1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU VISUGUI : GUI of VISU component
23 // File : VisuGUI_Tools.cxx
24 // Author : Sergey Anikin
27 #include "VisuGUI_Tools.h"
28 #include "VisuGUI_ViewTools.h"
29 #include "VisuGUI_Prs3dTools.h"
30 #include "VisuGUI_DialogRunner.h"
34 #include "VISU_Gen_i.hh"
35 #include "VISU_Prs3d_i.hh"
36 #include "VISU_Result_i.hh"
37 #include "VISU_Table_i.hh"
38 //#include "VISU_Mesh_i.hh"
39 #include "VISU_ViewManager_i.hh"
41 #include "VISU_Actor.h"
42 #include "VISU_ScalarMapAct.h"
44 #include "SalomeApp_Module.h"
45 #include "SalomeApp_Study.h"
46 #include "SalomeApp_Application.h"
48 #include "LightApp_DataObject.h"
49 #include "LightApp_SelectionMgr.h"
52 //#include "OB_Browser.h"
54 #include "SALOME_ListIO.hxx"
55 #include "SALOME_ListIteratorOfListIO.hxx"
57 #include "SVTK_ViewWindow.h"
58 #include "SVTK_Functor.h"
60 #include "VTKViewer_Algorithm.h"
62 #include "SPlot2d_ViewModel.h"
63 #include "Plot2d_ViewFrame.h"
64 #include "Plot2d_ViewManager.h"
66 #include "SUIT_Session.h"
67 #include "SUIT_MessageBox.h"
68 #include "SUIT_Desktop.h"
69 #include "SUIT_ViewWindow.h"
71 #include "CAM_DataModel.h"
73 #include <vtkRenderer.h>
74 #include <vtkActorCollection.h>
78 #include <QDoubleSpinBox>
82 //=============================================================================
85 //------------------------------------------------------------
87 GetDesktop(const CAM_Module* theModule)
89 return theModule->application()->desktop();
92 //------------------------------------------------------------
93 LightApp_SelectionMgr*
94 GetSelectionMgr(const SalomeApp_Module* theModule)
96 return theModule->getApp()->selectionMgr();
99 //------------------------------------------------------------
101 GetAppStudy(const CAM_Module* theModule)
104 dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy());
107 //------------------------------------------------------------
109 GetCStudy(const SalomeApp_Study* theStudy)
111 return theStudy->studyDS();
114 //------------------------------------------------------------
116 IsStudyLocked( _PTR(Study) theStudy )
119 return theStudy->GetProperties()->IsLocked();
123 //------------------------------------------------------------
125 CheckLock( _PTR(Study) theStudy,
128 if(IsStudyLocked(theStudy)){
129 SUIT_MessageBox::warning(theWidget,
130 QObject::tr("WRN_VISU_WARNING"),
131 QObject::tr("WRN_STUDY_LOCKED") );
137 //------------------------------------------------------------
139 runAndWait( QDialog* dlg, const bool modal )
141 VisuGUI_DialogRunner r( dlg );
142 return r.run( modal );
145 //------------------------------------------------------------
147 FindDataObject(SUIT_DataObject* theDataObject,
148 const QString& theEntry,
151 int aLevel = theDataObject->level() + 2;
152 QString aSourceEntry = theEntry.section(':',0,aLevel);
153 DataObjectList aList;
154 theDataObject->children(aList);
155 DataObjectList::Iterator aDataObjectIter = aList.begin();
156 while( aDataObjectIter!= aList.end() ) {
157 if(LightApp_DataObject* aChildDataObject = dynamic_cast<LightApp_DataObject*>(*aDataObjectIter)){
158 QString anEntry = aChildDataObject->entry();
159 QString aCurrentEntry = anEntry.section(':',0,aLevel);
160 if(aSourceEntry == aCurrentEntry){
161 if(theLevel == aLevel){
162 return aChildDataObject;
164 return FindDataObject(aChildDataObject,theEntry,theLevel);
173 //------------------------------------------------------------
175 FindDataObject(CAM_Module* theModule,
176 _PTR(SObject) theSObject)
178 CAM_DataModel* aDataModel = theModule->dataModel();
179 CAM_DataObject* aRootDataObject = aDataModel->root();
180 if(_PTR(SComponent) aComponent = theSObject)
181 return dynamic_cast<LightApp_DataObject*>(aRootDataObject);
183 int aLevel = theSObject->Depth();
184 std::string anEntry = theSObject->GetID();
185 return FindDataObject(aRootDataObject,anEntry.c_str(),aLevel);
188 //------------------------------------------------------------
190 UpdateObjBrowser(SalomeApp_Module* theModule,
191 bool theIsUpdateDataModel,
192 _PTR(SObject) theSObject)
194 LightApp_DataObject* aDataObject = NULL;
196 aDataObject = FindDataObject(theModule,theSObject);
198 theModule->updateObjBrowser(theIsUpdateDataModel,aDataObject);
199 theModule->getApp()->updateActions();
202 //------------------------------------------------------------
204 IsSObjectTable( _PTR(SObject) theSObject )
207 _PTR(GenericAttribute) anAttr;
208 if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
210 if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
216 //------------------------------------------------------------
218 GetVisuGen(const CAM_Module* theModule)
220 static VISU_Gen_i* aGen = NULL;
222 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
223 Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
224 VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
225 if(!CORBA::is_nil(aVISU)){
226 if((aGen = VISU_Gen_i::GetVisuGenImpl()))
227 aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
231 throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").toLatin1().data());
235 //------------------------------------------------------------
236 SALOME_MED::MED_Gen_var
239 static SALOME_MED::MED_Gen_var aGen;
240 if(CORBA::is_nil(aGen)){
241 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
242 Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
243 aGen = SALOME_MED::MED_Gen::_narrow(aComponent);
245 if(CORBA::is_nil(aGen))
246 throw std::runtime_error(QObject::tr("ERR_CANT_FIND_MED_COMPONENT").toLatin1().data());
251 //----------------------------------------------------------------------------
254 GetSelectedObjects(const SalomeApp_Module* theModule)
256 TSelectionInfo aSelectionInfo;
257 const SalomeApp_Study* aStudy = GetAppStudy(theModule);
258 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
259 SALOME_ListIO aListIO;
260 aSelectionMgr->selectedObjects(aListIO);
261 SALOME_ListIteratorOfListIO anIter(aListIO);
264 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
267 TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
268 if(anObjectInfo.mySObject){
269 TSelectionItem aSelectionItem;
270 aSelectionItem.myObjectInfo = anObjectInfo;
271 aSelectionItem.myIO = anIO;
272 aSelectionInfo.push_back(aSelectionItem);
275 anIter.Next(); // MULTIPR fixed
277 return aSelectionInfo;
280 //----------------------------------------------------------------------------
282 GetObjectByEntry(const SalomeApp_Study* theStudy,
283 const std::string& theEntry)
285 TObjectInfo anObjectInfo;
286 if(!theStudy || theEntry == "")
289 _PTR(Study) aStudy = GetCStudy(theStudy);
290 if(_PTR(SObject) aSObject = aStudy->FindObjectID(theEntry)){
291 anObjectInfo.mySObject = aSObject;
292 CORBA::Object_var anObject = ClientSObjectToObject(aSObject);
293 if(VISU::Base_i* aBase = GetServantInterface<VISU::Base_i>(anObject))
294 anObjectInfo.myBase = aBase;
301 //----------------------------------------------------------------------------
303 GetPrs3dToModify(const SalomeApp_Module* theModule,
306 if (CheckLock(GetCStudy(GetAppStudy(theModule)), GetDesktop(theModule)))
309 return GetPrs3dFromBase(theBase);
312 //----------------------------------------------------------------------------
314 GetPrs3dFromBase(Base_i* theBase)
316 if(theBase && theBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
317 CORBA::Object_var anObject = theBase->_this();
318 VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
319 VISU::Prs3d_var aPrs3d = aHolder->GetDevice();
320 return VISU::GetServantInterface<VISU::Prs3d_i>(aPrs3d);
322 return dynamic_cast<VISU::Prs3d_i*>(theBase);
326 //----------------------------------------------------------------------------
328 GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
329 VISU::Prs3d_i*& thePrs3d,
330 SVTK_ViewWindow*& theViewWindow,
331 VISU_Actor*& thenActor)
333 VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
334 if(aSelectionInfo.empty())
337 VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
338 thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
342 theViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
346 thenActor = FindActor(theViewWindow, thePrs3d);
354 //----------------------------------------------------------------------------
356 Add(LightApp_SelectionMgr* theSelectionMgr,
357 const Handle(SALOME_InteractiveObject)& theIO)
359 SALOME_ListIO aListIO;
360 theSelectionMgr->selectedObjects(aListIO);
361 aListIO.Append(theIO);
362 theSelectionMgr->setSelectedObjects(aListIO);
365 //------------------------------------------------------------
367 Remove(LightApp_SelectionMgr* theSelectionMgr,
368 const Handle(SALOME_InteractiveObject)& theIO)
370 if (theIO.IsNull()) return;
371 SALOME_ListIO aListIO, aNewListIO;
372 theSelectionMgr->selectedObjects(aListIO);
373 SALOME_ListIteratorOfListIO anIter (aListIO);
374 for (; anIter.More(); anIter.Next()) {
375 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
376 if (!anIO->isSame(theIO)) {
377 aNewListIO.Append(theIO);
380 theSelectionMgr->setSelectedObjects(aNewListIO);
384 * \brief Check, if the object can be deleted
386 * \param theEntry - entry of the object to check
387 * \param theModule - is used to access Study and VISU_Gen
388 * \retval bool - returns TRUE if the object is removable
391 IsRemovable (const std::string theEntry,
392 const SalomeApp_Module* theModule)
394 // asv : if selected object is a Save Point object selected in object browser - return false
395 if ( QString( theEntry.c_str() ).startsWith( QObject::tr( "SAVE_POINT_DEF_NAME" ) ) )
398 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
400 _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry);
401 VISU::Storable::TRestoringMap pMap;
403 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
404 if (!CORBA::is_nil(aCORBAObject)) {
405 VISU::RemovableObject_var aRemovableObj = VISU::RemovableObject::_narrow(aCORBAObject);
406 if (CORBA::is_nil(aRemovableObj)) {
407 // Not removable CORBA object
411 // Can be removed, if lays directly under VISU
412 // (first sub-level) or is a child of such an object
413 string aNAME, aVisuNAME = GetVisuGen(theModule)->ComponentDataType();
414 _PTR(GenericAttribute) anAttr;
415 _PTR(AttributeString) aComment;
417 _PTR(SObject) aRefSObject;
418 if (aSObject->ReferencedObject(aRefSObject)) {
419 // It can be a reference on curve, published under a container. IPAL 20317
420 VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(theModule), aRefSObject->GetID());
421 VISU::Base_i* aRefBase = aRefObjectInfo.myBase;
422 if( (aRefBase && aRefBase->GetType() == VISU::TCURVE) || (aRefBase && aRefBase->GetType() == VISU::TMESH) )
426 bool isUnderVISU = false;
427 _PTR(SObject) aFatherSObject = aSObject->GetFather();
428 if (aFatherSObject->FindAttribute(anAttr, "AttributeName")) {
429 // mkr : 24.11.2006 : use AttributeName and module title for correct "Delete"
430 // popup item displaying in object browser popup
431 _PTR(AttributeName) aComment (anAttr);
432 aNAME = aComment->Value();
433 QString aVisuTITLE = theModule->getApp()->moduleTitle(aVisuNAME.c_str());
434 if (!aVisuTITLE.compare(aNAME.c_str())) {
439 // Not directly under VISU component, check father
440 aCORBAObject = VISU::ClientSObjectToObject(aFatherSObject);
441 if (!CORBA::is_nil(aCORBAObject)) {
447 aFatherSObject = aFatherSObject->GetFather();
448 if (aFatherSObject->FindAttribute(anAttr, "AttributeString")) {
449 _PTR(AttributeString) aComment (anAttr);
450 aNAME = aComment->Value();
451 if (aNAME == aVisuNAME) {
456 // Father is not directly under VISU component
466 * \brief Check, if "Delete" popup-menu can be put on current selection
468 * \param theModule - is used to access SelectionManager, Study and VISU_Gen
469 * \retval bool - returns TRUE if all currently selected objects are removable
472 IsRemovableSelected (const SalomeApp_Module* theModule)
474 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
475 SALOME_ListIO aListIO;
476 aSelectionMgr->selectedObjects(aListIO);
478 if (aListIO.Extent() < 1)
481 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
482 if (!aStudy) return false;
484 SALOME_ListIteratorOfListIO anIter (aListIO);
485 for (; anIter.More(); anIter.Next()) {
486 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
487 if (anIO->hasEntry()) {
488 if (!IsRemovable(anIO->getEntry(), theModule))
495 //------------------------------------------------------------
497 DeleteSObject(VisuGUI* theModule,
498 _PTR(Study) theStudy,
499 _PTR(SObject) theSObject)
501 _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject);
502 for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
503 _PTR(SObject) aSObject = aChildIter->Value();
504 TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), aSObject->GetID());
505 ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */false);
508 TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), theSObject->GetID());
509 if(anObjectInfo.myBase){
510 ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */true);
512 CORBA::Object_var anObject = ClientSObjectToObject(theSObject);
513 VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject);
514 if (!CORBA::is_nil(aRemovableObject)) {
515 aRemovableObject->RemoveFromStudy();
518 // Remove aSObject together with all its sub-objects
519 VISU::RemoveFromStudy(theSObject,
520 false, // remove not only IOR attribute, but Object With Children
521 false); // not Destroy() sub-objects
525 //------------------------------------------------------------
527 DeletePrs3d(VisuGUI* theModule,
528 VISU::Prs3d_i* thePrs)
533 if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
536 if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule))
537 RemoveScalarBarPosition(theModule, aViewWindow, thePrs);
539 if(VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(thePrs)){
540 std::string anEntry = aColoredPrs3d->GetHolderEntry();
542 VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), anEntry);
543 if(VISU::Base_i* aBase = anObjectInfo.myBase){
544 if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
545 CORBA::Object_var anObject = aBase->_this();
546 VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject);
547 aRemovableObject->RemoveFromStudy();
554 thePrs->RemoveFromStudy();
558 //------------------------------------------------------------
559 // Presentation management
561 ChangeRepresentation (const SalomeApp_Module* theModule,
562 VISU::PresentationType theType)
564 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
565 if(aSelectionInfo.empty())
568 VISU::Prs3d_i* aPrs3d;
569 VISU::PointMap3d_i* aTable;
571 VISU_ActorBase* anActorBase;
573 TSelectionItem aSelectionItem = aSelectionInfo.front();
574 aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
576 aTable = dynamic_cast<VISU::PointMap3d_i*>(aSelectionItem.myObjectInfo.myBase);
581 SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
586 anActor = FindActor(aViewWindow, aPrs3d);
590 anActorBase = VISU::FindActorBase(aViewWindow, aTable);
599 if (anActor->IsShrunk()) {
604 anActor->SetShrink();
607 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
608 aMesh->SetShrink(toShrink);
611 if (anActorBase->IsShrunk())
612 anActorBase->UnShrink();
614 anActorBase->SetShrink();
619 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
620 aMesh->SetPresentationType(theType);
621 RecreateActor(theModule, aMesh);
623 anActor->SetRepresentation(theType);
627 anActorBase->SetRepresentation(theType);
630 aViewWindow->Repaint();
633 //------------------------------------------------------------
635 SetShading ( const SalomeApp_Module* theModule,
638 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
639 if(aSelectionInfo.empty())
642 TSelectionItem aSelectionItem = GetSelectedObjects(theModule).front();
643 VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
647 SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
651 VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
655 if(VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor)){
656 aScalarMapActor->SetShading(theOn);
657 aViewWindow->Repaint();
661 //------------------------------------------------------------
664 CheckTimeStamp(const SalomeApp_Module* theModule,
665 _PTR(SObject)& theSObject,
666 Handle(SALOME_InteractiveObject)& theIO,
667 ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
669 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
670 if(!aSelectionInfo.empty()){
671 TSelectionItem aSelectionItem = aSelectionInfo.front();
672 theIO = aSelectionItem.myIO;
673 theSObject = aSelectionItem.myObjectInfo.mySObject;
674 VISU::VISUType aType = VISU::Storable::SObject2Type(theSObject);
675 if (VISU::TTIMESTAMP == aType){
676 thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
679 if (VISU::TFIELD == aType){
680 thePublishInStudyMode = ColoredPrs3d_i::EPublishIndependently;
681 if(theSObject->FindSubObject(2,theSObject))
685 SUIT_MessageBox::warning(GetDesktop(theModule),
686 QObject::tr("WRN_VISU"),
687 QObject::tr("WRN_NO_AVAILABLE_DATA") );
691 //------------------------------------------------------------
693 CheckResult(const SalomeApp_Module* theModule,
694 _PTR(SObject) theSource,
695 VISU::Result_var& theResult)
697 if(theSource->Depth() < 3) // Bug of SALOMEDS : can\t get father from root object
700 _PTR(SObject) aSObj = theSource->GetFather();
704 aSObj = aSObj->GetFather();
708 aSObj = aSObj->GetFather();
712 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
713 if (CORBA::is_nil(anObject)) {
714 aSObj = aSObj->GetFather();
717 anObject = VISU::ClientSObjectToObject(aSObj);
720 if (CORBA::is_nil(anObject))
723 theResult = VISU::Result::_narrow(anObject);
724 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
727 //------------------------------------------------------------
730 PublishMeshInView(const SalomeApp_Module* theModule,
731 VISU::Prs3d_i* thePrs,
732 SVTK_ViewWindow* theViewWindow)
734 VISU_Actor* aActor = NULL;
735 if (!thePrs || !theViewWindow)
738 QApplication::setOverrideCursor( Qt::WaitCursor );
740 if ((aActor = thePrs->CreateActor()))
741 theViewWindow->AddActor(aActor);
742 } catch(std::exception& exc) {
743 SUIT_MessageBox::warning
744 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
745 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
747 QApplication::restoreOverrideCursor();
752 //------------------------------------------------------------
754 RepaintViewWindows (const SalomeApp_Module* theModule,
755 const Handle(SALOME_InteractiveObject)& theIObject)
757 TViewWindows aViewWindows;
758 if (SalomeApp_Application* anApp = theModule->getApp()) {
759 ViewManagerList aViewManagerList;
760 anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
761 QList<SUIT_ViewManager*>::Iterator anIter = aViewManagerList.begin();
762 while ( anIter != aViewManagerList.end() )
764 QVector<SUIT_ViewWindow*> aViews = (*anIter)->getViews();
765 for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
766 if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
767 if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
768 if (vw->isVisible(theIObject)) {
769 vw->getRenderer()->ResetCameraClippingRange();
771 vw->highlight(theIObject, true, true);
781 //------------------------------------------------------------
783 FindActor(const SalomeApp_Study* theStudy,
784 SVTK_ViewWindow* theViewWindow,
785 const QString& theEntry)
787 TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().data());
788 VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
789 return FindActor(theViewWindow, aPrs3d);
792 //------------------------------------------------------------
794 FindActorBase(const SalomeApp_Study* theStudy,
795 SVTK_ViewWindow* theViewWindow,
796 const QString& theEntry)
798 TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().constData());
799 VISU::PointMap3d_i* aTable = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase);
800 return FindActorBase(theViewWindow, aTable);
803 //------------------------------------------------------------
805 RecreateActor (const SalomeApp_Module* theModule,
806 VISU::Prs3d_i* thePrs)
808 QApplication::setOverrideCursor(Qt::WaitCursor);
810 SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
811 CORBA::String_var anEntry = aSObject->GetID();
814 thePrs->UpdateActors();
815 } catch (std::runtime_error& exc) {
817 QApplication::restoreOverrideCursor();
818 SUIT_MessageBox::warning
819 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
820 QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()) );
822 thePrs->RemoveActors();
825 QApplication::restoreOverrideCursor();
828 //------------------------------------------------------------
830 ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
831 vtkFloatingPointType allBounds[6],
832 const char* theActorClassName)
834 vtkRenderer *aRen = theViewWindow->getRenderer();
835 vtkActorCollection *anActColl = aRen->GetActors();
837 vtkFloatingPointType *bounds;
838 int somethingVisible = false;
840 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
841 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
842 // loop through all props
843 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ) {
844 // if it's invisible, or has no geometry, we can skip the rest
845 if (prop->GetVisibility() && prop->IsA(theActorClassName)) {
846 bounds = prop->GetBounds();
847 // make sure we haven't got bogus bounds
848 if (bounds != NULL &&
849 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
850 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
851 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT)
853 somethingVisible = true;
854 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
855 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
856 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
857 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
858 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
859 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
863 return somethingVisible;
866 //------------------------------------------------------------
867 void SetFitAll(SVTK_ViewWindow* theViewWindow)
869 static vtkFloatingPointType PRECISION = 0.000001;
870 static vtkFloatingPointType DEVIATION = 600;
871 vtkFloatingPointType XYZ_Bnd[6];
872 if (!ComputeVisiblePropBounds(theViewWindow, XYZ_Bnd)) return;
874 vtkFloatingPointType absX = XYZ_Bnd[1] - XYZ_Bnd[0];
875 vtkFloatingPointType absY = XYZ_Bnd[3] - XYZ_Bnd[2];
876 vtkFloatingPointType absZ = XYZ_Bnd[5] - XYZ_Bnd[4];
878 enum CameraOrient {e3D, eFront, eLeft, eTop};
879 CameraOrient aCameraOrient = e3D;
880 if (absX <= PRECISION) aCameraOrient = eFront;
882 if (absY <= PRECISION) aCameraOrient = eLeft;
884 if (absZ <= PRECISION) aCameraOrient = eTop;
886 // all the three dimensions exceeds precision
887 vtkFloatingPointType dev_abs_XY = absX / absY;
888 vtkFloatingPointType dev_abs_YZ = absY / absZ;
889 vtkFloatingPointType dev_abs_XZ = absX / absZ;
890 if (dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION)
891 aCameraOrient = eLeft;
893 if (1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION)
894 aCameraOrient = eFront;
896 if (dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION)
897 aCameraOrient = eTop;
904 switch (aCameraOrient) {
905 case eFront: theViewWindow->onFrontView(); break;
906 case eLeft: theViewWindow->onLeftView(); break;
907 case eTop: theViewWindow->onTopView(); break;
908 case e3D: theViewWindow->onResetView(); break;
910 theViewWindow->getRenderer()->ResetCameraClippingRange();
911 theViewWindow->onFitAll();
914 //************************************************************
918 GetPlot2dViewer(const SalomeApp_Module* theModule, const bool theCreate)
920 if(SalomeApp_Application* anApp = theModule->getApp()){
921 if(SUIT_ViewManager* aViewManager = anApp->getViewManager( Plot2d_Viewer::Type(), theCreate )){
922 return dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
928 //------------------------------------------------------------
929 // Internal function used by several public functions below
931 UpdateCurve(VISU::Curve_i* theCurve,
932 Plot2d_ViewFrame* aPlot,
933 SPlot2d_Curve* plotCurve,
936 if ( theDisplaying == VISU::eErase ) {
937 if ( plotCurve && aPlot )
938 aPlot->eraseCurve( plotCurve, false );
940 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
942 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
943 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
944 plotCurve->setVerTitle( theCurve->GetName().c_str() );
945 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
946 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
950 int nbPoints = theCurve->GetData( xList, yList, zList );
951 if ( nbPoints > 0 && xList && yList ) {
952 plotCurve->setData( xList, yList, nbPoints, zList );
954 if ( !theCurve->IsAuto() ) {
955 plotCurve->setLine( (Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
956 plotCurve->setMarker( (Plot2d::MarkerType)theCurve->GetMarker() );
957 SALOMEDS::Color color = theCurve->GetColor();
958 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
960 plotCurve->setAutoAssign( theCurve->IsAuto() );
962 aPlot->displayCurve( plotCurve, false );
965 Plot2d_Curve* crv = theCurve->CreatePresentation();
968 aPlot->displayCurve( crv, false );
969 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
970 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
971 SALOMEDS::Color newColor;
972 newColor.R = crv->getColor().red()/255.;
973 newColor.G = crv->getColor().green()/255.;
974 newColor.B = crv->getColor().blue()/255.;
975 theCurve->SetColor( newColor );
976 crv->setAutoAssign( theCurve->IsAuto() );
982 //------------------------------------------------------------
984 PlotTable(const SalomeApp_Module* theModule,
985 VISU::Table_i* table,
988 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true ); // create if necessary
991 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
995 if ( theDisplaying == VISU::eDisplayOnly )
997 QList<Plot2d_Curve*> clist;
998 aPlot->getCurves( clist );
999 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
1000 _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
1002 _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
1003 for ( ; Iter->More(); Iter->Next() ) {
1004 CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
1005 if( !CORBA::is_nil( childObject ) ) {
1006 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1007 if( !CORBA::is_nil( aCurve ) ) {
1008 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1009 SPlot2d_Curve* plotCurve = 0;
1010 SPlot2d_Curve* tmpCurve;
1011 for ( int i = 0; i < clist.count(); i++ ) {
1012 tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
1013 if (tmpCurve && tmpCurve->hasIO() &&
1014 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1015 plotCurve = tmpCurve;
1020 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1022 if ( theDisplaying == VISU::eErase && plotCurve ) {
1023 clist.removeAll(plotCurve );
1032 //------------------------------------------------------------
1034 PlotCurve(const SalomeApp_Module* theModule,
1035 VISU::Curve_i* theCurve,
1038 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1041 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1045 // if ( theDisplaying == VISU::eDisplayOnly )
1046 // aPlot->EraseAll();
1047 QList<Plot2d_Curve*> clist;
1048 aPlot->getCurves( clist );
1049 SPlot2d_Curve* plotCurve = 0;
1050 SPlot2d_Curve* tmpCurve;
1051 if(theDisplaying == VISU::eErase) {
1052 // 23.06.2008 skl for IPAL17672
1053 for (int i = 0; i < clist.count(); i++) {
1054 tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
1055 if (tmpCurve && tmpCurve->hasIO() &&
1056 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1057 plotCurve = tmpCurve;
1058 aPlot->eraseCurve(clist.at(i));
1062 UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
1065 for (int i = 0; i < clist.count(); i++) {
1066 tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
1067 if (tmpCurve && tmpCurve->hasIO() &&
1068 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1069 plotCurve = tmpCurve;
1071 else if (theDisplaying == VISU::eDisplayOnly) {
1072 aPlot->eraseCurve(clist.at(i));
1075 UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
1081 //------------------------------------------------------------
1083 PlotRemoveCurve(const SalomeApp_Module* theModule,
1084 VISU::Curve_i* pCrv)
1086 QString anEntry = pCrv->GetEntry().c_str();
1087 ViewManagerList pvm_list;
1088 theModule->getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
1089 ViewManagerList::Iterator pvm_it = pvm_list.begin();
1090 for( ; pvm_it != pvm_list.end(); pvm_it++ ){
1091 Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( *pvm_it );
1093 SPlot2d_Viewer* aSPlot2d = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
1095 Plot2d_ViewFrame* aPlot = aSPlot2d->getActiveViewFrame();
1097 QList<Plot2d_Curve*> clist;
1098 aPlot->getCurves( clist );
1099 for (int i = 0; i < clist.count(); i++) {
1100 if(SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>(clist[i]))
1101 if(plotCurve->hasIO() && (plotCurve->getIO()->getEntry() == anEntry))
1102 aPlot->eraseCurve(clist[i]);
1110 //------------------------------------------------------------
1112 PlotContainer(const SalomeApp_Module* theModule,
1113 VISU::Container_i* container,
1116 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1119 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1123 if ( theDisplaying == VISU::eDisplayOnly )
1125 QList<Plot2d_Curve*> clist;
1126 aPlot->getCurves( clist );
1127 if ( container->GetNbCurves() > 0 ) {
1128 int nbCurves = container->GetNbCurves();
1129 for ( int k = 1; k <= nbCurves; k++ ) {
1130 VISU::Curve_i* theCurve = container->GetCurve( k );
1131 if ( theCurve && theCurve->IsValid() ) {
1132 SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
1133 (aView->getCurveByIO(new SALOME_InteractiveObject(theCurve->GetEntry().c_str(), "", "")));
1135 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1137 if ( plotCurve && theDisplaying == VISU::eErase ) {
1138 clist.removeAll( plotCurve );
1144 if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
1147 qApp->processEvents();
1150 //------------------------------------------------------------
1152 CreatePlot(SalomeApp_Module* theModule,
1153 _PTR(SObject) theTableSO)
1155 if ( IsSObjectTable(theTableSO) ) {
1156 CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
1157 CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
1158 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1159 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1160 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1162 if ( pContainer && pTable ) {
1163 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
1164 CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
1165 if( !CORBA::is_nil( aNewCurve ) ) {
1166 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
1168 pContainer->AddCurve( pCrv->_this() );
1172 PlotContainer( theModule, pContainer, VISU::eDisplay );
1174 QString anEntry = pContainer->GetEntry().c_str();
1175 _PTR(Study) aStudy = theTableSO->GetStudy();
1176 _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.toLatin1().data());
1177 _PTR(SObject) aParentSO = aContainerSO->GetFather();
1178 UpdateObjBrowser(theModule,true,aParentSO);
1184 //************************************************************
1187 CreateMesh(VisuGUI* theModule,
1188 const Handle(SALOME_InteractiveObject)& theIO,
1189 SVTK_ViewWindow* theViewWindow)
1191 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
1192 //if (CheckLock(aStudy))
1195 _PTR(SObject) aResultSObj = aStudy->FindObjectID(theIO->getEntry());
1198 VISU::Result_var aResult;
1199 VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
1200 if (pResult == NULL)
1203 Storable::TRestoringMap aMap = Storable::GetStorableMap(aResultSObj);
1207 CORBA::Object_var aMesh;
1208 string aComment = Storable::FindValue(aMap,"myComment").toLatin1().data();
1209 string aMeshName = Storable::FindValue(aMap,"myMeshName").toLatin1().data();
1214 if (aComment == "ENTITY") {
1215 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
1216 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1217 aMesh = GetVisuGen(theModule)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1218 } else if (aComment == "FAMILY") {
1219 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
1220 string aFamilyName = Storable::FindValue(aMap,"myName").toLatin1().data();
1221 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1222 aMesh = GetVisuGen(theModule)->FamilyMeshOnEntity
1223 (aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1224 } else if (aComment == "GROUP") {
1225 string aGroupName = Storable::FindValue(aMap,"myName").toLatin1().data();
1226 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1227 aMesh = GetVisuGen(theModule)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1231 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1235 //QApplication::restoreOverrideCursor();
1236 VISU::Mesh_i* pPresent = NULL;
1237 if (!CORBA::is_nil(aMesh))
1238 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1239 if (pPresent == NULL) {
1240 SUIT_MessageBox::warning (GetDesktop(theModule),
1241 QObject::tr("WRN_VISU"),
1242 QObject::tr("ERR_CANT_BUILD_PRESENTATION") );
1246 if (theViewWindow) {
1252 if(GetResourceMgr()->booleanValue("VISU","display_only",false)){
1253 const VisuGUI* av = dynamic_cast<const VisuGUI*>(theModule);
1254 if(av)(const_cast<VisuGUI*>(av))->OnEraseAll();
1256 PublishMeshInView(theModule, pPresent, theViewWindow);
1257 if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
1258 SetFitAll(theViewWindow);
1262 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1265 } catch (std::runtime_error& exc) {
1267 SUIT_MessageBox::warning(GetDesktop(theModule), QObject::tr("WRN_VISU"),
1268 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
1272 UpdateObjBrowser(theModule, false, aResultSObj);
1274 theModule->application()->putInfo(QObject::tr("INF_DONE"));
1275 // Make "Save" button active
1276 theModule->getApp()->updateActions();
1280 // ========================================================================================
1281 // GetPrs3dList: find list of presentations for the given object
1282 // ========================================================================================
1283 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1284 const Handle(SALOME_InteractiveObject)& theIO)
1286 std::vector<VISU::Prs3d_i*> aList;
1287 if (!theIO.IsNull() && theIO->hasEntry()) {
1288 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1289 _PTR(SObject) aSObject = aCStudy->FindObjectID(theIO->getEntry());
1290 aList = GetPrs3dList(theModule, aSObject);
1295 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1296 _PTR(SObject) theObject)
1298 std::vector<VISU::Prs3d_i*> aList; int k = 0;
1302 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1304 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(theObject);
1305 if (!CORBA::is_nil(aCORBAObject)) {
1306 VISU::Base_var aVisuObj = VISU::Base::_narrow(aCORBAObject);
1307 if (!CORBA::is_nil(aVisuObj)) {
1308 VISU::VISUType aType = aVisuObj->GetType();
1310 case VISU::TSCALARMAP:
1311 case VISU::TISOSURFACES:
1312 case VISU::TDEFORMEDSHAPE:
1313 case VISU::TCUTPLANES:
1314 case VISU::TCUTLINES:
1315 case VISU::TVECTORS:
1316 case VISU::TSTREAMLINES:
1318 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1319 case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1322 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1323 if (aServant.in()) {
1324 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1326 aList[k] = aPrsObject;
1333 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1334 _PTR(SObject) aTimeStamp;
1335 anIter->Next(); // First is reference on support
1336 for (; anIter->More(); anIter->Next()) {
1337 aTimeStamp = anIter->Value();
1338 if (!aTimeStamp) continue;
1339 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1340 if (!aSubList.empty()) {
1341 int n = aSubList.size();
1343 for (int i = 0; i < n; i++) {
1344 aList[k] = aSubList[i];
1354 VISU::VISUType aType = VISU::Storable::SObject2Type(theObject);
1356 case VISU::TFIELD: {
1357 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1358 _PTR(SObject) aTimeStamp;
1359 anIter->Next(); // First is reference on support
1360 for (; anIter->More(); anIter->Next()) {
1361 aTimeStamp = anIter->Value();
1362 if (!aTimeStamp) continue;
1363 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1364 if (!aSubList.empty()) {
1365 int n = aSubList.size();
1367 for (int i = 0; i < n; i++) {
1368 aList[k] = aSubList[i];
1375 case VISU::TTIMESTAMP: {
1376 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1378 for (; anIter->More(); anIter->Next()) {
1379 aPrs = anIter->Value();
1380 if (!aPrs) continue;
1381 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
1382 if (!aSubList.empty()) {
1383 int n = aSubList.size();
1385 for (int i = 0; i < n; i++) {
1386 aList[k] = aSubList[i];
1397 //------------------------------------------------------------
1398 int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow)
1401 std::set<int> aIndexes;
1402 TViewToPrs3d aMap = theModule->getScalarBarsMap();
1403 TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(theViewWindow);
1404 if (aViewToPrsIter != aMap.end()) {
1405 TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
1406 for (; aPrsIter != (aViewToPrsIter->second).end(); aPrsIter++) {
1407 aIndexes.insert((*aPrsIter).second);
1410 std::set<int>::const_iterator aIter = aIndexes.begin();
1411 for (int i = 1,length = aIndexes.size(); i <= length; i++) {
1412 std::set<int>::const_iterator aIter = aIndexes.find(i);
1413 if (aIter == aIndexes.end()) { minIndx = i; break; }
1414 else minIndx = i + 1;
1419 //------------------------------------------------------------
1420 void AddScalarBarPosition (VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
1421 VISU::Prs3d_i* thePrs3d, int pos)
1423 TViewToPrs3d& aMap = theModule->getScalarBarsMap();
1424 TPrs3dToInd aPair; aPair.first = thePrs3d; aPair.second = pos;
1425 aMap[theViewWindow].insert(aPair);
1428 //------------------------------------------------------------
1429 void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
1430 VISU::Prs3d_i* thePrs3d)
1432 TViewToPrs3d& aMap = theModule->getScalarBarsMap();
1433 TSetPrs3d::iterator aIter = aMap[theViewWindow].begin();
1434 for (; aIter != aMap[theViewWindow].end(); aIter++)
1435 if ((*aIter).first == thePrs3d) {
1436 aMap[theViewWindow].erase(*aIter);
1440 //------------------------------------------------------------
1441 void initSpinBox( QSpinBox* spinBox,
1442 int min, int max, int step )
1444 spinBox->setRange( min, max );
1445 spinBox->setSingleStep( step );
1447 //------------------------------------------------------------
1448 void initSpinBox( QDoubleSpinBox* spinBox,
1449 double min, double max,
1450 double step, int decimals )
1452 spinBox->setRange( min, max );
1453 spinBox->setSingleStep( step );
1454 spinBox->setDecimals( decimals );
1456 //------------------------------------------------------------
1457 bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject)
1459 _PTR(SComponent) aVisuSO = theStudy->FindComponent("VISU");
1460 if (!aVisuSO) return false;
1461 _PTR(SObject) aFolder = theStudy->FindObject(CLIP_PLANES_FOLDER);
1463 _PTR(StudyBuilder) aBuilder = theStudy->NewBuilder();
1464 aFolder = aBuilder->NewObject(aVisuSO);
1466 _PTR(GenericAttribute) anAttr;
1467 anAttr = aBuilder->FindOrCreateAttribute(aFolder,"AttributeName");
1468 _PTR(AttributeName) aName(anAttr);
1469 aName->SetValue(CLIP_PLANES_FOLDER);
1471 theSObject = aFolder;