本文整理汇总了C++中AcApDocument类的典型用法代码示例。如果您正苦于以下问题:C++ AcApDocument类的具体用法?C++ AcApDocument怎么用?C++ AcApDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AcApDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectDocument
//
// NAME: selectDocument
//
// REMARKS: Simple utility to have the user choose an open document to
// perform some action on.
//
//
//
// RETURNS:
// void
static AcApDocument* selectDocument()
{
AcApDocument* documentArray[10];
AcApDocument* pDoc;
AcApDocumentIterator* pDocIter;
int nDocs = 0;;
pDocIter = acDocManager->newAcApDocumentIterator();
for ( ; !pDocIter->done(); pDocIter->step(), nDocs++) {
pDoc = pDocIter->document();
documentArray[nDocs] = pDoc;
acutPrintf("%d. %s\n", nDocs + 1, pDoc->fileName());
}
delete pDocIter;
acedInitGet(RSG_NOZERO | RSG_NONEG, NULL);
int iSelection;
int inputStatus = acedGetInt("Which document should this command execute in: ", &iSelection);
if (inputStatus == RTNORM && iSelection <= nDocs) {
return documentArray[iSelection - 1];
} else {
return NULL;
}
}
示例2: acutPrintf
// Notification when a SAVE is complete Typical method to detect when
// a document has been renamed
void
AsdkEditorReactor::saveComplete (AcDbDatabase*, const char* pActualName)
{
AcApDocument* pDoc = acDocManager->curDocument();
if (pDoc)
acutPrintf("DOCUMENT: Save complete %s\n", pDoc->fileName());
}
示例3: newSyncDoc
// NAME: newSyncDoc()
//
// REMARKS: Simple function which requests a NEW to be executed via the application context.
//
//
// NOTEs: See explanation for inAppContext()
// RETURNS:
// void
//
void
newSyncDoc()
{
static char pData[] = /*NOXLATE*/"acad.dwt";
AcApDocument* pDoc = acDocManager->curDocument();
if (pDoc) {
acutPrintf("\nCurrently in Document context : %s, Switching to App.\n",pDoc->fileName());
acDocManager->executeInApplicationContext(newSyncDocHelper, (void *)pData);
}
}
示例4: newSyncDocHelper
// NAME: newSyncDocHelper()
//
// REMARKS: Simple callback function to be executed in the application context.
// Demonstrates creating a new document synchronously to retain control
// in caller function
//
// NOTEs: See explanation for inAppContext()
// RETURNS:
// void
//
void
newSyncDocHelper( void *pData)
{
AcApDocument* pDoc = acDocManager->curDocument();
if (acDocManager->isApplicationContext()) {
acutPrintf("\nSucessfully Switched to App. Context\n");
acDocManager->appContextNewDocument((const char *)pData);
acutPrintf("\nOpened a new document synchronously.\n");
} else
acutPrintf("\nERROR: in Document context : %s\n",pDoc->fileName());
}
示例5: appContext
// NAME: appcontext()
//
// REMARKS: Simple function which requests a routine to be executed via the application context.
//
//
// NOTEs: See explanation for inAppContext()
// RETURNS:
// void
//
void
appContext()
{
static char pData[] = "Test Param";
AcApDocument* pDoc = acDocManager->curDocument();
if (pDoc) {
acutPrintf("\nCurrently in Document context : %s, Switching to App.\n",pDoc->fileName());
acDocManager->executeInApplicationContext(inAppContext, (void *)pData);
}
}
示例6: inAppContext
// NAME: inAppContext()
//
// REMARKS: Simple callback function to be executed in the application context.
//
// NOTES: The application context is unique from each document. It is the supervisor
// that delegates between each document that is currently opened. Mode-less dialogs
// and other floating dialogs execute in this domain. As such it is the only
// context where a document can be created that will not be suspended when the new document
// becomes active. In the previous OPEN and NEW APIs it was explained that once
// suspended a line of code following those APIs would not be executed until that
// document is activated again. For advanced operations a developer may require the
// ability to execute a routine from within the applciation context to overcome
// this limitation. As such, executeInApplicationContext() and its companion funcitons
// appContextOpenDocument() and appContextNewDocument() were provided.
//
//
// RETURNS:
// void
//
void
inAppContext( void *pData)
{
AcApDocument* pDoc = acDocManager->curDocument();
if (acDocManager->isApplicationContext()) {
acutPrintf("\nSucessfully Switched to App. Context\n");
if (pData != NULL)
acutPrintf("\nData: %s\n", (char *)pData);
} else
acutPrintf("\nERROR: in Document context : %s\n",pDoc->fileName());
}
示例7: OnIsquiescentButton
void CMDITestDialog::OnIsquiescentButton()
{
AcApDocument *pDoc = acDocManager->curDocument();
if(pDoc) {
CString tempStr;
tempStr.Format("Current Doc is %s\nlockMode() returned %s\nand myLockMode() returned %s.",
pDoc->isQuiescent() ? "Quiescent." : "NOT Quiescent.",
modeStr(pDoc->lockMode()),
modeStr(pDoc->myLockMode()) );
AfxMessageBox( tempStr );
}
}
示例8: listDocuments
//
// NAME: listDocuments
//
// REMARKS: Iterate over all the open documents. Very common piece of code
// for MDI aware applications.
//
//
// RETURNS:
// void
void
listDocuments()
{
AcApDocument* pDoc;
AcApDocumentIterator* pDocIter;
pDocIter = acDocManager->newAcApDocumentIterator();
for ( ; !pDocIter->done(); pDocIter->step()) {
pDoc = pDocIter->document();
acutPrintf(" %s\n", pDoc->fileName());
}
delete pDocIter;
}
示例9: acutPrintf
void
ArxDbgUiTdcSysReactors::removeInputReactorFromAll()
{
if (m_inputReactor) {
AcApDocument* tmpDoc;
AcDbVoidPtrArray docPtrs;
ArxDbgUtils::getAllDocuments(docPtrs);
acutPrintf(_T("\nRemoving Editor Input Reactor from all documents..."));
int len = docPtrs.length();
for (int i=0; i<len; i++) {
tmpDoc = static_cast<AcApDocument*>(docPtrs[i]);
tmpDoc->inputPointManager()->removeInputContextReactor(m_inputReactor);
}
}
}
示例10: send
//
// NAME: send
//
// REMARKS: Simple routine to exercise switching between documents and sending commands.
//
// NOTEs: The actual signature for sendStringToExecute is:
// virtual Acad::ErrorStatus sendStringToExecute(
// AcApDocument* pAcTargetDocument,
// const char * pszExecute,
// bool bActivate = true,
// bool bWrapUpInactiveDoc = false) = 0;
//
// By default this API activates the document you are sending the string to
// to be executed to. The last parameter, bWrapUpInactiveDoc is only applicable
// if bActivate == False. This special ability allows you to "clean up"
// a document you might have left with some dangling command when constructing
// a command that spans documents. One scenario is you are in the middle of
// a custom command whose implementation is designed to "follow" the user
// as they move from one document to another. If you have registered a reactor
// on documentToBeActivated(). When this reactor fires you wish to complete
// your current command in the document that is being deactivated and start
// a command in the document about to be activated.
// Given these conditions, you would possibly send a "return" to the old
// document and "execute my new command" string to the one about to activated.
// The "return" you would want to process in the background so you would pass
// bActivate = False and bWrapUpInactiveDoc = True.
//
// RETURNS:
// void
//
void
send()
{
AcApDocument* pDoc = selectDocument();
if (pDoc == NULL) {
acutPrintf("No document selected.\n");
return;
}
acDocManager->sendStringToExecute(pDoc, /*NOXLATE*/"_Line\n");
// The API inputPending() allows you to check to see if someone else has already
// made a request via sendStringToExecute() to a target document.
// You may not care if your command is autonomous and does not depend on the target
// document being in a quiescent state. If not call both isQuiescent() and inputPending()
acutPrintf("\nSent String to Doc: %s Pending Input %d\n", pDoc->fileName(), acDocManager->inputPending(pDoc));
}
示例11: getDocFromFilename
// getDocFromFilename()
// Passed a filename, it finds the corresponding document pointer
// Returns true if successful
bool CMDITestDialog::getDocFromFilename(CString csFileName, AcApDocument* &pNewDocument)
{
// Iterate over the open documents. We will match the filename if:
// The filename specified matches the fully qualified path
// name, as returned by AcApDocument::filename()
// -or-
// The filename specified matches the filename portion of the
// document name
AcApDocumentIterator* iter = acDocManager->newAcApDocumentIterator();
AcApDocument* pThisDocument = NULL;
CString csThisFilename;
CString csThisFilenameShort;
csFileName.MakeUpper(); // uppercase comparisons
while(!iter->done()) { // Tiptoe through the tulips
pThisDocument = iter->document();
csThisFilename = pThisDocument->docTitle();
csThisFilename.MakeUpper();
csThisFilenameShort = csThisFilename.Right(csThisFilename.GetLength() -
csThisFilename.ReverseFind('\\') - 1);
if(csFileName == csThisFilename || // Full path match
csFileName == csThisFilenameShort || // Matches filename only
csFileName == csThisFilenameShort.Left( // Filename less extension
csThisFilenameShort.GetLength() - 4))
{
pNewDocument = pThisDocument;
if( iter )
delete iter;
return true;
}
iter->step();
}
pNewDocument = NULL;
if( iter )
delete iter;
// no match found
return false;
}
示例12: RebuildListBox
void CMDITestDialog::RebuildListBox()
{
m_docListBox.ResetContent(); // start from an empty list box
// at this moment, get all drawing names and add them to the list box.
AcApDocumentIterator* iter = acDocManager->newAcApDocumentIterator();
AcApDocument* pDoc = NULL;
CString csFilename;
while(!iter->done()) {
pDoc = iter->document();
if(pDoc) { // #### make sure pDoc is not NULL ####
csFilename = pDoc->docTitle();
m_docListBox.AddString( csFilename );
}
iter->step();
}
if( iter )
delete iter;
}
示例13: append
bool append(AcDbEntity* pEntity)
{
AcDbBlockTable *pBlockTable;
AcApDocument* pDoc = acDocManager->curDocument();
Acad::ErrorStatus es = acDocManager->lockDocument(pDoc);
if (es != Acad::eOk) {
acedAlert("Failed to lock the document...");
return false;
}
AcDbDatabase* pDb = pDoc->database();
es = pDb->getBlockTable(pBlockTable, AcDb::kForRead);
if (es != Acad::eOk) {
acedAlert("Failed to get block table...");
return false;
}
AcDbBlockTableRecord *pBlockRec;
es = pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockRec, AcDb::kForWrite);
if (es != Acad::eOk) {
acedAlert("Failed to get block table record...");
pBlockTable->close();
return false;
}
es = pBlockRec->appendAcDbEntity(pEntity);
if (es != Acad::eOk) {
acedAlert("Failed to append entity...");
pBlockTable->close();
pBlockRec->close();
delete pEntity;
return false;
}
pBlockRec->close();
pBlockTable->close();
return true;
}
示例14: getDocCount
LRESULT CMDITestDialog::onAcadUpdateDialog( WPARAM, LPARAM )
{
// update elements of the dialog to reflect the current
// state of the documents
// get the current number of documents
m_staticDocNum.SetWindowText( getDocCount() );
// check/uncheck document activation
m_activationCheck.SetCheck( acDocManager->isDocumentActivationEnabled() );
// set the current document fields
CString fName;
AcApDocument *pCurrDoc = acDocManager->curDocument();
if( pCurrDoc ) {
fName = pCurrDoc->docTitle();
m_staticCurrentDoc.SetWindowText(fName);
m_staticToBeCurrDoc.SetWindowText(fName);
m_staticCurDocLockStatus.SetWindowText( modeStr(pCurrDoc->lockMode()) );
m_staticCurDocMyLockStatus.SetWindowText( modeStr(pCurrDoc->myLockMode()) );
}
else {
m_staticCurrentDoc.SetWindowText(fName);
m_staticToBeCurrDoc.SetWindowText("");
m_staticCurDocLockStatus.SetWindowText("");
m_staticCurDocMyLockStatus.SetWindowText("");
}
// set the active document data
AcApDocument *pActDoc = acDocManager->mdiActiveDocument();
if( pActDoc ) {
// active document name
fName = pActDoc->docTitle();
m_staticActiveDoc.SetWindowText(fName);
// active document lock modes
m_staticActDocLockStatus.SetWindowText( modeStr(pActDoc->lockMode()) );
m_staticActDocMyLockStatus.SetWindowText( modeStr(pActDoc->myLockMode()) );
}
else {
m_staticActiveDoc.SetWindowText("");
m_staticActDocLockStatus.SetWindowText("");
m_staticActDocMyLockStatus.SetWindowText("");
}
// rebuild listbox
RebuildListBox();
return TRUE;
}
示例15: LSS06
void LSS06()
{
CLogger::Print(_T("-------------| START LOGGING LESSONS 06 |--------------"));
//------------
// Get the current DENKI project pointer, and number of files of project.
if (!DenkiIsOpenProject()) {
acutPrintf(ACRX_T("Denki project has not been opened yet!"));
return;
}
ACHAR szMsg[256] = ACRX_T("\0");
DenkiDwgProject* pCurProj = DenkiDwgProject::getCurrent();
int nFileCount = pCurProj->count();
if (nFileCount < 1) {
CLogger::Print(_T("*Exit: There is no file within current project!"));
return;
}
//------------
// Get the 'Duplication Check Level' option of DENKI project.
DenkiDuplicationCheckLevel CheckLvl = DenkiGetDuplicationCheckLevel(_T("NAME"));
bool bChkInstNo = (CheckLvl == dclAsInstNumber) ? true : false;
bool bChkBanNo = (CheckLvl == dclAsBanNumber) ? true : false;
if (bChkInstNo) {
bChkBanNo = true;
}
CLogger::Print(_T("> INS_NO: %s - BAN_NO: %s")
, (bChkInstNo ? _T("Checked") : _T("Unchecked"))
, (bChkBanNo ? _T("Checked") : _T("Unchecked")));
//------------
// Require to input BAN_NO, INST_NO, NAME keywords to search.
ACHAR szNeedBanNo[256] = ACRX_T("\0");
ACHAR szNeedInstNo[256] = ACRX_T("\0");
ACHAR szNeedName[256] = ACRX_T("\0");
if (bChkBanNo) {
::LoadString(_hdllInstance, IDS_ASK_BANNO, szMsg, sizeof(szMsg)/sizeof(ACHAR));
if (RTNORM != acedGetString(1, szMsg, szNeedBanNo)) {
CLogger::Print(_T("*Exit: Fail to get the BAN_NO keyword."));
return;
}
}
if (bChkInstNo) {
::LoadString(_hdllInstance, IDS_ASK_INSTNO, szMsg, sizeof(szMsg)/sizeof(ACHAR));
if (RTNORM != acedGetString(1, szMsg, szNeedInstNo)) {
CLogger::Print(_T("*Exit: Fail to get the INST_NO keyword."));
return;
}
}
::LoadString(_hdllInstance, IDS_ASK_NAME, szMsg, sizeof(szMsg)/sizeof(ACHAR));
if (RTNORM != acedGetString(1, szMsg, szNeedName)) {
CLogger::Print(_T("*Exit: Fail to get the NAME keyword."));
return;
}
//------------
// Steps through DENKI project's files.
for (int nIndex = 0; nIndex < nFileCount; nIndex++) {
CLogger::Print(_T("---- Index = %d ----"), nIndex);
DenkiDwgProjectFile& file = pCurProj->getDwgAt(nIndex);
if (!file.hasZuwaku()) {
CLogger::Print(_T("Warn: File has not ZUWAKU. > Ignore"));
continue;
}
// Get file path, and file name
LPCASTR pszFileName = NULL;
file.getFilePath(pszFileName);
CLogger::Print(_T("> %s"), pszFileName);
// Check whether or not file has got DENKI_ZUWAKU.
DWORD dwFlags = 0;
if (!file.getZuwakuFlags(dwFlags)) {
CLogger::Print(_T("Warn: Fail to get the ZUWAKU flags > Ignore"));
continue;
}
if (!(dwFlags & DENKI_ZUWAKU)) {
CLogger::Print(_T("Warn: File has not DENKI_ZUWAKU. > Ignore"));
continue;
}
// Get the current working database (Just to store).
AcDbDatabase* pCurDb = acdbHostApplicationServices()->workingDatabase();
Acad::ErrorStatus esResult;
AcApDocument* pDoc = NULL;
AcDbDatabase* pDb = NULL;
bool bFromProject = false;
bool bReadMyseft = false;
// Look up the required database from managed documents.
if (pDoc = findDocument(pszFileName)) {
CLogger::Print(_T("Inform: found out the database from managed documents."));
pDb = pDoc->database();
//.........这里部分代码省略.........