ObjectARX, AutoCAD. Среда программирования библиотеки C++



         

Пример MDI-ЗНАЮЩЕГО приложения - часть 4


// document.

//

void AsdkAppDocGlobals::unload()

{

acDocManager->removeReactor(m_pDocReactor);

delete m_pDocReactor;

removeAllDocGlobals(m_pHead);

m_pHead = m_pData = NULL;

}

 

long &

AsdkAppDocGlobals::entityCount()

{

return m_pData->m_EntAcc;

}

 

void

AsdkAppDocGlobals::incrementEntityCount()

{

m_pData->m_EntAcc++;

}

 

void

AsdkAppDocGlobals::decrementEntityCount()

{

m_pData->m_EntAcc--;

}

 

AsdkDbReactor *

AsdkAppDocGlobals::dbReactor()

{

return m_pData->m_pDbr;

}

 

void

AsdkAppDocGlobals::setDbReactor(AsdkDbReactor *pDb)

{

m_pData->m_pDbr = pDb;

}

// Adds a reactor to the database to monitor changes.

// This can be called multiple times without any ill

// effects because subsequent calls will be ignored.

//

void

watchDb()

{

AsdkDbReactor *pDbr;

if (gpAsdkAppDocGlobals->dbReactor() == NULL)

{

pDbr = new AsdkDbReactor();

gpAsdkAppDocGlobals->setDbReactor(pDbr);

acdbHostApplicationServices()->workingDatabase()->addReactor(pDbr);

acutPrintf(

" Added Database Reactor to "

"acdbHostApplicationServices()->workingDatabase().\n");

}

}

// Removes the database reactor.

//

void

clearReactors()

{

AsdkDbReactor *pDbr;

if ((pDbr = gpAsdkAppDocGlobals->dbReactor()) != NULL)

{

acdbHostApplicationServices()->workingDatabase()->removeReactor(pDbr);

delete pDbr;

gpAsdkAppDocGlobals->setDbReactor(NULL);

}

}

// ObjectARX entry point function

//

AcRx::AppRetCode

acrxEntryPoint(AcRx::AppMsgCode msg, void* appId)

{

switch (msg) {

case AcRx::kInitAppMsg:

acrxUnlockApplication(appId);

acrxRegisterAppMDIAware(appId);

gpAsdkAppDocGlobals = new AsdkAppDocGlobals(curDoc());

gpAsdkAppDocGlobals->setGlobals(curDoc());

acedRegCmds->addCommand("ASDK_NOTIFY_TEST",

"ASDK_WATCH",

"WATCH",

ACRX_CMD_TRANSPARENT,

watchDb);

acedRegCmds->addCommand("ASDK_NOTIFY_TEST",

"ASDK_CLEAR",

"CLEAR",

ACRX_CMD_TRANSPARENT,

clearReactors);

break;

case AcRx::kUnloadAppMsg:

if (gpAsdkAppDocGlobals != NULL)

{

gpAsdkAppDocGlobals->unload();

delete gpAsdkAppDocGlobals;

gpAsdkAppDocGlobals = NULL;

}

acedRegCmds->removeGroup("ASDK_NOTIFY_TEST");

break;

}

return AcRx::kRetOK;

}




Содержание  Назад  Вперед