void cmdCursorOff()
{
    acutPrintf( _T("%d callers have disabled system graphics.\n"), curDoc()->inputPointManager()->systemCursorDisableCount() );
    acutPrintf( _T("Enabling system graphics...\n") );
    curDoc()->inputPointManager()->enableSystemCursorGraphics();
    acutPrintf( _T("%d callers have disabled system graphics.\n"), curDoc()->inputPointManager()->systemCursorDisableCount() );
}
void cmdForcedPickOff()
{
    acutPrintf( _T("%d callers have turned on forced picking.\n"), curDoc()->inputPointManager()->forcedPickCount() );
    acutPrintf( _T("Turning on forced picking...\n") );
    curDoc()->inputPointManager()->turnOffForcedPick();
    acutPrintf( _T("%d callers have turned on forced picking.\n"), curDoc()->inputPointManager()->forcedPickCount() );
}
BOOL CLayerTreeDlg::SetCurrentLayer(CString strCADLayer)
{
	acDocManager->lockDocument(curDoc());

	struct resbuf *Value = acutBuildList(RTSTR,strCADLayer,0); 

	int err = acedSetVar("clayer", Value);

	acutRelRb(Value);

	if( err != RTNORM)
	{
		acDocManager->unlockDocument(curDoc());

		acutPrintf("\n切换当前图层至 %s 的时候发生错误,请稍后再试。\n",strCADLayer);

		return FALSE;
	}

	acDocManager->unlockDocument(curDoc());

	acutPrintf("\n当前图层切换为 %s\n", strCADLayer);

	return TRUE;
}
Example #4
0
void
CCurveTextJig::doIt()
{

	AcDbObjectId eId;
	if(!m_pCurvetext) return;

	double startDist = m_pCurvetext->getStartDist();
	double length = m_pCurvetext->getLength();
	m_pCurvetext->setInJig(true);
	// sets the input point monitor
	//
	curDoc()->inputPointManager()->addPointMonitor(&m_InputPoint);
	// starts the drag sequence
	//
	AcEdJig::DragStatus stat = drag();
	// remove the input point monitor
	//
	curDoc()->inputPointManager()->removePointMonitor(&m_InputPoint);
	m_pCurvetext->setInJig(false);
	// if cancel, resets the orignal state
	//
    if(stat == AcEdJig::kCancel)
	{
		m_pCurvetext->setStartDist(startDist);
		m_pCurvetext->setLength(length);
		m_pCurvetext->recordGraphicsModified();
		return;
	}
}
Example #5
0
// Arx 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;
}
Example #6
0
void CZhfPalette::AddControls()
{
	acDocManager->lockDocument(curDoc(), AcAp::kWrite, NULL, NULL, true) ;
	CRect rect ;
	GetClientRect(&rect) ;
	int iWidth = rect.Width() ;
	int iHeight = rect.Height() ;

	CFont * pFont = new CFont;
	pFont->CreateFont(14, // nHeight
		0, // nWidth
		0, // nEscapement
		0, // nOrientation
		FW_NORMAL , // nWeight
		FALSE, // bItalic
		FALSE, // bUnderline
		0, // cStrikeOut
		ANSI_CHARSET, // nCharSet
		OUT_DEFAULT_PRECIS, // nOutPrecision
		CLIP_DEFAULT_PRECIS, // nClipPrecision
		DEFAULT_QUALITY, // nQuality
		DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
		_T("Arial")); // lpszFac


	int iIndex = 0 ;
	int iCount = m_strArrayFile.GetCount() ;
	for (int i=0; i<iCount; i++)
	{
		CString strFile = m_strArrayFile.GetAt(i) ;

		CGsPreviewCtrl* pCtrl = new CGsPreviewCtrl() ;
		pCtrl->m_iIndex = iIndex ;
		pCtrl->m_strDwgFile = strFile ;
		m_pArrayPreviewCtrl.Add(pCtrl) ;
		pCtrl->Create(_T(""), WS_CHILD|WS_VISIBLE|SS_CENTER|SS_SUNKEN, CRect(10, 10, 110, 110), this) ;
		
		AcDbDatabase* pDbSrc = new AcDbDatabase(false) ;
		if(Acad::eOk==pDbSrc->readDwgFile(strFile))
		{
			AcDbDatabase* pDbTo = new AcDbDatabase() ;
			this->Wblock(pDbSrc, pDbTo) ;
			this->FilterDb(pDbTo, m_nArrayFilterMode.GetAt(i)) ;

			pCtrl->SetDatabase(pDbTo);
		}
		delete pDbSrc ;		

		CStatic* pCtrlStatic = new CStatic() ;
		CString strFileName ;
		strFileName.Format(_T("%s"), m_strArrayFileName.GetAt(i)) ;		
		m_pArrayStatic.Add(pCtrlStatic) ;
		pCtrlStatic->Create(strFileName, WS_CHILD|WS_VISIBLE|SS_CENTER, CRect(10, 10, 40, 110), this) ;
		pCtrlStatic->SetFont(pFont) ;
		iIndex++ ;
	}
	acDocManager->unlockDocument(curDoc()) ;
	this->OnSize(0, iWidth, iHeight) ;
}
void cmdRemoveFilter()
{
    if ( NULL != curDoc()->inputPointManager()->currentPointFilter() )
    {
        curDoc()->inputPointManager()->revokePointFilter();
        acutPrintf( _T("Input point filter removed.\n") );
    }
}
    // ----- AsdkSelectionFilterUI.SubentSel command (do not rename)
    static void AsdkSelectionFilterUI_SubentSel(void)
    {
        // we have to allow duplicates; otherwise, the xref would be selectable
        // only once (because the main entity is the one that counts).

        setAllowDuplicateSelection(curDoc(), true);
        ads_name sset, eName;
        AcDbObjectId id;

        // "_:n" gives us nested entities
        //
        if (RTNORM == acedSSGet("_:n", NULL, NULL, NULL, sset))
        {
            acutPrintf("\n");
            long len = 0;
            acedSSLength(sset, &len);
            for (long i = 0; i < len; i++)// For each entity in sset
            {

                resbuf *rb = NULL;
                // We use ssnamex() here, because the regular ssname()
                // would give only the main entity (the xref)
                //
                if (RTNORM == acedSSNameX(&rb, sset, i))//Get the sub entity
                {
                    resbuf *rbWalk = rb;
                    while (NULL != rbWalk)
                    {
                        if (RTENAME == rbWalk->restype)
                        {
                            eName[0] = rbWalk->resval.rlname[0];
                            eName[1] = rbWalk->resval.rlname[1];
                            if(Acad::eOk == acdbGetObjectId(id, eName))
                            {
                                acutPrintf("Entity %d: <%x>", i, id.asOldId());
                                AcDbEntity *pEnt;
                                if (Acad::eOk == acdbOpenObject(pEnt, id, AcDb::kForRead))
                                {
                                    acutPrintf("(%s)\n", pEnt->isA()->name());
                                    pEnt->close();
                                }
                                else
                                    acutPrintf("\nCouldn't open object");
                            }
                            rbWalk = NULL; //force quit out of loop
                        }
                        else
                            rbWalk = rbWalk->rbnext;
                    }
                    acutRelRb(rb);
                }
            }
            acedSSFree(sset);
        }

        setAllowDuplicateSelection(curDoc(), false);
    }
Example #9
0
void CMyDlg::UpdateListCtr()
{
	acDocManager->lockDocument(curDoc());
	int nCount = m_ListCtr.GetItemCount();
	acutPrintf("%d\n", nCount);
	long lId;
	CString str;
	AcDbObjectId LineId;
	AcDbEntity *pEnt = NULL;
	AcDbLine *pLine = NULL;
	Acad::ErrorStatus es;
	
	if (nCount > 0)
	{
			for (int i = 0; i < nCount; ++i)
			{
				str = m_ListCtr.GetItemText(i, 0);
				lId = atol(str);
				LineId.setFromOldId(lId);
				//获得指针
				es = acdbOpenAcDbEntity(pEnt, LineId, AcDb::kForWrite);

				//检查是否被删除
				pLine = AcDbLine::cast(pEnt);
				if (es == Acad::eWasErased)
				{
					m_ListCtr.DeleteItem(i);
					--m_lLineCnt;
					--i;
					--m_Row;
				} 
				//检查颜色
				else if (es == Acad::eOk)
				{
					if (pLine)
					{
						str = m_ListCtr.GetItemText(i, 1);
						Adesk::UInt16 usColor = (Adesk::UInt16)atoi(str);
						if (pLine->colorIndex() != usColor)
						{
							char *buf = (char*)malloc(20);
							itoa((int)pLine->colorIndex(), buf, 10);
							m_ListCtr.SetItemText(i, 1, buf);
							free(buf);
						}
						pLine->close();
					}
				}						
			}
	}
	
	UpdateData(FALSE);
	acDocManager->unlockDocument(curDoc());
}
Example #10
0
//
//
//	Detach the database reactor if the db is deactivated.  
//  Close the dialog if requested by the user.
//
//
void detachDbReactor(AcDbDatabase* pDb)
{
	acDocManager->lockDocument(curDoc(), AcAp::kWrite);
    if(gpDbReactor) 
    {
        pDb->removeReactor(gpDbReactor);
		delete gpDbReactor;
		gpDbReactor = NULL;
		acutPrintf("\nDetached DbReactor from the current database.\n");
    }
	acDocManager->unlockDocument(curDoc());

	acedPostCommandPrompt();
}
Example #11
0
HRESULT CPolyCommand::initialize()
{
    HRESULT hr = S_OK;

    try {
        // Get an instance of a wrapper for a non-db-resident polygon
        if (FAILED(hr = m_pPoly.CoCreateInstance(CLSID_ComPolygon))) {
            // most likely problem, be a little more descriptive here
            acutPrintf("\nUnable to load ComPolygon");
            throw hr;
        }

        // Get the base object - needed for those methods inherited by polygon
        m_pBaseObj = m_pPoly;
        m_pBaseObj->CreateObject();

        // Get an instance of a listner so we know when input has been
        // entered in OPM
        if (FAILED(hr = CComObject<CComPolyCmd>::CreateInstance(&m_pPolyCmd)))
            throw hr;

        m_pPolyCmd->SetDocument(curDoc());
        hr = m_pPolyCmd->QueryInterface(IID_IUnknown,(LPVOID *)&m_pUnkCmd);
        if (FAILED(hr))
            throw hr;

        // Attach the listener to the polygon wrapper
        CComQIPtr<IConnectionPointContainer> pPtContainer;
        pPtContainer = m_pPoly;
        hr = pPtContainer->FindConnectionPoint(
            IID_IPropertyNotifySink,&m_pConPt);
        if (FAILED(hr))
            throw hr;

        if (FAILED(hr = m_pConPt->Advise(m_pUnkCmd,&m_dConnectionID)))
            throw hr;

        acedSetIUnknownForCurrentCommand(m_pPoly);

        m_pDb = curDoc()->database();

        setDefaults();

    } catch (HRESULT) {
        fail();
    }
    return hr;
}
Example #12
0
void CMyDlg::OnSelectLine()
{
	// TODO: Add your control notification handler code here
	ads_name adsNameSet, adsName;
	AcDbObjectId objId;
	int ret = 0;
	long lSelCnt = 0;
	AcDbEntity *pEnt = NULL;
	int nCount = m_ListCtr.GetItemCount();
	long lId;
	CString str;
	AcDbObjectId LineId;

	acDocManager->lockDocument(curDoc());

	ShowWindow(SW_HIDE);
	ret = acedSSGet(NULL, NULL, NULL, NULL, adsNameSet);
	
	if (RTNORM == ret)
	{
		m_ListCtr.SetFocus();
		acedSSLength(adsNameSet, &lSelCnt);
		for (long i = 0; i < lSelCnt; ++i)
		{
			acedSSName(adsNameSet, i, adsName);
			acdbGetObjectId(objId, adsName);
			if (nCount > 0)
			{
				for (int i = 0; i < nCount; ++i)
				{
					str = m_ListCtr.GetItemText(i, 0);
					lId = atol(str);
					LineId.setFromOldId(lId);
					if (LineId == objId)
					{				
						m_ListCtr.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
					}
				}
			}			
		}
		ShowWindow(SW_SHOW);
	}

	acedSSFree(adsName);
//	acutRelRb(stResBuf);
	acDocManager->unlockDocument(curDoc());
}
WindStationDockBarChildDlg::~WindStationDockBarChildDlg()
{
    if( curDoc() != 0 )
    {
        updateLastSelect();
        clearAll();
    }
}
Example #14
0
    // ----- AsdkSelectionFilterUI._DelSubselFilter command (do not rename)
    static void AsdkSelectionFilterUI_DelSubselFilter(void)
    {

        if (!pFilterDocReactor) return;
        pFilterDocReactor ->deleteSubSelFilter(curDoc());
        if (pRings != NULL)pRings ->setSubSelState(0);


    }
void WindStationDockBarChildDlg::clearAll()
{
    // 锁定当前文档
    acDocManager->lockDocument( curDoc() );
    // 恢复颜色
    ArxEntityHelper::SetEntitiesColor2( m_objIds, m_colors );

    acDocManager->unlockDocument( curDoc() );

    m_list.DeleteAllItems();
    m_objIds.removeAll();
    m_colors.removeAll();
    m_lastPos = -1;
    m_listFinishInitial = false;
    m_reasons.removeAll();
    m_hosts.removeAll();

    clearAllData();
}
Example #16
0
    // ----- AsdkSelectionFilterUI._AddSubentFilter command (do not rename)
    static void AsdkSelectionFilterUI_AddSubentFilter(void)
    {

        // Add new subentity selection filter for the current document
        if (!pFilterDocReactor) {
            pFilterDocReactor = new CFilterDocumentReactor();
            acDocManager->addReactor(pFilterDocReactor);
        }
        pFilterDocReactor ->addSubEntSelFilter(curDoc());

    }
Example #17
0
//
//	Attach the database reactor if one isn't attached already.  
//	Then, start up the dialog.
//
//
void attachDbReactor(AcDbDatabase* pDb)
{
	if(gbDisplayDialog)
	{
		AcDbDatabase* pWkDb = acdbHostApplicationServices()->workingDatabase();
		assert(pWkDb == pDb);
		AcDbDatabase* pCurDb = curDoc()->database();
		assert(pCurDb == pDb);
		acDocManager->lockDocument(curDoc(), AcAp::kWrite);
    
		gpDbReactor = new CDbModReactor();
		pWkDb->addReactor(gpDbReactor);
		acutPrintf("\nAttached CDbModReactor to the current database.\n");     
		
		acDocManager->unlockDocument(curDoc());
		acedPostCommandPrompt();
	}
	else
		endDlg();
}
Example #18
0
void
curveContextMenu::onCommand(Adesk::UInt32 cmdIndex)
{

	switch(cmdIndex)
	{
	case ID_CURVES_CURVETEXT:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.ct ");
		break;
	}
}
Example #19
0
void ArxEntityHelper::ZoomToEntityForModeless( const AcDbObjectId& objId )
{
	// 在非模态对话框下无法使用
	//ads_name en;
	//if(Acad::eOk != acdbGetAdsName(en, objId)) return;
	//acedCommand(RTSTR, _T("ZOOM"), RTSTR, _T("O"), RTENAME, en, RTSTR, _T(""), 0);

	// 临时使用sendStringToExecute解决缩放定位问题
	CString cmd;
	cmd.Format( _T( "ZOOM O \003" ) ); // 按空格结束选择对象,然后esc(防止多余的空格重复执行命令)
	acDocManager->sendStringToExecute( curDoc(), cmd, true, false, false );
}
void XAcDocOp::openDocCallBack(void *pData)
{
	if(pData == NULL || !AfxIsValidAddress(pData , sizeof(_CREATEDOCUMENTINFO)))
		return;

	CString strFilePathName;

	if(pData == NULL || !AfxIsValidAddress(pData , sizeof(_CREATEDOCUMENTINFO)))
		return;

	Acad::ErrorStatus	es;
	try
	{
		_CREATEDOCUMENTINFO	*pCreateInfo;
		pCreateInfo		= (_CREATEDOCUMENTINFO*)pData;
		strFilePathName = pCreateInfo->pszName;
		strFilePathName.Trim();

		//判断当前是否处于SDI模式
		BOOL	bIsSDIMode = FALSE;
		resbuf	*pRb;

		pRb	= acutNewRb(RTSHORT);
		if(acedGetVar("SDI" , pRb) == RTNORM && pRb->resval.rint == 1)	//是SDI模式
		{
			pCreateInfo->bActiveOldDoc	= FALSE;	//不能切换到先前的文档
			if(curDoc() != NULL)
				es = acDocManager->closeDocument(curDoc());	//关闭当前文档
		}
		acutRelRb(pRb);

		es = acDocManager->appContextOpenDocument(strFilePathName);

		if(pCreateInfo->bActiveOldDoc && pCreateInfo->pOldDoc != NULL)
			acDocManager->activateDocument(pCreateInfo->pOldDoc);
	}
	catch (...)
	{
	}
}
void WindStationDockBarChildDlg::OnLvnItemchangedAirList( NMHDR* pNMHDR, LRESULT* pResult )
{
    if( !m_listFinishInitial ) return;

    LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>( pNMHDR );

    if( pNMLV->iItem != -1 )
    {
        // 锁定当前文档
        acDocManager->lockDocument( curDoc() );

        // 第几个图元
        int row = pNMLV->iItem;

        if( m_lastPos != -1 )
        {
            // 保存数据
            writePropertyData( m_objIds[m_lastPos] );

            // 恢复上一次选择图元的颜色
            ArxEntityHelper::SetEntityColor( m_objIds[m_lastPos], m_colors[m_lastPos] );
        }

        clearAllData();
        // 读取数据
        readPropertyData( m_objIds[row] );

        // 缩放并用黄颜色高亮显示
        ArxEntityHelper::ZoomToEntity( m_objIds[row] );
        ArxEntityHelper::SetEntityColor( m_objIds[row], 2 );

        m_lastPos = row;

        acDocManager->unlockDocument( curDoc() );
    }

    *pResult = 0;
}
void WindStationDockBarChildDlg::initTunnelList()
{
    // 锁定当前文档
    acDocManager->lockDocument( curDoc() );

    // 查找用风地点以及缘由
    FindUseAirPlacesAndReasons( m_objIds, m_reasons );
    // 查找用风地点的测风站所在的宿主巷道
    FindWindStationHosts( m_objIds, m_hosts );

    // 记录颜色
    ArxEntityHelper::GetEntitiesColor( m_objIds, m_colors );

    // 解锁当前文档
    acDocManager->unlockDocument( curDoc() );

    //assert(m_objIds.length() == m_reasons.length());
    int len = m_objIds.length();
    for ( int i = 0; i < len; i++ )
    {
        // 序号
        CString num;
        num.Format( _T( "%d" ), i + 1 );
        m_list.InsertItem( i, num );
        //m_list.SetItemData(i, i);

        m_list.SetItemText( i, 0, num );
        m_list.SetItemText( i, 1, m_reasons[i].kACharPtr() );
    }

    // 选中第1个
    if( len > 0 )
    {
        m_list.SetItemState( 0, LVIS_SELECTED, LVIS_SELECTED );
        m_listFinishInitial = true;
    }
}
Example #23
0
void CMyDlg::OnDelLine() 
{
	// TODO: Add your control notification handler code here
	int nItem;
	long lId;
	CString str;
	AcDbObjectId LineId;
	AcDbEntity *pEnt = NULL;
	AcDbLine *pLine = NULL;
	Acad::ErrorStatus es;

	acDocManager->lockDocument(curDoc());
	//在列表中删除选定行
	while(m_ListCtr.GetNextItem(-1, (LVNI_ALL | LVNI_SELECTED)) != -1)
	{
		nItem = m_ListCtr.GetNextItem(-1, (LVNI_ALL | LVNI_SELECTED));
		str = m_ListCtr.GetItemText(nItem, 0);
		//acutPrintf("%s\n", str);
		lId = atol(str);
		LineId.setFromOldId(lId);
		//获得指针
		es = acdbOpenAcDbEntity(pEnt, LineId, AcDb::kForWrite);
		//在模型空间删除相应实体
		pLine = AcDbLine::cast(pEnt);
		if (pLine)
		{
			pLine->erase();
			pLine->close();
			m_ListCtr.DeleteItem(nItem);
			--m_Row;
		}	
	}
	UpdateData(FALSE);
	
	acDocManager->unlockDocument(curDoc());	
}
void WindStationDockBarChildDlg::OnBnClickedStationReadBtn()
{
    int row = LB_ERR;
    for( int i = 0; i < m_list.GetItemCount(); i++ )
    {
        if( LVIS_SELECTED == m_list.GetItemState( i, LVIS_SELECTED ) )
        {
            row = i;
            break;
        }
    }
    if( row == LB_ERR ) return;

    if( !m_hasStation )
    {
        CString msg;
        msg.Format( _T( "请先设置测风站!!!\n【提示】\n点击工具栏的【测风站】按钮绘制测风站" ) );
        MessageBox( msg );
        return;
    }

    // 读取测风站所在巷道的【断面面积】、【风速】、【风量】数据
    AcDbObjectId objId = m_objIds[row];

    // 锁定当前文档
    acDocManager->lockDocument( curDoc() );

    //DataHelper::GetPropertyData(objId, _T("名称"), m_name);
    DataHelper::GetPropertyData( objId, _T( "断面面积" ), m_area );
    DataHelper::GetPropertyData( objId, _T( "风速" ), m_v );
    DataHelper::GetPropertyData( objId, _T( "风量" ), m_q );

    acDocManager->unlockDocument( curDoc() );

    UpdateData( FALSE );
}
void WindStationDockBarChildDlg::updateLastSelect()
{
    int row = LB_ERR;
    for( int i = 0; i < m_list.GetItemCount(); i++ )
    {
        if( LVIS_SELECTED == m_list.GetItemState( i, LVIS_SELECTED ) )
        {
            row = i;
            break;
        }
    }

    if( row != LB_ERR )
    {
        //UpdateData(TRUE);

        // 锁定当前文档
        acDocManager->lockDocument( curDoc() );
        // 保存数据
        writePropertyData( m_objIds[row] );

        acDocManager->unlockDocument( curDoc() );
    }
}
Example #26
0
void
curvetextContextMenu::onCommand(Adesk::UInt32 cmdIndex)
{

	switch(cmdIndex)
	{
	case ID_CURVETEXT_REVERSE:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.reverse ");
		break;

	case ID_CURVETEXT_CURVE_SHOW:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.showCurve ");
		break;

	case ID_CURVETEXT_CURVE_HIDE:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.hideCurve ");
		break;

	case ID_CURVETEXT_TEXT_SHOW:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.ShowText ");
		break;

	case ID_CURVETEXT_TEXT_HIDE:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.HideText ");
		break;

	case ID_CURVETEXT_FITTEXT_YES:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.fit ");
		break;

	case ID_CURVETEXT_FITTEXT_NO:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.noFit ");
		break;

	case ID_CURVETEXT_REPEATTEXT_YES:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.repeatText ");
		break;

	case ID_CURVETEXT_REPEATTEXT_NO:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.noTextRepetition ");
		break;

	case ID_CURVETEXT_SETTEXTSTARTPOINT:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.ssp ");
		break;

	case ID_CURVETEXT_SETTEXTENDPOINT:
		acDocManager->sendStringToExecute(curDoc(), "ASDK_CURVETEXT.sep ");
		break;
	}
}
Example #27
0
void CMyDlg::OnCreateLine() 
{	
	// TODO: Add your control notification handler code here
	acDocManager->lockDocument(curDoc());

	int i;
	int m, n;

	char *buf = (char*)malloc(20);
	
	AcDbObjectId LineId;
	AcDbLine *pLine = NULL;
	//块表
	AcDbBlockTable *pTb = NULL;
	//块表记录
	AcDbBlockTableRecord *pTbr = NULL;
	//层表
	AcDbLayerTable *pLyr = NULL;
	//层表记录
	AcDbLayerTableRecord* pLyrr = NULL;
	//图形数据库
	AcDbDatabase *pDb = acdbHostApplicationServices()->workingDatabase();
	
	Acad::ErrorStatus es;
	
	CListCtrl *pListCtr = (CListCtrl *)GetDlgItem( IDC_LIST1 );
	
	//设置随机数种子
	srand(time(NULL));
	
	//更新数据
	UpdateData(TRUE);

	m_VecSize += m_Edit5;
	m_xVec.resize(m_VecSize);
	m_yVec.resize(m_VecSize);

	//acutPrintf("%d\n", m_Edit1);
	
	es = pDb->getLayerTable(pLyr, AcDb::kForWrite);	//以写的方式打开层表
	es = pDb->getBlockTable(pTb, AcDb::kForRead);	//以读的方式打开块表
	es = pTb->getAt(ACDB_MODEL_SPACE, pTbr, AcDb::kForWrite);//以写的方式打开块表记录
	
	//创建图层GalLineTest
	if (!pLyr->has("GalLineTest"))
	{
		pLyrr = new AcDbLayerTableRecord;	//创建层记录
		pLyrr->setName("GalLineTest");		//设置名字
		//pLyrr->setColor(color);			//设置颜色
		//pLyrr->setLineWeight(lnWt);		//设置线宽
		
		if (Acad::eOk != pLyr->add(pLyrr))	//添加该层记录到层表
		{
			//添加失败
			delete pLyrr;		//释放内存
			pLyr->close();		//关闭层表
		}
		//关闭层表记录
		pLyrr->close();
	}
	//关闭层表
	pLyr->close();
	
	//生成点坐标
	for (i = 0; i < m_Edit5; ++i)
	{
		if ((m_Edit2 != 0) && (m_Edit4 != 0))
		{
			m_xVec[i] = rand() % m_Edit2 + m_Edit1;
			m_yVec[i] = rand() % m_Edit4 + m_Edit3;
		}
		else
		{
			m_xVec[i] = 0;
			m_yVec[i] = 0;
		}
	}
	
	//遍历点坐标
	for (m = 0; m < m_Edit5; ++m)
	{
		for (n = (m+1); n < m_Edit5; ++n)
		{
			if ((m_xVec[m] != m_xVec[n]) && (m_yVec[m] != m_yVec[n]))
			{
				AcGePoint3d ptStart(m_xVec[m], m_yVec[m], 0);
				AcGePoint3d ptEnd(m_xVec[n], m_yVec[n], 0);
				pLine = new AcDbLine(ptStart, ptEnd);
				//pLine->setColor();
				pLine->setLayer("GalLineTest");
				//创建线段
				es = pTbr->appendAcDbEntity(LineId, pLine);
				if (Acad::eOk == es)
				{
					++m_lLineCnt;
				}
				//acutPrintf("%d\n", LineId);
				sprintf(buf, "%d", LineId);			
				m_ListCtr.InsertItem(m_Row, buf);
				
				buf = itoa(pLine->colorIndex(), buf, 10);
				m_ListCtr.SetItemText(m_Row, 1, buf);
				
				buf = itoa(LineLength(m_xVec[m], m_yVec[m],
									m_xVec[n], m_yVec[n]), buf, 10);
				m_ListCtr.SetItemText(m_Row, 2, buf);
				
				++m_Row;
				pLine->close();	//关闭实体
			}
		}
	}
	pTbr->close();	//关闭块表记录
	pTb->close();	//关闭块表

	acDocManager->unlockDocument(curDoc());
	free(buf);
}
Example #28
0
void CMyDlg::OnSeekPath()
{
	// TODO: Add your control notification handler code here

	acDocManager->lockDocument(curDoc());

	ads_point fromPnt, toPnt;
	CSearchGraph sGraph;

	ShowWindow(SW_HIDE);

	sGraph.Init();

	bool flag1 = false;
	bool flag2 = false;

	if (m_lLineCnt > 0)
	{
		do 
		{
			if (RTNORM == acedGetPoint(NULL, _T("选择一个点\n"), fromPnt))
			{		
				//选择的点必须是线段的起点或终点、或两线段的交点
				for (vector<stPoint>::iterator it = sGraph.m_Points.begin();
				it != sGraph.m_Points.end(); ++it)
				{
					if ((fromPnt[X] == (*it).pnt[X]) &&
						(fromPnt[Y] == (*it).pnt[Y]))
					{
						flag1 = true;
						break;
					}
				}
			}
			if (!flag1)
			{
				acutPrintf("选择的点必须是线段的起点或终点、或两线段的交点\n");
			}
		} while (!flag1);

		do 
		{
			if (RTNORM == acedGetPoint(fromPnt, _T("选择第二个点\n"), toPnt))
			{
				for (vector<stPoint>::iterator it = sGraph.m_Points.begin();
				it != sGraph.m_Points.end(); ++it)
				{
					if ((toPnt[X] == (*it).pnt[X]) &&
						(toPnt[Y] == (*it).pnt[Y]))
					{
						flag2 = true;
						break;
					}
				}
			}
			if (!flag1)
			{
				acutPrintf("选择的点必须是线段的起点或终点、或两线段的交点\n");		
			}
		} while (!flag2);
	}

//	SearchPath();

	acDocManager->unlockDocument(curDoc());

}
Example #29
0
// Entry point message handler function
void OnkLoadDwgMsg()
{
	// TODO: Implement this message handler

	new AsdkDbEmployeeReactor (true, curDoc ()) ;
}
Example #30
0
ArxDocLockSwitch::~ArxDocLockSwitch()
{
	acDocManager->unlockDocument( curDoc() );
}