- obj->FindAttribute(anAttr, "AttributePersistentRef");
-
- while(useSubItems?anIter->More():!anAttr->_is_nil()) {
- if(!obj->FindAttribute(anAttr, "AttributeIOR") &&
- obj->FindAttribute(anAttr, "AttributePersistentRef")) {
- _PTR(SComponent) FComp ( obj->GetFatherComponent() );
- if (FComp) {
- if (FComp->FindAttribute(anAttr, "AttributeName")) {
- _PTR(AttributeName) aName ( anAttr );
- QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str());
- // parent->loadComponentData(parent->getComponentName(aName->Value()));
- Engines::Component_var comp ;
- if ( compName.compare("SUPERV") == 0 ) {
- comp = QAD_Application::getDesktop()->getEngine( "SuperVisionContainer", compName) ;
- }
- else {
- comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", compName);
- if ( comp->_is_nil() )
- comp = QAD_Application::getDesktop()->getEngine( "FactoryServerPy", compName);
- }
-
- if (!CORBA::is_nil(comp)) {
- SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
- if (!CORBA::is_nil(driver)) {
- SALOMEDS::StudyBuilder_var B = dynamic_cast<SALOMEDS_Study*>(aStudy.get())->GetStudy()->NewBuilder();
- if (!CORBA::is_nil(B)) {
- B->LoadWith(FComp,driver);
- } else {
- return;
- }
- }
- else {
- MESSAGE("loadComponentData(): Driver is null");
- return;
- }
- }
- else {
- MESSAGE("loadComponentData(): Engine is null");
- return;
- }
- // // load
- // Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM");
- // if (!CORBA::is_nil(comp)) {
- // SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp);
- // SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- // SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM");
- // if (!CORBA::is_nil(SC))
- // aStudyBuilder->LoadWith(SC,driver);
- }
- }
- else {
- MESSAGE("Component is null");
+ }
+ GeometryGUI::Modified();
+ }
+ else if (isVTK) { // if is VTKViewer
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
+ (SUIT_Session::session()->activeApplication());
+ if (!app)
+ return;
+
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ if (!aSelMgr)
+ return;
+
+ SALOME_ListIO selected;
+ aSelMgr->selectedObjects(selected);
+ if (selected.IsEmpty())
+ return;
+
+ SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>(window);
+ if (!vtkVW)
+ return;
+
+ SALOME_View* view = GEOM_Displayer::GetActiveView();
+
+ vtkActorCollection* aCollection = vtkActorCollection::New();
+
+ for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) {
+ Handle(SALOME_InteractiveObject) anIObject = It.Value();
+ SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry());
+ SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>(aPrs);
+ if (vtkPrs) {
+ vtkActorCollection* anActors = vtkPrs->GetObjects();
+ anActors->InitTraversal();
+ vtkActor* anAct = anActors->GetNextActor();
+ aCollection->AddItem(anAct);
+ }
+ }
+
+ if (aCollection)
+ aCollection->InitTraversal();
+ else
+ return;
+
+ double aDC = 0.;
+
+ vtkActor* anAct = aCollection->GetNextActor();
+ if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct))
+ aDC = anActor->GetDeflection();
+ else
+ return;
+
+ GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
+ (SUIT_Session::session()->activeApplication()->desktop());
+ DeflectionDlg->setTheDC(aDC);
+ if (DeflectionDlg->exec()) {
+ SUIT_OverrideCursor();
+ aDC = DeflectionDlg->getTheDC();
+ while (anAct != NULL) {
+ if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
+ // There are no casting to needed actor.
+ anActor->SetDeflection(aDC);
+ appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
+ }
+ anAct = aCollection->GetNextActor();
+ }
+ }
+ GeometryGUI::Modified();
+ } // end vtkviewer
+}
+
+void GEOMToolsGUI::OnSelectOnly(int mode)
+{
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if ( app ) {
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ GEOM_Displayer aDisp (appStudy);
+ aDisp.GlobalSelection(mode);
+ getGeometryGUI()->setLocalSelectionMode(mode);
+ }
+}
+
+void GEOMToolsGUI::OnShowHideChildren( bool show )
+{
+ SALOME_ListIO selected;
+ SalomeApp_Application* app =
+ dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+
+ SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
+
+ GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
+
+ if ( app && disp ) {
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( aSelMgr && appStudy ) {
+ aSelMgr->selectedObjects( selected );
+ if ( !selected.IsEmpty() ) {
+ _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(StudyBuilder) B = aStudy->NewBuilder();
+
+ bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
+ if ( aLocked ) {
+ SUIT_MessageBox::warning( app->desktop(),
+ QObject::tr( "WRN_WARNING" ),
+ QObject::tr( "WRN_STUDY_LOCKED" ) );
+ return;
+ }
+
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+
+ _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
+ _PTR(GenericAttribute) anAttr;
+ if ( obj ) {
+ _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" );
+ aExp->SetExpandable( show );
+ if(!show)
+ disp->EraseWithChildren(IObject,true);
+ } // if ( obj )
+ } // iterator
+ }
+ }
+ app->updateObjectBrowser( false );
+ app->updateActions();
+ }
+}
+
+void GEOMToolsGUI::OnPointMarker()
+{
+ GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
+ dlg.exec();
+}
+
+void GEOMToolsGUI::OnMaterialProperties()
+{
+ GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
+ dlg.exec();
+}
+
+void GEOMToolsGUI::OnUnpublishObject() {
+ SALOME_ListIO selected;
+ SalomeApp_Application* app =
+ dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+
+ SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
+
+ GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
+
+ if ( app && disp ) {
+ LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( aSelMgr && appStudy ) {
+ aSelMgr->selectedObjects( selected );
+ if ( !selected.IsEmpty() ) {
+ _PTR(Study) aStudy = appStudy->studyDS();
+ _PTR(StudyBuilder) B = aStudy->NewBuilder();
+
+ bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
+ if ( aLocked ) {
+ SUIT_MessageBox::warning( app->desktop(),
+ QObject::tr( "WRN_WARNING" ),
+ QObject::tr( "WRN_STUDY_LOCKED" ) );
+ return;
+ }
+
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
+
+ _PTR(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) );
+ _PTR(GenericAttribute) anAttr;
+ if ( obj ) {
+ _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" );
+ aDrw->SetDrawable( false );
+ disp->EraseWithChildren(IObject);
+ } // if ( obj )
+ } // iterator
+ aSelMgr->clearSelected();
+ }
+ }
+ app->updateObjectBrowser( false );
+ app->updateActions();
+ }
+
+}
+
+void GEOMToolsGUI::OnPublishObject() {
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if(!app)
+ return;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if(!appStudy)
+ return;
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ if(!aStudy)
+ return;
+
+ //Check lock of the study
+ bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked();
+ if ( aLocked ) {
+ SUIT_MessageBox::warning( app->desktop(),
+ QObject::tr( "WRN_WARNING" ),
+ QObject::tr( "WRN_STUDY_LOCKED" ) );
+ return;
+ }
+
+ GEOMToolsGUI_PublishDlg * publishDlg =
+ new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );
+ publishDlg->exec();
+}
+
+
+void GEOMToolsGUI::OnEdgeWidth()
+{
+ SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+
+
+ bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
+ bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
+ int mgrId = window->getViewManager()->getGlobalId();
+
+ if (isOCC) { // if is OCCViewer
+ OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
+ Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+ ic->InitCurrent();
+ if (ic->MoreCurrent()) {
+ Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+
+ int aWidth = (int)CurObject->Width();
+
+ GEOMToolsGUI_LineWidthDlg * Dlg = new GEOMToolsGUI_LineWidthDlg
+ (SUIT_Session::session()->activeApplication()->desktop(),"EDGE_WIDTH_TLT");
+ Dlg->setTheLW(aWidth);
+ int aNewWidth = 0;
+ if (Dlg->exec()) {
+ aNewWidth = Dlg->getTheLW();
+ bool ok = (aNewWidth != aWidth && aNewWidth != 0 );
+ if (ok) {
+ for(; ic->MoreCurrent(); ic->NextCurrent()) {
+ CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+ CurObject->SetWidth(aNewWidth);
+ ic->Redisplay(CurObject);
+ appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth);