1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2005 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 : VisuGUI_Tools.cxx
25 // Author : Sergey Anikin
29 #include "VisuGUI_Tools.h"
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Prs3d_i.hh"
33 #include "VISU_Result_i.hh"
34 #include "VISU_Table_i.hh"
35 #include "VISU_Mesh_i.hh"
36 #include "VISU_ViewManager_i.hh"
38 #include "VISU_Actor.h"
39 #include "VISU_ScalarMapAct.h"
41 #include "SalomeApp_Module.h"
42 #include "SalomeApp_Study.h"
43 #include "SalomeApp_Application.h"
45 #include "OB_Browser.h"
46 #include "LightApp_DataObject.h"
47 #include "LightApp_SelectionMgr.h"
49 #include "SALOME_ListIO.hxx"
50 #include "SALOME_ListIteratorOfListIO.hxx"
52 #include "SVTK_ViewWindow.h"
53 #include "SVTK_ViewModel.h"
54 #include "SVTK_Functor.h"
56 #include "VTKViewer_Algorithm.h"
58 #include "SPlot2d_ViewModel.h"
59 #include "Plot2d_ViewFrame.h"
61 #include "SUIT_Session.h"
62 #include "SUIT_MessageBox.h"
66 #include <vtkRenderer.h>
67 #include <vtkActorCollection.h>
70 //=============================================================================
74 GetDesktop(const CAM_Module* theModule)
76 return theModule->application()->desktop();
79 LightApp_SelectionMgr*
80 GetSelectionMgr(const SalomeApp_Module* theModule)
82 return theModule->getApp()->selectionMgr();
86 GetAppStudy(const CAM_Module* theModule)
89 dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
93 GetCStudy(const SalomeApp_Study* theStudy)
95 return theStudy->studyDS();
99 IsStudyLocked( _PTR(Study) theStudy )
102 return theStudy->GetProperties()->IsLocked();
107 CheckLock( _PTR(Study) theStudy,
110 if(IsStudyLocked(theStudy)){
111 SUIT_MessageBox::warn1(theWidget,
112 QObject::tr("WRN_VISU_WARNING"),
113 QObject::tr("WRN_STUDY_LOCKED"),
114 QObject::tr("BUT_OK"));
121 FindDataObject(SUIT_DataObject* theDataObject,
122 const QString& theEntry,
125 int aLevel = theDataObject->level() + 2;
126 QString aSourceEntry = theEntry.section(':',0,aLevel);
127 DataObjectList aList;
128 theDataObject->children(aList);
129 DataObjectListIterator aDataObjectIter(aList);
130 while(SUIT_DataObject* aDataObject = aDataObjectIter.current()){
131 if(LightApp_DataObject* aChildDataObject = dynamic_cast<LightApp_DataObject*>(aDataObject)){
132 QString anEntry = aChildDataObject->entry();
133 QString aCurrentEntry = anEntry.section(':',0,aLevel);
134 if(aSourceEntry == aCurrentEntry){
135 if(theLevel == aLevel){
136 return aChildDataObject;
138 return FindDataObject(aChildDataObject,theEntry,theLevel);
148 FindDataObject(CAM_Module* theModule,
149 _PTR(SObject) theSObject)
151 CAM_DataModel* aDataModel = theModule->dataModel();
152 CAM_DataObject* aRootDataObject = aDataModel->root();
153 if(_PTR(SComponent) aComponent = theSObject)
154 return dynamic_cast<LightApp_DataObject*>(aRootDataObject);
156 int aLevel = theSObject->Depth();
157 std::string anEntry = theSObject->GetID();
158 return FindDataObject(aRootDataObject,anEntry.c_str(),aLevel);
162 UpdateObjBrowser(SalomeApp_Module* theModule,
163 bool theIsUpdateDataModel,
164 _PTR(SObject) theSObject)
166 LightApp_DataObject* aDataObject = NULL;
168 aDataObject = FindDataObject(theModule,theSObject);
170 theModule->updateObjBrowser(theIsUpdateDataModel,aDataObject);
171 theModule->getApp()->updateActions();
175 IsSObjectTable( _PTR(SObject) theSObject )
178 _PTR(GenericAttribute) anAttr;
179 if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
181 if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
188 GetVisuGen(const CAM_Module* theModule)
190 static VISU_Gen_i* aGen = NULL;
192 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
193 Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
194 VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
195 if(!CORBA::is_nil(aVISU)){
196 aGen = VISU_Gen_i::GetVisuGenImpl();
197 aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
201 throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").latin1());
205 SALOME_MED::MED_Gen_var
208 static SALOME_MED::MED_Gen_var aGen;
209 if(CORBA::is_nil(aGen)){
210 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
211 Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
212 aGen = SALOME_MED::MED_Gen::_narrow(aComponent);
214 if(CORBA::is_nil(aGen))
215 throw std::runtime_error(QObject::tr("ERR_CANT_FIND_MED_COMPONENT").latin1());
220 VISU::Storable::TRestoringMap getMapOfValue (_PTR(SObject) theSObject)
222 VISU::Storable::TRestoringMap aMap;
224 _PTR(GenericAttribute) anAttr;
225 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
226 _PTR(AttributeComment) aComment (anAttr);
227 std::string aValue = aComment->Value();
228 QString aString (aValue.c_str());
229 VISU::Storable::StrToMap(aString, aMap);
235 QString getValue (_PTR(SObject) theSObject, QString theKey)
238 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
240 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
244 //------------------------------------------------------------
247 GetSelectedObj(const SalomeApp_Study* theStudy,
248 const QString& theEntry,
249 VISU::Storable::TRestoringMap* theMap)
251 if (!theStudy || theEntry.isEmpty())
252 return CORBA::Object::_nil();
254 _PTR(Study) aStudy = GetCStudy(theStudy);
255 _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry.latin1());
257 _PTR(GenericAttribute) anAttr;
258 if (theMap && aSObject->FindAttribute(anAttr,"AttributeComment")) {
259 _PTR(AttributeComment) aComment (anAttr);
260 std::string aValue = aComment->Value();
261 QString aString (aValue.c_str());
262 VISU::Storable::StrToMap(aString, *theMap);
264 return VISU::ClientSObjectToObject(aSObject);
266 return CORBA::Object::_nil();
270 GetSelectedObj(const SalomeApp_Module* theModule,
271 Handle(SALOME_InteractiveObject)* theIO,
272 VISU::Storable::TRestoringMap* theMap)
274 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
275 SALOME_ListIO aListIO;
276 aSelectionMgr->selectedObjects(aListIO);
277 SALOME_ListIteratorOfListIO anIter(aListIO);
279 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
283 return GetSelectedObj( GetAppStudy(theModule), anIO->getEntry(), theMap );
285 return CORBA::Object::_nil();
289 GetPrsToModify(const SalomeApp_Module* theModule,
290 Handle(SALOME_InteractiveObject)* theIO,
291 VISU::Storable::TRestoringMap* theMap)
293 if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
296 CORBA::Object_var anObject = GetSelectedObj(theModule, theIO);
297 if (CORBA::is_nil(anObject))
300 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
304 return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
308 Add(LightApp_SelectionMgr* theSelectionMgr,
309 const Handle(SALOME_InteractiveObject)& theIO)
311 SALOME_ListIO aListIO;
312 theSelectionMgr->selectedObjects(aListIO);
313 aListIO.Append(theIO);
314 theSelectionMgr->setSelectedObjects(aListIO);
318 Remove(LightApp_SelectionMgr* theSelectionMgr,
319 const Handle(SALOME_InteractiveObject)& theIO)
321 if (theIO.IsNull()) return;
322 SALOME_ListIO aListIO, aNewListIO;
323 theSelectionMgr->selectedObjects(aListIO);
324 SALOME_ListIteratorOfListIO anIter (aListIO);
325 for (; anIter.More(); anIter.Next()) {
326 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
327 if (!anIO->isSame(theIO)) {
328 aNewListIO.Append(theIO);
331 theSelectionMgr->setSelectedObjects(aNewListIO);
335 * \brief Check, if "Delete" popup-menu can be put on current selection
337 * \param theModule - is used to access SelectionManager, Study and VISU_Gen
338 * \retval bool - returns TRUE if all currently selected objects are removable
341 IsRemovableSelected (const SalomeApp_Module* theModule)
343 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
344 SALOME_ListIO aListIO;
345 aSelectionMgr->selectedObjects(aListIO);
347 if (aListIO.Extent() < 1)
350 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
351 if (!aStudy) return false;
353 // In some cases single selection can have its own popup-menu item for deletion
354 /*if (aListIO.Extent() == 1) {
355 Handle(SALOME_InteractiveObject) anIO = aListIO.First();
356 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
358 VISU::VISUType aType = (VISU::VISUType)getValue(aSObject, "myType").toInt();
359 if (aType == VISU::TVIEW3D) {
360 return false; // special case
365 SALOME_ListIteratorOfListIO anIter (aListIO);
366 for (; anIter.More(); anIter.Next()) {
367 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
368 if (anIO->hasEntry()) {
369 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
370 VISU::Storable::TRestoringMap pMap;
372 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
373 if (!CORBA::is_nil(aCORBAObject)) {
374 VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject);
375 if (CORBA::is_nil(aRemovableObj)) {
376 // Not removable CORBA object
380 // Can be removed, if lays directly under VISU
381 // (first sub-level) or is a child of such an object
382 string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType();
383 _PTR(GenericAttribute) anAttr;
384 _PTR(AttributeComment) aComment;
386 bool isUnderVISU = false;
387 _PTR(SObject) aFatherSObject = aSObject->GetFather();
388 if (aFatherSObject->FindAttribute(anAttr, "AttributeComment")) {
389 _PTR(AttributeComment) aComment (anAttr);
390 aNAME = aComment->Value();
391 if (aNAME == aVisuNAME) {
396 // Not directly under VISU component, check father
397 aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject);
398 if (!CORBA::is_nil(aCORBAObject)) {
404 aFatherSObject = aFatherSObject->GetFather();
405 if (aFatherSObject->FindAttribute(anAttr, "AttributeComment")) {
406 _PTR(AttributeComment) aComment (anAttr);
407 aNAME = aComment->Value();
408 if (aNAME == aVisuNAME) {
413 // Father is not directly under VISU component
427 ErasePrs (const SalomeApp_Module* theModule,
428 CORBA::Object_ptr theObject, bool theUpdate)
430 if (!CORBA::is_nil(theObject)) {
431 VISU::Base_var aBase = VISU::Base::_narrow(theObject);
432 if (CORBA::is_nil(aBase)) return;
433 VISU::VISUType aType = aBase->GetType();
437 if (VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
438 PlotCurve(theModule, aCurve, VISU::eErase );
441 case VISU::TCONTAINER:
443 if (VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
444 PlotContainer(theModule, aContainer, VISU::eErase );
449 if (VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
450 PlotTable(theModule, aTable, VISU::eErase );
455 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())) {
456 ErasePrs3d(theModule, aPrsObject);
458 if (SVTK_ViewWindow* vw = GetViewWindow(theModule))
468 DeleteSObject(VisuGUI* theModule,
469 _PTR(Study) theStudy,
470 _PTR(SObject) theSObject)
472 _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject);
473 for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
474 _PTR(SObject) aChildSObject = aChildIter->Value();
476 CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject);
477 RemoveScalarBarPosition(theModule,aChildObj);
478 ErasePrs(theModule, aChildObj);
481 CORBA::Object_var anObj = VISU::ClientSObjectToObject(theSObject);
482 if (!CORBA::is_nil(anObj)) {
483 RemoveScalarBarPosition(theModule,anObj);
484 ErasePrs(theModule, anObj);
486 VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
487 if (!CORBA::is_nil(aRemovableObject)) {
488 aRemovableObject->RemoveFromStudy();
491 // Remove aSObject together with all its sub-objects
493 VISU::RemoveFromStudy(theSObject,
494 false, // remove not only IOR attribute, but Object With Children
495 false); // not Destroy() sub-objects
500 DeletePrs3d(VisuGUI* theModule,
501 VISU::Prs3d_i* thePrs,
502 const Handle(SALOME_InteractiveObject)& theIO)
506 if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
509 RemoveScalarBarPosition(theModule,thePrs);
510 thePrs->RemoveFromStudy();
514 ErasePrs3d(const SalomeApp_Module* theModule,
515 VISU::Prs3d_i* thePrs)
517 if ( SVTK_ViewWindow* vw = GetViewWindow( theModule ) ){
518 if (VISU_Actor* anVISUActor = FindActor( vw, thePrs )) {
519 anVISUActor->VisibilityOff();
524 // Presentation management
527 ChangeRepresentation (const SalomeApp_Module* theModule,
528 VISU::PresentationType theType)
530 SVTK_ViewWindow* vw = GetViewWindow( theModule, false );
534 Handle(SALOME_InteractiveObject) anIO;
535 CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
536 if (CORBA::is_nil(anObject)) return;
538 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
539 if (CORBA::is_nil(aVisuObj)) return;
541 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
542 if (!aServant.in()) return;
544 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
546 if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) {
549 if (anActor->IsShrunk())
552 anActor->SetShrink();
555 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
556 aMesh->SetPresentationType(theType);
557 RecreateActor(theModule, aMesh);
559 anActor->SetRepresentation(theType);
568 SetShading ( const SalomeApp_Module* theModule,
571 SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type());
573 SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( aView );
577 Handle(SALOME_InteractiveObject) anIO;
578 CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
579 if (CORBA::is_nil(anObject)) return;
581 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
582 if (CORBA::is_nil(aVisuObj)) return;
584 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
585 if (!aServant.in()) return;
587 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
589 if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) {
590 if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor) )
591 aScalarMapActor->SetShading( theOn );
600 CheckTimeStamp(const SalomeApp_Module* theModule,
601 _PTR(SObject)& theSObject,
602 Handle(SALOME_InteractiveObject)* theIO)
604 Handle(SALOME_InteractiveObject) anIO;
605 CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
608 if (!anIO.IsNull() && anIO->hasEntry()){
609 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
610 theSObject = aStudy->FindObjectID(anIO->getEntry());
611 QString aValue = getValue(theSObject,"myType");
612 if (aValue.toInt() == int(VISU::TTIMESTAMP))
615 SUIT_MessageBox::warn1(GetDesktop(theModule),
616 QObject::tr("WRN_VISU"),
617 QObject::tr("WRN_NO_AVAILABLE_DATA"),
618 QObject::tr("BUT_OK") );
623 CheckResult(const SalomeApp_Module* theModule,
624 _PTR(SObject) theSource,
625 VISU::Result_var& theResult)
627 if(theSource->Depth() < 3) // Bug of SALOMEDS : can\t get father from root object
630 _PTR(SObject) aSObj = theSource->GetFather();
634 aSObj = aSObj->GetFather();
638 aSObj = aSObj->GetFather();
642 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
643 if (CORBA::is_nil(anObject)) {
644 aSObj = aSObj->GetFather();
647 anObject = VISU::ClientSObjectToObject(aSObj);
650 if (CORBA::is_nil(anObject))
653 theResult = VISU::Result::_narrow(anObject);
654 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
659 SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule, QString theType)
661 if(SalomeApp_Application* anApp = theModule->getApp()){
662 if(SUIT_ViewManager* aViewManager = anApp->activeViewManager()){
663 if (!theType.isNull()) {
664 if (aViewManager->getType() != theType)
667 return aViewManager->getActiveView();
676 GetViews(const SalomeApp_Module* theModule)
678 TViewWindows aViewWindows;
679 if(SalomeApp_Application* anApp = theModule->getApp()){
680 ViewManagerList aViewManagerList;
681 anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
682 QPtrListIterator<SUIT_ViewManager> anIter(aViewManagerList);
683 while(SUIT_ViewManager* aViewManager = anIter.current()){
684 QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
685 for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
686 if(SUIT_ViewWindow* aViewWindow = aViews.at(i))
687 if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow))
688 aViewWindows.push_back(aView);
697 GetViewWindow( const SalomeApp_Module* theModule, const bool theCreate )
699 if (SalomeApp_Application* anApp = theModule->getApp())
701 SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
706 SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate );
707 return aViewManager ? dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() ) : 0;
714 GetViewWindow(const SalomeApp_Module* theModule, const bool theCreate )
716 if (SalomeApp_Application* anApp = theModule->getApp())
718 SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow());
723 if(SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate ))
724 return dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
734 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>
735 (SUIT_Session::session()->activeApplication());
737 if (SUIT_ViewManager* aViewManager = anApp->activeViewManager()) {
738 if (aViewManager->getType() == SVTK_Viewer::Type()) {
739 if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
740 return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
749 PublishInView(const SalomeApp_Module* theModule,
750 VISU::Prs3d_i* thePrs)
752 VISU_Actor* aActor = NULL;
755 if(SVTK_ViewWindow* aView = GetViewWindow(theModule)){
756 QApplication::setOverrideCursor( Qt::waitCursor );
758 if(aActor = thePrs->CreateActor())
759 aView->AddActor(aActor);
760 }catch(std::exception& exc){
761 SUIT_MessageBox::warn1
762 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
763 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
764 QObject::tr("BUT_OK"));
766 QApplication::restoreOverrideCursor();
772 UpdateViewer(const SalomeApp_Module* theModule,
773 VISU::Prs3d_i* thePrs,
776 SVTK_ViewWindow* vw = GetViewWindow( theModule );
777 if (!vw) return NULL;
779 vtkRenderer *aRen = vw->getRenderer();
780 vtkActorCollection *anActColl = aRen->GetActors();
781 anActColl->InitTraversal();
784 VISU_Actor* anVISUActor = NULL;
785 VISU_Actor* aResActor = NULL;
786 while(vtkActor *anActor = anActColl->GetNextActor()){
787 anVISUActor = VISU_Actor::SafeDownCast(anActor);
789 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
790 if(aPrs == NULL) continue;
791 if (thePrs == aPrs) {
793 aResActor = anVISUActor;
794 thePrs->UpdateActor(aResActor);
795 aResActor->VisibilityOn();
796 } catch (std::runtime_error& exc) {
797 aResActor->VisibilityOff();
799 SUIT_MessageBox::warn1
800 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
801 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
802 QObject::tr("BUT_OK"));
804 } else if (theDispOnly) {
805 anVISUActor->VisibilityOff();
808 } else if (theDispOnly && anActor->GetVisibility()) {
809 anActor->VisibilityOff();
816 //anVISUActor = PublishInView( theModule, thePrs );
821 RepaintViewWindows (const SalomeApp_Module* theModule,
822 const Handle(SALOME_InteractiveObject)& theIObject)
824 TViewWindows aViewWindows;
825 if (SalomeApp_Application* anApp = theModule->getApp()) {
826 ViewManagerList aViewManagerList;
827 anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
828 QPtrListIterator<SUIT_ViewManager> anIter (aViewManagerList);
829 while (SUIT_ViewManager* aViewManager = anIter.current()) {
830 QPtrVector<SUIT_ViewWindow> aViews = aViewManager->getViews();
831 for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
832 if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
833 if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
834 if (vw->isVisible(theIObject)) {
835 vw->getRenderer()->ResetCameraClippingRange();
837 vw->highlight(theIObject, true, true);
848 FindActor(SVTK_ViewWindow* theViewWindow,
849 const char* theEntry)
851 using namespace SVTK;
852 if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){
853 if(vtkActorCollection* aCollection = aRenderer->GetActors()){
854 if(VISU_Actor* anActor = Find<VISU_Actor>(aCollection,TIsSameEntry<VISU_Actor>(theEntry))){
863 FindActor(SVTK_ViewWindow* theViewWindow,
864 VISU::Prs3d_i* thePrs)
866 SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
867 CORBA::String_var anEntry = aSObject->GetID();
868 return FindActor(theViewWindow,anEntry.in());
872 RecreateActor (const SalomeApp_Module* theModule,
873 VISU::Prs3d_i* thePrs)
875 QApplication::setOverrideCursor(Qt::waitCursor);
877 SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
878 CORBA::String_var anEntry = aSObject->GetID();
881 thePrs->UpdateActors();
882 } catch (std::runtime_error& exc) {
884 QApplication::restoreOverrideCursor();
885 SUIT_MessageBox::warn1
886 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
887 QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()),
888 QObject::tr("BUT_OK"));
890 thePrs->RemoveActors();
893 QApplication::restoreOverrideCursor();
896 static bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
898 const char* theActorClassName = "VISU_Actor")
900 vtkRenderer *aRen = theViewWindow->getRenderer();
901 vtkActorCollection *anActColl = aRen->GetActors();
904 int somethingVisible = false;
906 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
907 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
908 // loop through all props
909 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ) {
910 // if it's invisible, or has no geometry, we can skip the rest
911 if (prop->GetVisibility() && prop->IsA(theActorClassName)) {
912 bounds = prop->GetBounds();
913 // make sure we haven't got bogus bounds
914 if (bounds != NULL &&
915 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
916 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
917 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT)
919 somethingVisible = true;
920 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
921 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
922 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
923 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
924 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
925 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
929 return somethingVisible;
932 void SetFitAll(SVTK_ViewWindow* theViewWindow)
934 static float PRECISION = 0.000001;
935 static float DEVIATION = 600;
937 if (!ComputeVisiblePropBounds(theViewWindow, XYZ_Bnd)) return;
939 float absX = XYZ_Bnd[1] - XYZ_Bnd[0];
940 float absY = XYZ_Bnd[3] - XYZ_Bnd[2];
941 float absZ = XYZ_Bnd[5] - XYZ_Bnd[4];
943 enum CameraOrient {e3D, eFront, eLeft, eTop};
944 CameraOrient aCameraOrient = e3D;
945 if (absX <= PRECISION) aCameraOrient = eFront;
947 if (absY <= PRECISION) aCameraOrient = eLeft;
949 if (absZ <= PRECISION) aCameraOrient = eTop;
951 // all the three dimensions exceeds precision
952 float dev_abs_XY = absX / absY;
953 float dev_abs_YZ = absY / absZ;
954 float dev_abs_XZ = absX / absZ;
955 if (dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION)
956 aCameraOrient = eLeft;
958 if (1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION)
959 aCameraOrient = eFront;
961 if (dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION)
962 aCameraOrient = eTop;
969 switch (aCameraOrient) {
970 case eFront: theViewWindow->onFrontView(); break;
971 case eLeft: theViewWindow->onLeftView(); break;
972 case eTop: theViewWindow->onTopView(); break;
973 case e3D: theViewWindow->onResetView(); break;
975 theViewWindow->getRenderer()->ResetCameraClippingRange();
976 theViewWindow->onFitAll();
979 //************************************************************
983 GetPlot2dViewer(const SalomeApp_Module* theModule, const bool theCreate)
985 if(SalomeApp_Application* anApp = theModule->getApp()){
986 if(SUIT_ViewManager* aViewManager = anApp->getViewManager( Plot2d_Viewer::Type(), theCreate )){
987 return dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
993 // Internal function used by several public functions below
995 UpdateCurve(VISU::Curve_i* theCurve,
996 Plot2d_ViewFrame* aPlot,
997 SPlot2d_Curve* plotCurve,
1000 if ( theDisplaying == VISU::eErase ) {
1001 if ( plotCurve && aPlot )
1002 aPlot->eraseCurve( plotCurve, false );
1004 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1006 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1007 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1008 plotCurve->setVerTitle( theCurve->GetName() );
1009 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1010 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1013 int nbPoints = theCurve->GetData( xList, yList );
1014 if ( nbPoints > 0 && xList && yList ) {
1015 plotCurve->setData( xList, yList, nbPoints );
1017 if ( !theCurve->IsAuto() ) {
1018 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1019 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1020 SALOMEDS::Color color = theCurve->GetColor();
1021 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1023 plotCurve->setAutoAssign( theCurve->IsAuto() );
1025 aPlot->displayCurve( plotCurve, false );
1028 Plot2d_Curve* crv = theCurve->CreatePresentation();
1031 aPlot->displayCurve( crv, false );
1032 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1033 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1034 SALOMEDS::Color newColor;
1035 newColor.R = crv->getColor().red()/255.;
1036 newColor.G = crv->getColor().green()/255.;
1037 newColor.B = crv->getColor().blue()/255.;
1038 theCurve->SetColor( newColor );
1039 crv->setAutoAssign( theCurve->IsAuto() );
1046 PlotTable(const SalomeApp_Module* theModule,
1047 VISU::Table_i* table,
1050 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true ); // create if necessary
1053 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1057 if ( theDisplaying == VISU::eDisplayOnly )
1059 QList<Plot2d_Curve> clist;
1060 aPlot->getCurves( clist );
1061 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
1062 _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry().latin1() );
1064 _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
1065 for ( ; Iter->More(); Iter->Next() ) {
1066 CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
1067 if( !CORBA::is_nil( childObject ) ) {
1068 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1069 if( !CORBA::is_nil( aCurve ) ) {
1070 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1071 SPlot2d_Curve* plotCurve = 0;
1072 SPlot2d_Curve* tmpCurve;
1073 for ( int i = 0; i < clist.count(); i++ ) {
1074 tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
1075 if (tmpCurve && tmpCurve->hasIO() &&
1076 !strcmp(tmpCurve->getIO()->getEntry(), theCurve->GetEntry())) {
1077 plotCurve = tmpCurve;
1082 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1084 if ( theDisplaying == VISU::eErase && plotCurve ) {
1085 clist.remove( plotCurve );
1095 PlotCurve(const SalomeApp_Module* theModule,
1096 VISU::Curve_i* theCurve,
1099 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1102 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1106 // if ( theDisplaying == VISU::eDisplayOnly )
1107 // aPlot->EraseAll();
1108 QList<Plot2d_Curve> clist;
1109 aPlot->getCurves( clist );
1110 SPlot2d_Curve* plotCurve = 0;
1111 SPlot2d_Curve* tmpCurve;
1112 for (int i = 0; i < clist.count(); i++) {
1113 tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
1114 if (tmpCurve && tmpCurve->hasIO() &&
1115 !strcmp(tmpCurve->getIO()->getEntry(), theCurve->GetEntry())) {
1116 plotCurve = tmpCurve;
1117 } else if (theDisplaying == VISU::eDisplayOnly) {
1118 aPlot->eraseCurve(clist.at(i));
1122 UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
1128 PlotContainer(const SalomeApp_Module* theModule,
1129 VISU::Container_i* container,
1132 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1135 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1139 if ( theDisplaying == VISU::eDisplayOnly )
1141 QList<Plot2d_Curve> clist;
1142 aPlot->getCurves( clist );
1143 if ( container->GetNbCurves() > 0 ) {
1144 int nbCurves = container->GetNbCurves();
1145 for ( int k = 1; k <= nbCurves; k++ ) {
1146 VISU::Curve_i* theCurve = container->GetCurve( k );
1147 if ( theCurve && theCurve->IsValid() ) {
1148 SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
1149 (aView->getCurveByIO(new SALOME_InteractiveObject (theCurve->GetEntry(), "", "")));
1151 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1153 if ( plotCurve && theDisplaying == VISU::eErase ) {
1154 clist.remove( plotCurve );
1163 CreatePlot(SalomeApp_Module* theModule,
1164 _PTR(SObject) theTableSO)
1166 if ( IsSObjectTable(theTableSO) ) {
1167 CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
1168 CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
1169 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1170 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1171 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1173 if ( pContainer && pTable ) {
1174 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
1175 CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
1176 if( !CORBA::is_nil( aNewCurve ) ) {
1177 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
1179 pContainer->AddCurve( pCrv->_this() );
1183 PlotContainer( theModule, pContainer, VISU::eDisplay );
1185 QString anEntry = pContainer->GetEntry();
1186 _PTR(Study) aStudy = theTableSO->GetStudy();
1187 _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.latin1());
1188 _PTR(SObject) aParentSO = aContainerSO->GetFather();
1189 UpdateObjBrowser(theModule,true,aParentSO);
1195 //************************************************************
1198 void CreateMesh (const SalomeApp_Module* theModule,
1199 const Handle(SALOME_InteractiveObject)& theIO)
1201 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
1202 //if (CheckLock(aStudy))
1205 _PTR(SObject) aResultSObj = aStudy->FindObjectID(theIO->getEntry());
1208 VISU::Result_var aResult;
1209 VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
1210 if (pResult == NULL)
1213 Storable::TRestoringMap aMap = getMapOfValue(aResultSObj);
1215 string aComment = Storable::FindValue(aMap,"myComment",&isExist).latin1();
1219 CORBA::Object_var aMesh;
1220 string aMeshName = Storable::FindValue(aMap,"myMeshName").latin1();
1225 if (aComment == "ENTITY") {
1226 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
1227 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1228 aMesh = GetVisuGen(theModule)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1229 } else if (aComment == "FAMILY") {
1230 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
1231 string aFamilyName = Storable::FindValue(aMap,"myName").latin1();
1232 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1233 aMesh = GetVisuGen(theModule)->FamilyMeshOnEntity
1234 (aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1235 } else if (aComment == "GROUP") {
1236 string aGroupName = Storable::FindValue(aMap,"myName").latin1();
1237 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1238 aMesh = GetVisuGen(theModule)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1242 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1246 QApplication::restoreOverrideCursor();
1247 VISU::Mesh_i* pPresent = NULL;
1248 if (!CORBA::is_nil(aMesh))
1249 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1250 if (pPresent == NULL) {
1251 SUIT_MessageBox::warn1 (GetDesktop(theModule),
1252 QObject::tr("WRN_VISU"),
1253 QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
1254 QObject::tr("BUT_OK"));
1258 if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) {
1264 PublishInView(theModule, pPresent);
1265 //aView->onFitAll();
1269 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1272 theModule->application()->putInfo(QObject::tr("INF_DONE"));
1273 // Make "Save" button active
1274 theModule->getApp()->updateActions();
1275 } catch (std::runtime_error& exc) {
1277 SUIT_MessageBox::warn1
1278 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
1279 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()),
1280 QObject::tr("BUT_OK"));
1285 // ========================================================================================
1286 // GetPrs3dList: find list of presentations for the given object
1287 // ========================================================================================
1288 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1289 const Handle(SALOME_InteractiveObject)& theIO)
1291 std::vector<VISU::Prs3d_i*> aList;
1292 if (!theIO.IsNull() && theIO->hasEntry()) {
1293 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1294 _PTR(SObject) aSObject = aCStudy->FindObjectID(theIO->getEntry());
1295 aList = GetPrs3dList(theModule, aSObject);
1300 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1301 _PTR(SObject) theObject)
1303 std::vector<VISU::Prs3d_i*> aList; int k = 0;
1307 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1309 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(theObject);
1310 if (!CORBA::is_nil(aCORBAObject)) {
1311 VISU::Base_var aVisuObj = VISU::Base::_narrow(aCORBAObject);
1312 if (!CORBA::is_nil(aVisuObj)) {
1313 VISU::VISUType aType = aVisuObj->GetType();
1315 case VISU::TSCALARMAP:
1316 case VISU::TISOSURFACE:
1317 case VISU::TDEFORMEDSHAPE:
1318 case VISU::TCUTPLANES:
1319 case VISU::TCUTLINES:
1320 case VISU::TVECTORS:
1321 case VISU::TSTREAMLINES:
1323 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1325 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1326 if (aServant.in()) {
1327 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1329 aList[k] = aPrsObject;
1336 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1337 _PTR(SObject) aTimeStamp;
1338 anIter->Next(); // First is reference on support
1339 for (; anIter->More(); anIter->Next()) {
1340 aTimeStamp = anIter->Value();
1341 if (!aTimeStamp) continue;
1342 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1343 if (!aSubList.empty()) {
1344 int n = aSubList.size();
1346 for (int i = 0; i < n; i++) {
1347 aList[k] = aSubList[i];
1357 _PTR(GenericAttribute) anAttr;
1358 if (theObject->FindAttribute(anAttr, "AttributeComment")) {
1359 _PTR(AttributeComment) aComment (anAttr);
1360 string aComm = aComment->Value();
1361 QString strIn (aComm.c_str());
1362 VISU::Storable::TRestoringMap pMap;
1363 VISU::Storable::StrToMap(strIn, pMap);
1365 VISU::VISUType aType =
1366 (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
1371 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1372 _PTR(SObject) aTimeStamp;
1373 anIter->Next(); // First is reference on support
1374 for (; anIter->More(); anIter->Next()) {
1375 aTimeStamp = anIter->Value();
1376 if (!aTimeStamp) continue;
1377 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1378 if (!aSubList.empty()) {
1379 int n = aSubList.size();
1381 for (int i = 0; i < n; i++) {
1382 aList[k] = aSubList[i];
1389 case VISU::TTIMESTAMP:
1391 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1393 for (; anIter->More(); anIter->Next()) {
1394 aPrs = anIter->Value();
1395 if (!aPrs) continue;
1396 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
1397 if (!aSubList.empty()) {
1398 int n = aSubList.size();
1400 for (int i = 0; i < n; i++) {
1401 aList[k] = aSubList[i];
1415 int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule){
1417 std::set<int> aIndexes;
1418 SVTK_ViewWindow* vw = GetViewWindow(theModule);
1419 TViewToPrs3d aMap = theModule->getScalarBarsMap();
1420 TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(vw);
1421 if (aViewToPrsIter != aMap.end()){
1422 TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
1423 for(;aPrsIter!=(aViewToPrsIter->second).end();aPrsIter++){
1424 aIndexes.insert((*aPrsIter).second);
1427 std::set<int>::const_iterator aIter = aIndexes.begin();
1428 for (int i=1,length=aIndexes.size(); i <= length; i++){
1429 std::set<int>::const_iterator aIter = aIndexes.find(i);
1430 if(aIter==aIndexes.end()){minIndx = i;break;}
1431 else minIndx = i + 1;
1437 void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos){
1438 SVTK_ViewWindow* vw = GetViewWindow(theModule);
1439 TViewToPrs3d& aMap = theModule->myScalarBarsMap;
1440 TPrs3dToInd aPair; aPair.first=thePrs3d; aPair.second=pos;
1441 aMap[vw].insert(aPair);
1444 void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d){
1445 TViewToPrs3d& aMap = theModule->myScalarBarsMap;
1446 TSetPrs3d::iterator aIter = aMap[vw].begin();
1447 for(;aIter!=aMap[vw].end();aIter++)
1448 if((*aIter).first == thePrs3d){
1449 aMap[vw].erase(*aIter);
1454 void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d){
1455 SVTK_ViewWindow* vw = GetViewWindow(theModule);
1456 RemoveScalarBarPosition(theModule,vw,thePrs3d);
1459 void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject){
1460 if (!CORBA::is_nil(theObject)) {
1461 Base_var aBase = Base::_narrow(theObject);
1462 if (CORBA::is_nil(aBase)) return;
1463 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
1464 RemoveScalarBarPosition(theModule,aPrsObject);