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

AcApProfileManagerReactor Класс


AcApProfileManagerReactor класс обеспечивает контейнер для различных  события уведомлений, основанных на изменении параметров пользователем.

AcApProfileManagerReactor уведомления класса

Уведомление

Связанный Метод

Текущий профиль собирается быть измененным



 AcApProfileManagerReactor::currentProfileWillChange

Текущий профиль был изменен

 AcApProfileManagerReactor::currentProfileChanged

Текущий профиль собирается быть сброшенным

 AcApProfileManagerReactor::currentProfileWillBeReset

Текущий профиль был сброшен

 AcApProfileManagerReactor::currentProfileReset

Не-текущий профиль собирается быть сброшенным

 AcApProfileManagerReactor::profileWillReset

Не-текущий профиль был сброшен

AcApProfileManagerReactor:: profileReset

Пример менеджера профилей

Следующая выборка демонстрирует использование Классов AcApProfileManagerReactor и AcApProfileManager:

// Определить класс, полученный из AcApProfileManagerReactor, чтобы управлять уведомлениями.

//

class AsdkProfileManagerReactor : public AcApProfileManagerReactor

{

public:

void currentProfileWillChange(const char *newProfile);

void currentProfileChanged(const char *newProfile);

void currentProfileWillBeReset(const char *curProfile);

void currentProfileReset(const char *curProfile);

void profileWillReset(const char *profName);

void profileReset(const char *proName);

};

// Define the notification functions.

//

void

AsdkProfileManagerReactor::

currentProfileWillChange(const char *newProfile)

{

acutPrintf("\nCurrent profile will change: %s", newProfile);

}

void

AsdkProfileManagerReactor::

currentProfileChanged(const char *newProfile)

{

acutPrintf("\nCurrent profile changed: %s", newProfile);

}

void

AsdkProfileManagerReactor::

currentProfileWillBeReset(const char *curProfile)

{

acutPrintf("\nCurrent profile will be reset: %s", curProfile);

}

void

AsdkProfileManagerReactor::


currentProfileReset(const char *curProfile)

{

acutPrintf("\ nCurrent profile has been reset: %s", curProfile);

}

void

AsdkProfileManagerReactor::

profileWillReset(const char *profName)

{

acutPrintf("\nNon-current profile will be reset: %s", profName);

}

void

AsdkProfileManagerReactor::

profileReset(const char *profName)

{

acutPrintf("\nNon-current profile has been reset:%s", profName);

}

void

aFunction()

{

acutPrintf("This is AsdkProfileSample Test Application...\n");

// Attach the reactor for the duration of this command. Normally

// this would be added upon application initialization.

//

AsdkProfileManagerReactor *pProfileRector =

new AsdkProfileManagerReactor();

acProfileManagerPtr()->addReactor(pProfileRector);

// Obtain the path for the registry keys and print it out.

//

char *pstrKey;

acProfileManagerPtr()->ProfileRegistryKey(pstrKey, NULL);

if (pstrKey != NULL) {

acutPrintf("\nThe profiles registry key is: %s", pstrKey);

acutDelString(pstrKey);

}

// Get the list of all profiles in the user’s configuration

// and print them out.

//

AcApProfileNameArray arrNameList;

int nProfiles =

acProfileManagerPtr()->ProfileListNames(arrNameList);

acutPrintf("\nNumber of profiles currently "

"in the user profile list is: %d", nProfiles);

for (int i = 0; i < nProfiles; i++)

acutPrintf("\nProfile name is: %s", arrNameList[i]);

// Copy the unnamed profile to the AsdkTestProfile.

//

acProfileManagerPtr()->ProfileCopy(

"AsdkTestProfile",

"<<Unnamed Profile>>",

"This is a test");

// Reset the newly copied profile to AutoCAD defaults.

//

acProfileManagerPtr()->ProfileReset("AsdkTestProfile");

// Make this new profile current.

//

acProfileManagerPtr()->ProfileSetCurrent("AsdkTestProfile");

// Change a value in the profile. For this example, make the

// cursor big.

//

struct resbuf rbCursorSize;

rbCursorSize.restype = RTSHORT;

rbCursorSize.resval.rint = 100;

acedSetVar("CURSORSIZE", &rbCursorSize);

// Rename the profile to a new name.

//

acProfileManagerPtr()->ProfileRename(

"AsdkTestProfile2",

"AsdkTestProfile",

"This is another test");

// Export the profile.

//

acProfileManagerPtr()->ProfileExport(

"AsdkTestProfile2",

"./AsdkTestProfile2.arg");

// Import the profile.

//

acProfileManagerPtr()->ProfileImport(

"AsdkTestProfile3",

"./AsdkTestProfile2.arg",

"This is a copy of AsdkTestProfile2"

"by Exporting/Importing",

Adesk::kTrue);

// Remove the reactor.

//

acProfileManagerPtr()->removeReactor(pProfileRector);

}


Содержание раздела