- // MESSAGE("createAndDisplayGO");
- QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
- SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
-
- Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
- GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp);
-
- CORBA::String_var aFatherIOR;
- SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
- aStudyBuilder->DefineComponentInstance( father, Geom );
- father->ComponentIOR(aFatherIOR);
-
- SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(ActiveStudy->getActiveStudyFrame()->entry());
-
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(Entry);
- SALOMEDS::GenericAttribute_var anAttr;
- SALOMEDS::AttributeIOR_var anIOR;
- // Create new actor
- if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
- return;
- anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
- CORBA::String_var anIORValue = anIOR->Value();
-
- GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue);
- TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
-
- if ( !obj->_is_nil() ) {
- if (obj->FindAttribute(anAttr, "AttributeName")) {
- SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
- CORBA::String_var aNameValue = aName->Value();
- // open transaction
- QAD_Operation* op = new SALOMEGUI_ImportOperation( ActiveStudy );
- op->start();
-
- SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
- aStudyBuilder->Addreference(newObj1, obj);
- // commit transaction
- op->finish();
-
- Handle(GEOM_InteractiveObject) anIO = new GEOM_InteractiveObject(const_cast<char*>(anIORValue.in()),
- const_cast<char*>(aFatherIOR.in()),
- "GEOM",
- const_cast<char*>(obj->GetID()));
-
- class TEvent: public SALOME_Event{
- QAD_Study* myStudy;
- TopoDS_Shape myShape;
- Handle(SALOME_InteractiveObject) myIO;
- const char* myName;
- public:
- TEvent(QAD_Study* theStudy, TopoDS_Shape theShape,
- const Handle(SALOME_InteractiveObject)& theIO,
- const char* theName):
- myStudy(theStudy), myShape(theShape),
- myIO(theIO), myName(theName)
- {}
- virtual void Execute(){
- if(VTKViewer_ViewFrame* aViewFrame = GetFrame<VTKViewer_ViewFrame>(myStudy)){
- VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor();
- int aMode = myRenderInter->GetDisplayMode();
-
- vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(myShape,0,aMode,true);
+ class TEvent: public SALOME_Event
+ {
+ std::string myEntry;
+ bool myUpdateViewer;
+ public:
+ TEvent(const char* theEntry, bool toUpdateViewer):
+ myEntry(theEntry),
+ myUpdateViewer(toUpdateViewer)
+ {}
+ virtual void Execute()
+ {
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if (!app) return;
+
+ SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+ if (!ActiveStudy) return;
+
+ _PTR(Study) aStudy(ActiveStudy->studyDS());
+ _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
+
+ GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
+ if (CORBA::is_nil(Geom)) {
+ GeometryGUI::InitGeomGen();
+ Geom = GeometryGUI::GetGeomGen();
+ }
+ if (CORBA::is_nil(Geom))
+ return;
+
+ string aFatherIOR;
+ _PTR(SComponent) father = aStudy->FindComponent("GEOM");
+ if (!father)
+ return;
+ if (!father->ComponentIOR(aFatherIOR)) {
+ CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(Geom);
+ aStudyBuilder->LoadWith(father, objStr.in());
+ father->ComponentIOR(aFatherIOR);
+ }
+
+ _PTR(SObject) obj = aStudy->FindObjectID(myEntry);
+ if (!obj)
+ return;
+
+ // Create new actor
+ _PTR(GenericAttribute) anAttr;
+ if (!obj->FindAttribute(anAttr, "AttributeIOR"))
+ return;
+ _PTR(AttributeIOR) anIOR(anAttr);
+ string anIORValue = anIOR->Value();
+
+ GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue.c_str());
+ TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
+ if (!Shape.IsNull()) {
+ if (obj->FindAttribute(anAttr, "AttributeName")) {
+ _PTR(AttributeName) aName (anAttr);
+ string aNameValue = aName->Value();
+ // open transaction
+ /*SUIT_Operation* op = new SalomeApp_ImportOperation (app);
+ op->start();
+
+ _PTR(SObject) newObj1 = aStudyBuilder->NewObject(father);
+ aStudyBuilder->Addreference(newObj1, obj);
+ // commit transaction
+ op->commit();*/
+ Handle(GEOM_InteractiveObject) anIO =
+ new GEOM_InteractiveObject (const_cast<char*>(anIORValue.c_str()),
+ const_cast<char*>(aFatherIOR.c_str()),
+ "GEOM",
+ const_cast<char*>( obj->GetID().c_str()));
+
+ GEOM_Displayer(ActiveStudy).Display(anIO, myUpdateViewer);
+ /*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
+ SVTK_View* aView = aViewWindow->getView();
+ int aMode = aView->GetDisplayMode();
+
+ vtkActorCollection* theActors =
+ GEOM_AssemblyBuilder::BuildActors(Shape,0,aMode,true);