// Gets the drawing container
CATISpecObject_var spDrawingSpec = piDrawing;
CATIContainer_var spDrawingCont = spDrawingSpec->GetFeatContainer();
// The drawing factory is implemented ont the drawing container
CATIDrwFactory_var spDrwFact = spDrawingCont;
CATISheet_var spSheet=piDrawing->GetCurrentSheet();
CATISheet *piNewSheet = spSheet;
// We do create a view with Make Up
CATIDftViewMakeUp *piNewViewMU = NULL;
spDrwFact->CreateViewWithMakeUp(IID_CATIDftViewMakeUp, (void **)[$piNewViewMU)]
// Get the view from the MakeUp
CATIView *piNewView = NULL;
piNewViewMU->GetView([$piNewView)]
// The view has to be typed: FrontView for Interactive view.
piNewView->SetViewType(FrontView);
piNewViewMU->SetPosition(100.0,50.0);
// Let's add the view to the sheet
piNewSheet->AddView(piNewViewMU);
piNewSheet->SetCurrentView(piNewView);
CATI2DWFFactory_var spGeomFactory(piNewView);
// Creation of a circle:
double center[2];
center[0]=100.0;
center[1]=150.0;
double radius = 50.0;
CATISpecObject_var Cercle = spGeomFactory->CreateCircle(center,radius);
CATIDrwAnnotationFactory_var spDrwAnnoFact=piNewView;
if(NULL_var!=spDrwAnnoFact)
{
AfxMessageBox(L"NULL_var!=spDrwAnnoFact ");
CATUnicodeString textString("oint");
int titleLength = textString.GetLengthInChar();
CATIDescendants_var spDesc = piNewView;
CATListValCATISpecObject_var List;
spDesc->GetDirectChildren ("CATI2DCircle",List);
double center[2];
double rad;
CATI2DCircle_var my2DCir(List[1]);
my2DCir->GetCircleData(center,[$rad)]
CATIDrwText_var spText = spDrwAnnoFact->CreateDrwText(center[0],center[1],textString);
// Modify the properties
CATIDrwTextProperties_var spTextProp = spText;
// Modification of under part of the properties of the text
spText->SetParameterOnSubString(CATDrwUnderline, 1, titleLength, 1);
// Modification of the properties of the text as a whole
spTextProp->SetFontSize(12.5);
spTextProp->SetBold(TRUE);
spTextProp->SetFontColor(123,0,255,100);
// Refresh the text visualization
spTextProp->Refresh();
}
CATILinkableObject_var spLink=pDocument;
//pDocument为三维的CATPart的指针,非空。
if(NULL_var!=spLink)
{
AfxMessageBox(L"NULL_var!=spLink");
}
piNewView->SetDoc(spLink);
// spDrwFact->CreateProjectionCallout();
//spPlane为Part文件中的一个已知平面。
CATPlane_var spPla=spPlane;
CATMathPlane mathPlane;
if(NULL_var!=spPla)
{
AfxMessageBox(L"NULL_var!=spPla");
spPla->GetAxis(mathPlane);
}
CATIGenerSpec_var spGener=piNewView->GetGenerSpec();
if(NULL_var!=spGener)
{
AfxMessageBox(L"NULL_var!=spGener");
spGener->SetProjPlane(mathPlane);
}
//Have to use this way to get the right CATILinkableObject
CATFrmEditor *pCurrFrmEditor = GetEditor();
CATPathElement oUIActPathElem = pCurrFrmEditor->GetUIActiveObject();
CATBaseUnknown* pCurrElemBase = oUIActPathElem.CurrentElement();
CATILinkableObject_var spLink(pCurrElemBase);
//
CATIEditor *poEditor=NULL;
CATSession *piSession=CATSession::GetPtrSession();
CATIIniInteractiveSession *piInteractiveSession=NULL;
HRESULT hr=piSession->QueryInterface(IID_CATIIniInteractiveSession,(void **)[$piInteractiveSession)]
hr=piInteractiveSession->New("Drawing", [$poEditor)]
CATFrmEditor* _editor2=poEditor->GetEditor();
CATDocument* pDoc =_editor2->GetDocument();
CATIDrawing *piDrawing = NULL;
CATIDftDocumentServices *piDftDocServices = NULL;
if (SUCCEEDED(pDoc->QueryInterface(IID_CATIDftDocumentServices, (void **)&piDftDocServices)))
{
piDftDocServices->GetDrawing(IID_CATIDrawing, (void **)[$piDrawing)]
piDftDocServices->Release();
}
// Gets the drawing container
CATISpecObject_var spDrawingSpec = piDrawing;
CATIContainer_var spDrawingCont = spDrawingSpec->GetFeatContainer();
// The drawing factory is implemented ont the drawing container
CATIDrwFactory_var spDrwFact = spDrawingCont;
// We do create a view with Make Up
CATIDftViewMakeUp *piNewViewMU = NULL;
spDrwFact->CreateViewWithMakeUp(IID_CATIDftViewMakeUp, (void **)[$piNewViewMU)]
// Get the view from the MakeUp
CATIView *piNewView = NULL;
piNewViewMU->GetView([$piNewView)]
// The view has to be typed: FrontView for Interactive view.
// CATILinkableObject_var spLink=pDocument;
//pDocument?三?的CATPart的指?,非空。
if(NULL_var==spLink)
{
cout << "spLink is NULL!" << endl;
}
piNewView->SetDoc(spLink);
// Let's add the view to the sheet
piNewSheet->AddView(piNewViewMU);
piNewSheet->SetCurrentView(piNewView);
CATI2DWFFactory_var spGeomFactory(piNewView);
// Creation of a circle:
double center[2];
center[0]=100.0;
center[1]=150.0;
double radius = 50.0;
CATISpecObject_var Cercle = spGeomFactory->CreateCircle(center,radius);
CATIDrwAnnotationFactory_var spDrwAnnoFact=piNewView;
if(NULL_var!=spDrwAnnoFact)
{
//AfxMessageBox(L"NULL_var!=spDrwAnnoFact ");
CATUnicodeString textString("oint");
int titleLength = textString.GetLengthInChar();
CATIDescendants_var spDesc = piNewView;
CATListValCATISpecObject_var List;
spDesc->GetDirectChildren ("CATI2DCircle",List);
double center[2];
double rad;
CATI2DCircle_var my2DCir(List[1]);
my2DCir->GetCircleData(center,[$rad)]
CATIDrwText_var spText = spDrwAnnoFact->CreateDrwText(center[0],center[1],textString);
// Modify the properties
CATIDrwTextProperties_var spTextProp = spText;
// Modification of under part of the properties of the text
spText->SetParameterOnSubString(CATDrwUnderline, 1, titleLength, 1);
// Modification of the properties of the text as a whole
spTextProp->SetFontSize(12.5);
spTextProp->SetBold(TRUE);
spTextProp->SetFontColor(123,0,255,100);
// Refresh the text visualization
spTextProp->Refresh();
}