1 // GEOM GEOMGUI : GUI for Geometry component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : EntityGUI.cxx
25 // Author : Damien COQUERET
29 #include "EntityGUI.h"
31 #include "QAD_RightFrame.h"
32 #include "OCCViewer_Viewer3d.h"
33 #include "VTKViewer_ViewFrame.h"
34 #include "GEOM_AssemblyBuilder.h"
35 #include "SALOMEGUI_ImportOperation.h"
36 #include "SALOMEGUI_QtCatchCorbaException.hxx"
38 #include <TopoDS_Compound.hxx>
39 #include <BRep_Builder.hxx>
40 #include <TopExp_Explorer.hxx>
42 #include "DisplayGUI.h"
44 #include "EntityGUI_SketcherDlg.h" // Sketcher
45 #include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE
47 #include "utilities.h"
51 //=======================================================================
52 // function : EntityGUI()
53 // purpose : Constructor
54 //=======================================================================
55 EntityGUI::EntityGUI() :
58 myGeomBase = new GEOMBase();
59 myGeomGUI = GEOMContext::GetGeomGUI();
60 myGeom = myGeomGUI->myComponentGeom;
62 mySimulationShape1 = new AIS_Shape(TopoDS_Shape());
63 mySimulationShape2 = new AIS_Shape(TopoDS_Shape());
67 //=======================================================================
68 // function : ~EntityGUI()
69 // purpose : Destructor
70 //=======================================================================
71 EntityGUI::~EntityGUI()
76 //=======================================================================
77 // function : OnGUIEvent()
79 //=======================================================================
80 bool EntityGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
82 EntityGUI* myEntityGUI = new EntityGUI();
83 myEntityGUI->myGeomGUI->EmitSignalDeactivateDialog();
84 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
90 ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTop(); // DCQ : 28/02/2002
91 EntityGUI_SketcherDlg* aDlg = new EntityGUI_SketcherDlg(parent, "", myEntityGUI, Sel);
94 case 407: // EXPLODE : use ic
96 Handle(AIS_InteractiveContext) ic;
97 if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
98 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
99 ic = v3d->getAISContext();
101 EntityGUI_SubShapeDlg *aDlg = new EntityGUI_SubShapeDlg(parent, "", myEntityGUI, Sel, ic);
106 parent->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
114 //=======================================================================
115 // function : OnSketchEnd()
117 //=======================================================================
118 void EntityGUI::OnSketchEnd(const char *Cmd)
121 GEOM::GEOM_Shape_var result = myGeom->MakeSketcher(Cmd);
122 if(result->_is_nil()) {
123 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
126 result->NameType(tr("GEOM_WIRE"));
127 if(myGeomBase->Display(result))
128 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
130 catch(const SALOME::SALOME_Exception& S_ex) {
131 QtCatchCorbaException(S_ex);
137 //=====================================================================================
138 // function : DisplaySimulationShape()
139 // purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
140 //=====================================================================================
141 void EntityGUI::DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shape& S2)
143 //NRI DEBUG : 14/02/2002
144 if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
147 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
148 Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
151 /* erase any previous */
152 ic->Erase(mySimulationShape1, Standard_True, Standard_False);
153 ic->ClearPrs(mySimulationShape1);
155 mySimulationShape1 = new AIS_Shape(TopoDS_Shape());
156 mySimulationShape1->Set(S1);
157 mySimulationShape1->SetColor(Quantity_NOC_RED);
159 ic->Deactivate(mySimulationShape1);
160 ic->Display(mySimulationShape1, Standard_False);
161 mySimulationShape1->UnsetColor();
164 ic->Erase(mySimulationShape2, Standard_True, Standard_False);
165 ic->ClearPrs(mySimulationShape2);
167 mySimulationShape2 = new AIS_Shape(TopoDS_Shape());
168 mySimulationShape2->Set(S2);
169 mySimulationShape2->SetColor(Quantity_NOC_VIOLET);
171 ic->Deactivate(mySimulationShape2);
172 ic->Display(mySimulationShape2, Standard_False);
173 mySimulationShape2->UnsetColor();
175 ic->UpdateCurrentViewer();
177 catch(Standard_Failure) {
178 MESSAGE("Exception catched in EntityGUI::DisplaySimulationShape ");
184 //==================================================================================
185 // function : EraseSimulationShape()
186 // purpose : Clears the display of 'mySimulationShape' a pure graphical shape
187 //==================================================================================
188 void EntityGUI::EraseSimulationShape(int Sh)
190 int count = QAD_Application::getDesktop()->getActiveStudy()->getStudyFramesCount();
191 for(int i = 0; i < count; i++) {
192 if(QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getTypeView() == VIEW_OCC) {
193 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getStudyFrame(i)->getRightFrame()->getViewFrame())->getViewer();
194 Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
196 ic->Erase(mySimulationShape1, Standard_True, Standard_False);
197 ic->ClearPrs(mySimulationShape1);
200 ic->Erase(mySimulationShape2, Standard_True, Standard_False);
201 ic->ClearPrs(mySimulationShape2);
203 ic->UpdateCurrentViewer();
209 //=====================================================================================
210 // function : SObjectExist()
212 //=====================================================================================
213 bool EntityGUI::SObjectExist(SALOMEDS::SObject_ptr theFatherObject, const char* IOR)
215 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
216 SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(theFatherObject);
217 SALOMEDS::SObject_var RefSO;
218 SALOMEDS::GenericAttribute_var anAttr;
219 SALOMEDS::AttributeIOR_var anIOR;
220 for(; it->More();it->Next()) {
221 SALOMEDS::SObject_var SO= it->Value();
222 if(SO->FindAttribute(anAttr, "AttributeIOR")) {
223 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
224 if(strcmp( anIOR->Value(), IOR ) == 0)
227 if(SO->ReferencedObject(RefSO)) {
228 if(RefSO->FindAttribute(anAttr, "AttributeIOR")) {
229 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
230 if(strcmp(anIOR->Value(), IOR) == 0)
239 //=====================================================================================
240 // function : OnSubShapeGetAll()
241 // purpose : Explode a shape in all sub shapes with a SubShapeType
242 //=====================================================================================
243 bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType)
245 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
246 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR);
247 if(theObj->_is_nil()) {
248 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
252 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
253 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
254 SALOMEDS::GenericAttribute_var anAttr;
255 SALOMEDS::AttributeName_var aName;
256 SALOMEDS::AttributeIOR_var anIOR;
257 SALOMEDS::AttributePixMap_var aPixmap;
259 /* We create a sub object for each sub shape as attribute of the main object */
260 /* Each sub object contains list (length=1) containing its index in the main shape */
261 GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR);
262 GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
263 GEOM::GEOM_Shape_var aResult;
266 listGeomShapes = myGeom->SubShapeAll(aShape, SubShapeType);
267 if(listGeomShapes->length() < 1) {
268 QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_ABORT"));
272 catch(const SALOME::SALOME_Exception& S_ex) {
273 QtCatchCorbaException(S_ex);
276 /* open transaction */
277 QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy());
280 TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
281 TopoDS_Shape mainShape;
284 if(aShape->IsMainShape()) {
285 mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
289 aShape = myGeom->GetIORFromString(aShape->MainName());
292 /* Loop on each sub shape created */
293 /* int i = 1 ; /* index for the nameType */
294 for(int j=0; j<listGeomShapes->length(); j++) {
295 /* Get each sub shape extracted CORBA and OCC */
296 aResult = listGeomShapes[j] ;
297 TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult);
300 QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_ABORT"));
304 /* Set the nameType of sub shape */
305 char* nameG = (char *)malloc(20);
306 Standard_CString Type;
307 if(myGeomBase->GetShapeTypeString(S, Type)) {
308 aResult->NameType(Type);
309 sprintf(nameG, "%s_%d", Type, myGeomBase->GetIndex(S, mainShape, SubShapeType));
312 aResult->NameType(tr("GEOM_SHAPE"));
313 sprintf(nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++);
315 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name());
317 bool allreadyexist = false;
319 if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
320 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
321 Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
323 Handle(GEOM_AISShape) result = new GEOM_AISShape(S, nameG);
324 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
326 MESSAGE ("SO->_is_nil() " << SO->_is_nil())
329 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj);
330 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
331 aName = SALOMEDS::AttributeName::_narrow(anAttr);
332 aName->SetValue(nameG);
333 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
334 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
335 anIOR->SetValue(aResult->Name());
337 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
338 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
339 MESSAGE(" Type " << S.ShapeType())
340 if (S.ShapeType() == TopAbs_COMPOUND)
341 aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND");
342 else if(S.ShapeType() == TopAbs_COMPSOLID)
343 aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID");
344 else if(S.ShapeType() == TopAbs_SOLID)
345 aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID");
346 else if(S.ShapeType() == TopAbs_SHELL)
347 aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL");
348 else if(S.ShapeType() == TopAbs_FACE)
349 aPixmap->SetPixMap("ICON_OBJBROWSER_FACE");
350 else if(S.ShapeType() == TopAbs_WIRE)
351 aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE");
352 else if(S.ShapeType() == TopAbs_EDGE)
353 aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE");
354 else if(S.ShapeType() == TopAbs_VERTEX)
355 aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX");
357 MESSAGE(" aPixmap->GetPixMap " << aPixmap->GetPixMap())
359 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
360 aStudyBuilder->Addreference(newObj1, newObj);
361 IO->setEntry(newObj->GetID());
363 aResult->StudyShapeId(newObj->GetID());
366 allreadyexist = true;
367 if(!this->SObjectExist(theObj, aResult->Name())) {
368 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
369 aStudyBuilder->Addreference(newObj1, SO);
370 IO->setEntry(SO->GetID());
371 aResult->StudyShapeId(SO->GetID());
376 result->setName(nameG);
381 else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
382 VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
384 int themode = myRenderInter->GetDisplayMode();
385 vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
386 vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
388 Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
391 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj);
392 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
393 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
394 anIOR->SetValue(aResult->Name());
395 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
396 aName = SALOMEDS::AttributeName::_narrow(anAttr);
397 aName->SetValue(nameG);
399 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
400 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
401 if(S.ShapeType() == TopAbs_COMPOUND)
402 aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND");
403 else if(S.ShapeType() == TopAbs_COMPSOLID)
404 aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID");
405 else if(S.ShapeType() == TopAbs_SOLID)
406 aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID");
407 else if(S.ShapeType() == TopAbs_SHELL)
408 aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL");
409 else if(S.ShapeType() == TopAbs_FACE)
410 aPixmap->SetPixMap("ICON_OBJBROWSER_FACE");
411 else if(S.ShapeType() == TopAbs_WIRE)
412 aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE");
413 else if(S.ShapeType() == TopAbs_EDGE)
414 aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE");
415 else if(S.ShapeType() == TopAbs_VERTEX)
416 aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX");
418 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
419 aStudyBuilder->Addreference(newObj1, newObj);
420 IO->setEntry(newObj->GetID());
423 allreadyexist = true;
424 if(!this->SObjectExist(theObj, aResult->Name())) {
425 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
426 aStudyBuilder->Addreference(newObj1, SO);
427 IO->setEntry(SO->GetID());
432 vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True);
433 theActors->InitTraversal();
434 vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
435 while(!(anActor==NULL)) {
436 GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
438 GActor->setName(nameG);
439 theRenderer->AddActor(GActor);
441 anActor = (vtkActor*)theActors->GetNextActor();
447 /* commit transaction */
450 QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser();
451 QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY"));
456 //=====================================================================================
457 // function : OnSubShapeGetSelected()
459 //=====================================================================================
460 bool EntityGUI::OnSubShapeGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType, Standard_Integer& aLocalContextId, bool& myUseLocalContext)
462 //* Test the type of viewer */
463 if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
466 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
467 SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR);
468 if(theObj->_is_nil()) {
469 QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
473 OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
474 Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
476 if( myUseLocalContext == false ) {
477 /* local context is from DialogBox */
478 MESSAGE("Error : No local context opened for sub shapes method" << endl ) ;
482 GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR );
483 TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
485 TopoDS_Shape mainShape;
488 if(aShape->IsMainShape()) {
489 mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
493 aShape = myGeom->GetIORFromString(aShape->MainName());
496 GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
498 int nbSelected = ic->NbSelected();
499 ListOfID->length(nbSelected);
501 TopoDS_Compound compound;
502 ic->InitSelected(); /* to init again */
504 B.MakeCompound(compound);
507 /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */
508 /* the compound is homogenous by selection */
509 while(ic->MoreSelected()) {
510 int index = myGeomBase->GetIndex(ic->SelectedShape(), mainShape, SubShapeType);
512 B.Add(compound, ic->SelectedShape());
517 /* Test if user has selected sub shapes */
518 if(ListOfID->length() < 1)
521 GEOM::GEOM_Shape_var aResult;
523 aResult = myGeom->SubShape(aShape, SubShapeType, ListOfID);
525 catch (const SALOME::SALOME_Exception& S_ex) {
526 QtCatchCorbaException(S_ex);
529 /* local context from DialogBox */
530 ic->CloseLocalContext(aLocalContextId);
531 myUseLocalContext = false ;
533 char* nameG = (char *)malloc(20);
534 Standard_CString Type;
536 Handle(GEOM_AISShape) result;
537 Handle(GEOM_InteractiveObject) IO;
539 if(nbSelected == 1) {
540 TopExp_Explorer Exp (compound, TopAbs_ShapeEnum(SubShapeType));
542 if(myGeomBase->GetShapeTypeString(Exp.Current(),Type)) {
543 aResult->NameType(Type);
544 sprintf (nameG, "%s_%d", Type, myGeomBase->GetIndex( Exp.Current(), mainTopo, SubShapeType));
547 aResult->NameType(tr("GEOM_SHAPE"));
548 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++);
550 result = new GEOM_AISShape(Exp.Current(), nameG);
551 IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
555 if ( myGeomBase->GetShapeTypeString(compound,Type)) {
556 aResult->NameType(Type);
557 sprintf (nameG, "%s_%d", Type, myGeomGUI->myNbGeom++);
559 aResult->NameType(tr("GEOM_SHAPE"));
560 sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++);
562 result = new GEOM_AISShape(compound, nameG);
563 IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
566 SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name());
568 /* open transaction */
569 QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy());
572 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
573 SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
574 SALOMEDS::GenericAttribute_var anAttr;
575 SALOMEDS::AttributeName_var aName;
576 SALOMEDS::AttributeIOR_var anIOR;
577 SALOMEDS::AttributePixMap_var aPixmap;
579 bool allreadyexist = false;
582 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj);
583 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
584 anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
585 anIOR->SetValue(aResult->Name());
586 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
587 aName = SALOMEDS::AttributeName::_narrow(anAttr);
588 aName->SetValue(result->getName());
590 anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
591 aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
592 if(result->Shape().ShapeType() == TopAbs_COMPOUND)
593 aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND");
594 else if(result->Shape().ShapeType() == TopAbs_COMPSOLID)
595 aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID");
596 else if(result->Shape().ShapeType() == TopAbs_SOLID)
597 aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID");
598 else if(result->Shape().ShapeType() == TopAbs_SHELL)
599 aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL");
600 else if(result->Shape().ShapeType() == TopAbs_FACE)
601 aPixmap->SetPixMap("ICON_OBJBROWSER_FACE");
602 else if(result->Shape().ShapeType() == TopAbs_WIRE)
603 aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE");
604 else if(result->Shape().ShapeType() == TopAbs_EDGE)
605 aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE");
606 else if(result->Shape().ShapeType() == TopAbs_VERTEX)
607 aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX");
609 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
610 aStudyBuilder->Addreference(newObj1, newObj);
612 IO->setEntry(newObj->GetID());
613 aResult->StudyShapeId(newObj->GetID());
616 allreadyexist = true;
617 if(!this->SObjectExist(theObj, aResult->Name())) {
618 SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
619 aStudyBuilder->Addreference(newObj1, SO);
621 IO->setEntry(SO->GetID());
622 aResult->StudyShapeId(SO->GetID());
626 /* commit transaction */
630 result->setName(nameG);
635 DisplayGUI* myDisplayGUI = new DisplayGUI();
636 myDisplayGUI->OnDisplayAll(true);
638 QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser();
639 QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY"));
644 //=====================================================================================
646 //=====================================================================================
649 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
650 {return EntityGUI::OnGUIEvent(theCommandID, parent);}