Skip to content

Commit

Permalink
[#165] PyAcadApplicationImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
CEXT-Dan committed Jan 2, 2025
1 parent 1c02b7e commit 378af40
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 8 deletions.
78 changes: 75 additions & 3 deletions PyRxCore/PyAcadApplicationImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void PyAcadApplicationImpl::Eval(const CString& csVal) const
PyThrowBadHr(impObj()->Eval(bstrVal));
}

std::vector<std::wstring> PyAcadApplicationImpl::ListArx()
wstringArray PyAcadApplicationImpl::ListArx()
{
VARIANT rtVal;
VariantInit(&rtVal);
Expand All @@ -38,11 +38,83 @@ std::vector<std::wstring> PyAcadApplicationImpl::ListArx()
return vec;
}

void PyAcadApplicationImpl::LoadArx(const CString& csVal)
{
_bstr_t bstrVal{ csVal };
#if defined(_ZRXTARGET)
PyThrowBadHr(impObj()->LoadZrx(bstrVal));
#elif defined(_GRXTARGET)
PyThrowBadHr(impObj()->LoadGrx(bstrVal));
#else
PyThrowBadHr(impObj()->LoadArx(bstrVal));
#endif
}

void PyAcadApplicationImpl::LoadDVB(const CString& csVal)
{
#if defined(_ZRXTARGET)
throw PyNotimplementedByHost();
#else
_bstr_t bstrVal{ csVal };
PyThrowBadHr(impObj()->LoadDVB(bstrVal));
#endif
}

void PyAcadApplicationImpl::Quit()
{
PyThrowBadHr(impObj()->Quit());
}

void PyAcadApplicationImpl::RunMacro(const CString& csVal)
{
_bstr_t bstrVal{ csVal };
PyThrowBadHr(impObj()->RunMacro(bstrVal));
}

void PyAcadApplicationImpl::UnloadArx(const CString& csVal)
{
_bstr_t bstrVal{ csVal };
#if defined(_ZRXTARGET)
PyThrowBadHr(impObj()->UnloadZrx(bstrVal));
#elif defined(_GRXTARGET)
PyThrowBadHr(impObj()->UnloadGrx(bstrVal));
#else
PyThrowBadHr(impObj()->UnloadArx(bstrVal));
#endif
}

void PyAcadApplicationImpl::UnloadDVB(const CString& csVal)
{
#if defined(_ZRXTARGET)
throw PyNotimplementedByHost();
#else
_bstr_t bstrVal{ csVal };
PyThrowBadHr(impObj()->UnloadDVB(bstrVal));
#endif
}

void PyAcadApplicationImpl::Update()
{
PyThrowBadHr(impObj()->Update());
}

void PyAcadApplicationImpl::ZoomAll()
{
PyThrowBadHr(impObj()->ZoomAll());
}

void PyAcadApplicationImpl::ZoomCenter(const AcGePoint3d& pnt, double magnify)
{
VARIANT rtVal;
VariantInit(&rtVal);
InitVariantFromDoubleArray(asDblArray(pnt), 3, &rtVal);
PyThrowBadHr(impObj()->ZoomCenter(rtVal,magnify));
}

bool PyAcadApplicationImpl::runTest()
{
PyAcadApplicationImpl app;
for (const auto& item : app.ListArx())
acutPrintf(_T("\n%ls"), item.c_str());
app.ZoomCenter(AcGePoint3d(0,0,0),10);
return true;
}

Expand Down
25 changes: 20 additions & 5 deletions PyRxCore/PyAcadApplicationImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

#ifdef PYRXDEBUG

#include <atlbase.h>
#include <atlsafe.h>

#pragma comment( lib , "propsys.lib" )

#if defined(_BRXTARGET) && (_BRXTARGET <= 250)
Expand Down Expand Up @@ -49,16 +52,28 @@
#define IAcadDocument IGcadDocument
#endif

using wstringArray = std::vector<std::wstring>;

class PyAcadApplicationImpl
{
public:
PyAcadApplicationImpl();
~PyAcadApplicationImpl() = default;
void Eval(const CString& csVal) const;
//AcadState GetAcadState();
std::vector<std::wstring> ListArx();


void Eval(const CString& csVal) const;
//AcadState GetAcadState();
wstringArray ListArx();
void LoadArx(const CString& csVal);
void LoadDVB(const CString& csVal);
void Quit();
void RunMacro(const CString& csVal);
void UnloadArx(const CString& csVal);
void UnloadDVB(const CString& csVal);
void Update();
//void Zoom(int ...);
void ZoomAll();
void ZoomCenter(const AcGePoint3d& pnt, double magnify);


static bool runTest();
public:
IAcadApplication* impObj(const std::source_location& src = std::source_location::current()) const;
Expand Down

0 comments on commit 378af40

Please sign in to comment.