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);
598 if (anActor->IsShrunk())
601 anActor->SetShrink();
602 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
603 aMesh->SetShrink(true);
606 if (anActorBase->IsShrunk())
607 anActorBase->UnShrink();
609 anActorBase->SetShrink();
614 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
615 aMesh->SetPresentationType(theType);
616 RecreateActor(theModule, aMesh);
618 anActor->SetRepresentation(theType);
622 anActorBase->SetRepresentation(theType);
625 aViewWindow->Repaint();
628 //------------------------------------------------------------
630 SetShading ( const SalomeApp_Module* theModule,
633 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
634 if(aSelectionInfo.empty())
637 TSelectionItem aSelectionItem = GetSelectedObjects(theModule).front();
638 VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
642 SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
646 VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
650 if(VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor)){
651 aScalarMapActor->SetShading(theOn);
652 aViewWindow->Repaint();
656 //------------------------------------------------------------
659 CheckTimeStamp(const SalomeApp_Module* theModule,
660 _PTR(SObject)& theSObject,
661 Handle(SALOME_InteractiveObject)& theIO,
662 ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
664 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
665 if(!aSelectionInfo.empty()){
666 TSelectionItem aSelectionItem = aSelectionInfo.front();
667 theIO = aSelectionItem.myIO;
668 theSObject = aSelectionItem.myObjectInfo.mySObject;
669 VISU::VISUType aType = VISU::Storable::SObject2Type(theSObject);
670 if (VISU::TTIMESTAMP == aType){
671 thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
674 if (VISU::TFIELD == aType){
675 thePublishInStudyMode = ColoredPrs3d_i::EPublishIndependently;
676 if(theSObject->FindSubObject(2,theSObject))
680 SUIT_MessageBox::warning(GetDesktop(theModule),
681 QObject::tr("WRN_VISU"),
682 QObject::tr("WRN_NO_AVAILABLE_DATA") );
686 //------------------------------------------------------------
688 CheckResult(const SalomeApp_Module* theModule,
689 _PTR(SObject) theSource,
690 VISU::Result_var& theResult)
692 if(theSource->Depth() < 3) // Bug of SALOMEDS : can\t get father from root object
695 _PTR(SObject) aSObj = theSource->GetFather();
699 aSObj = aSObj->GetFather();
703 aSObj = aSObj->GetFather();
707 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
708 if (CORBA::is_nil(anObject)) {
709 aSObj = aSObj->GetFather();
712 anObject = VISU::ClientSObjectToObject(aSObj);
715 if (CORBA::is_nil(anObject))
718 theResult = VISU::Result::_narrow(anObject);
719 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
722 //------------------------------------------------------------
725 PublishMeshInView(const SalomeApp_Module* theModule,
726 VISU::Prs3d_i* thePrs,
727 SVTK_ViewWindow* theViewWindow)
729 VISU_Actor* aActor = NULL;
730 if (!thePrs || !theViewWindow)
733 QApplication::setOverrideCursor( Qt::WaitCursor );
735 if ((aActor = thePrs->CreateActor()))
736 theViewWindow->AddActor(aActor);
737 } catch(std::exception& exc) {
738 SUIT_MessageBox::warning
739 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
740 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
742 QApplication::restoreOverrideCursor();
747 //------------------------------------------------------------
749 RepaintViewWindows (const SalomeApp_Module* theModule,
750 const Handle(SALOME_InteractiveObject)& theIObject)
752 TViewWindows aViewWindows;
753 if (SalomeApp_Application* anApp = theModule->getApp()) {
754 ViewManagerList aViewManagerList;
755 anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
756 QList<SUIT_ViewManager*>::Iterator anIter = aViewManagerList.begin();
757 while ( anIter != aViewManagerList.end() )
759 QVector<SUIT_ViewWindow*> aViews = (*anIter)->getViews();
760 for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
761 if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
762 if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
763 if (vw->isVisible(theIObject)) {
764 vw->getRenderer()->ResetCameraClippingRange();
766 vw->highlight(theIObject, true, true);
776 //------------------------------------------------------------
778 FindActor(const SalomeApp_Study* theStudy,
779 SVTK_ViewWindow* theViewWindow,
780 const QString& theEntry)
782 TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().data());
783 VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
784 return FindActor(theViewWindow, aPrs3d);
787 //------------------------------------------------------------
789 FindActorBase(const SalomeApp_Study* theStudy,
790 SVTK_ViewWindow* theViewWindow,
791 const QString& theEntry)
793 TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().constData());
794 VISU::PointMap3d_i* aTable = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase);
795 return FindActorBase(theViewWindow, aTable);
798 //------------------------------------------------------------
800 RecreateActor (const SalomeApp_Module* theModule,
801 VISU::Prs3d_i* thePrs)
803 QApplication::setOverrideCursor(Qt::WaitCursor);
805 SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
806 CORBA::String_var anEntry = aSObject->GetID();
809 thePrs->UpdateActors();
810 } catch (std::runtime_error& exc) {
812 QApplication::restoreOverrideCursor();
813 SUIT_MessageBox::warning
814 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
815 QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()) );
817 thePrs->RemoveActors();
820 QApplication::restoreOverrideCursor();
823 //------------------------------------------------------------
825 ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
826 vtkFloatingPointType allBounds[6],
827 const char* theActorClassName)
829 vtkRenderer *aRen = theViewWindow->getRenderer();
830 vtkActorCollection *anActColl = aRen->GetActors();
832 vtkFloatingPointType *bounds;
833 int somethingVisible = false;
835 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
836 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
837 // loop through all props
838 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ) {
839 // if it's invisible, or has no geometry, we can skip the rest
840 if (prop->GetVisibility() && prop->IsA(theActorClassName)) {
841 bounds = prop->GetBounds();
842 // make sure we haven't got bogus bounds
843 if (bounds != NULL &&
844 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
845 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
846 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT)
848 somethingVisible = true;
849 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
850 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
851 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
852 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
853 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
854 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
858 return somethingVisible;
861 //------------------------------------------------------------
862 void SetFitAll(SVTK_ViewWindow* theViewWindow)
864 static vtkFloatingPointType PRECISION = 0.000001;
865 static vtkFloatingPointType DEVIATION = 600;
866 vtkFloatingPointType XYZ_Bnd[6];
867 if (!ComputeVisiblePropBounds(theViewWindow, XYZ_Bnd)) return;
869 vtkFloatingPointType absX = XYZ_Bnd[1] - XYZ_Bnd[0];
870 vtkFloatingPointType absY = XYZ_Bnd[3] - XYZ_Bnd[2];
871 vtkFloatingPointType absZ = XYZ_Bnd[5] - XYZ_Bnd[4];
873 enum CameraOrient {e3D, eFront, eLeft, eTop};
874 CameraOrient aCameraOrient = e3D;
875 if (absX <= PRECISION) aCameraOrient = eFront;
877 if (absY <= PRECISION) aCameraOrient = eLeft;
879 if (absZ <= PRECISION) aCameraOrient = eTop;
881 // all the three dimensions exceeds precision
882 vtkFloatingPointType dev_abs_XY = absX / absY;
883 vtkFloatingPointType dev_abs_YZ = absY / absZ;
884 vtkFloatingPointType dev_abs_XZ = absX / absZ;
885 if (dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION)
886 aCameraOrient = eLeft;
888 if (1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION)
889 aCameraOrient = eFront;
891 if (dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION)
892 aCameraOrient = eTop;
899 switch (aCameraOrient) {
900 case eFront: theViewWindow->onFrontView(); break;
901 case eLeft: theViewWindow->onLeftView(); break;
902 case eTop: theViewWindow->onTopView(); break;
903 case e3D: theViewWindow->onResetView(); break;
905 theViewWindow->getRenderer()->ResetCameraClippingRange();
906 theViewWindow->onFitAll();
909 //************************************************************
913 GetPlot2dViewer(const SalomeApp_Module* theModule, const bool theCreate)
915 if(SalomeApp_Application* anApp = theModule->getApp()){
916 if(SUIT_ViewManager* aViewManager = anApp->getViewManager( Plot2d_Viewer::Type(), theCreate )){
917 return dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
923 //------------------------------------------------------------
924 // Internal function used by several public functions below
926 UpdateCurve(VISU::Curve_i* theCurve,
927 Plot2d_ViewFrame* aPlot,
928 SPlot2d_Curve* plotCurve,
931 if ( theDisplaying == VISU::eErase ) {
932 if ( plotCurve && aPlot )
933 aPlot->eraseCurve( plotCurve, false );
935 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
937 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
938 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
939 plotCurve->setVerTitle( theCurve->GetName().c_str() );
940 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
941 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
945 int nbPoints = theCurve->GetData( xList, yList, zList );
946 if ( nbPoints > 0 && xList && yList ) {
947 plotCurve->setData( xList, yList, nbPoints, zList );
949 if ( !theCurve->IsAuto() ) {
950 plotCurve->setLine( (Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
951 plotCurve->setMarker( (Plot2d::MarkerType)theCurve->GetMarker() );
952 SALOMEDS::Color color = theCurve->GetColor();
953 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
955 plotCurve->setAutoAssign( theCurve->IsAuto() );
957 aPlot->displayCurve( plotCurve, false );
960 Plot2d_Curve* crv = theCurve->CreatePresentation();
963 aPlot->displayCurve( crv, false );
964 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
965 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
966 SALOMEDS::Color newColor;
967 newColor.R = crv->getColor().red()/255.;
968 newColor.G = crv->getColor().green()/255.;
969 newColor.B = crv->getColor().blue()/255.;
970 theCurve->SetColor( newColor );
971 crv->setAutoAssign( theCurve->IsAuto() );
977 //------------------------------------------------------------
979 PlotTable(const SalomeApp_Module* theModule,
980 VISU::Table_i* table,
983 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true ); // create if necessary
986 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
990 if ( theDisplaying == VISU::eDisplayOnly )
992 QList<Plot2d_Curve*> clist;
993 aPlot->getCurves( clist );
994 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
995 _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
997 _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
998 for ( ; Iter->More(); Iter->Next() ) {
999 CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
1000 if( !CORBA::is_nil( childObject ) ) {
1001 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1002 if( !CORBA::is_nil( aCurve ) ) {
1003 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1004 SPlot2d_Curve* plotCurve = 0;
1005 SPlot2d_Curve* tmpCurve;
1006 for ( int i = 0; i < clist.count(); i++ ) {
1007 tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
1008 if (tmpCurve && tmpCurve->hasIO() &&
1009 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1010 plotCurve = tmpCurve;
1015 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1017 if ( theDisplaying == VISU::eErase && plotCurve ) {
1018 clist.removeAll(plotCurve );
1027 //------------------------------------------------------------
1029 PlotCurve(const SalomeApp_Module* theModule,
1030 VISU::Curve_i* theCurve,
1033 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1036 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1040 // if ( theDisplaying == VISU::eDisplayOnly )
1041 // aPlot->EraseAll();
1042 QList<Plot2d_Curve*> clist;
1043 aPlot->getCurves( clist );
1044 SPlot2d_Curve* plotCurve = 0;
1045 SPlot2d_Curve* tmpCurve;
1046 if(theDisplaying == VISU::eErase) {
1047 // 23.06.2008 skl for IPAL17672
1048 for (int i = 0; i < clist.count(); i++) {
1049 tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
1050 if (tmpCurve && tmpCurve->hasIO() &&
1051 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1052 plotCurve = tmpCurve;
1053 aPlot->eraseCurve(clist.at(i));
1057 UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
1060 for (int i = 0; i < clist.count(); i++) {
1061 tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
1062 if (tmpCurve && tmpCurve->hasIO() &&
1063 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1064 plotCurve = tmpCurve;
1066 else if (theDisplaying == VISU::eDisplayOnly) {
1067 aPlot->eraseCurve(clist.at(i));
1070 UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
1076 //------------------------------------------------------------
1078 PlotRemoveCurve(const SalomeApp_Module* theModule,
1079 VISU::Curve_i* pCrv)
1081 QString anEntry = pCrv->GetEntry().c_str();
1082 ViewManagerList pvm_list;
1083 theModule->getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
1084 ViewManagerList::Iterator pvm_it = pvm_list.begin();
1085 for( ; pvm_it != pvm_list.end(); pvm_it++ ){
1086 Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( *pvm_it );
1088 SPlot2d_Viewer* aSPlot2d = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
1090 Plot2d_ViewFrame* aPlot = aSPlot2d->getActiveViewFrame();
1092 QList<Plot2d_Curve*> clist;
1093 aPlot->getCurves( clist );
1094 for (int i = 0; i < clist.count(); i++) {
1095 if(SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>(clist[i]))
1096 if(plotCurve->hasIO() && (plotCurve->getIO()->getEntry() == anEntry))
1097 aPlot->eraseCurve(clist[i]);
1105 //------------------------------------------------------------
1107 PlotContainer(const SalomeApp_Module* theModule,
1108 VISU::Container_i* container,
1111 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1114 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1118 if ( theDisplaying == VISU::eDisplayOnly )
1120 QList<Plot2d_Curve*> clist;
1121 aPlot->getCurves( clist );
1122 if ( container->GetNbCurves() > 0 ) {
1123 int nbCurves = container->GetNbCurves();
1124 for ( int k = 1; k <= nbCurves; k++ ) {
1125 VISU::Curve_i* theCurve = container->GetCurve( k );
1126 if ( theCurve && theCurve->IsValid() ) {
1127 SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
1128 (aView->getCurveByIO(new SALOME_InteractiveObject(theCurve->GetEntry().c_str(), "", "")));
1130 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1132 if ( plotCurve && theDisplaying == VISU::eErase ) {
1133 clist.removeAll( plotCurve );
1139 if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
1142 qApp->processEvents();
1145 //------------------------------------------------------------
1147 CreatePlot(SalomeApp_Module* theModule,
1148 _PTR(SObject) theTableSO)
1150 if ( IsSObjectTable(theTableSO) ) {
1151 CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
1152 CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
1153 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1154 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1155 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1157 if ( pContainer && pTable ) {
1158 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
1159 CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
1160 if( !CORBA::is_nil( aNewCurve ) ) {
1161 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
1163 pContainer->AddCurve( pCrv->_this() );
1167 PlotContainer( theModule, pContainer, VISU::eDisplay );
1169 QString anEntry = pContainer->GetEntry().c_str();
1170 _PTR(Study) aStudy = theTableSO->GetStudy();
1171 _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.toLatin1().data());
1172 _PTR(SObject) aParentSO = aContainerSO->GetFather();
1173 UpdateObjBrowser(theModule,true,aParentSO);
1179 //************************************************************
1182 CreateMesh(VisuGUI* theModule,
1183 const Handle(SALOME_InteractiveObject)& theIO,
1184 SVTK_ViewWindow* theViewWindow)
1186 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
1187 //if (CheckLock(aStudy))
1190 _PTR(SObject) aResultSObj = aStudy->FindObjectID(theIO->getEntry());
1193 VISU::Result_var aResult;
1194 VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
1195 if (pResult == NULL)
1198 Storable::TRestoringMap aMap = Storable::GetStorableMap(aResultSObj);
1202 CORBA::Object_var aMesh;
1203 string aComment = Storable::FindValue(aMap,"myComment").toLatin1().data();
1204 string aMeshName = Storable::FindValue(aMap,"myMeshName").toLatin1().data();
1209 if (aComment == "ENTITY") {
1210 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
1211 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1212 aMesh = GetVisuGen(theModule)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1213 } else if (aComment == "FAMILY") {
1214 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
1215 string aFamilyName = Storable::FindValue(aMap,"myName").toLatin1().data();
1216 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1217 aMesh = GetVisuGen(theModule)->FamilyMeshOnEntity
1218 (aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1219 } else if (aComment == "GROUP") {
1220 string aGroupName = Storable::FindValue(aMap,"myName").toLatin1().data();
1221 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1222 aMesh = GetVisuGen(theModule)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1226 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1230 //QApplication::restoreOverrideCursor();
1231 VISU::Mesh_i* pPresent = NULL;
1232 if (!CORBA::is_nil(aMesh))
1233 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1234 if (pPresent == NULL) {
1235 SUIT_MessageBox::warning (GetDesktop(theModule),
1236 QObject::tr("WRN_VISU"),
1237 QObject::tr("ERR_CANT_BUILD_PRESENTATION") );
1241 if (theViewWindow) {
1247 if(GetResourceMgr()->booleanValue("VISU","display_only",false)){
1248 const VisuGUI* av = dynamic_cast<const VisuGUI*>(theModule);
1249 if(av)(const_cast<VisuGUI*>(av))->OnEraseAll();
1251 PublishMeshInView(theModule, pPresent, theViewWindow);
1252 if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
1253 SetFitAll(theViewWindow);
1257 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1260 } catch (std::runtime_error& exc) {
1262 SUIT_MessageBox::warning(GetDesktop(theModule), QObject::tr("WRN_VISU"),
1263 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
1267 UpdateObjBrowser(theModule, false, aResultSObj);
1269 theModule->application()->putInfo(QObject::tr("INF_DONE"));
1270 // Make "Save" button active
1271 theModule->getApp()->updateActions();
1275 // ========================================================================================
1276 // GetPrs3dList: find list of presentations for the given object
1277 // ========================================================================================
1278 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1279 const Handle(SALOME_InteractiveObject)& theIO)
1281 std::vector<VISU::Prs3d_i*> aList;
1282 if (!theIO.IsNull() && theIO->hasEntry()) {
1283 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1284 _PTR(SObject) aSObject = aCStudy->FindObjectID(theIO->getEntry());
1285 aList = GetPrs3dList(theModule, aSObject);
1290 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1291 _PTR(SObject) theObject)
1293 std::vector<VISU::Prs3d_i*> aList; int k = 0;
1297 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1299 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(theObject);
1300 if (!CORBA::is_nil(aCORBAObject)) {
1301 VISU::Base_var aVisuObj = VISU::Base::_narrow(aCORBAObject);
1302 if (!CORBA::is_nil(aVisuObj)) {
1303 VISU::VISUType aType = aVisuObj->GetType();
1305 case VISU::TSCALARMAP:
1306 case VISU::TISOSURFACES:
1307 case VISU::TDEFORMEDSHAPE:
1308 case VISU::TCUTPLANES:
1309 case VISU::TCUTLINES:
1310 case VISU::TVECTORS:
1311 case VISU::TSTREAMLINES:
1313 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1314 case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1317 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1318 if (aServant.in()) {
1319 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1321 aList[k] = aPrsObject;
1328 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1329 _PTR(SObject) aTimeStamp;
1330 anIter->Next(); // First is reference on support
1331 for (; anIter->More(); anIter->Next()) {
1332 aTimeStamp = anIter->Value();
1333 if (!aTimeStamp) continue;
1334 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1335 if (!aSubList.empty()) {
1336 int n = aSubList.size();
1338 for (int i = 0; i < n; i++) {
1339 aList[k] = aSubList[i];
1349 VISU::VISUType aType = VISU::Storable::SObject2Type(theObject);
1351 case VISU::TFIELD: {
1352 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1353 _PTR(SObject) aTimeStamp;
1354 anIter->Next(); // First is reference on support
1355 for (; anIter->More(); anIter->Next()) {
1356 aTimeStamp = anIter->Value();
1357 if (!aTimeStamp) continue;
1358 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1359 if (!aSubList.empty()) {
1360 int n = aSubList.size();
1362 for (int i = 0; i < n; i++) {
1363 aList[k] = aSubList[i];
1370 case VISU::TTIMESTAMP: {
1371 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1373 for (; anIter->More(); anIter->Next()) {
1374 aPrs = anIter->Value();
1375 if (!aPrs) continue;
1376 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
1377 if (!aSubList.empty()) {
1378 int n = aSubList.size();
1380 for (int i = 0; i < n; i++) {
1381 aList[k] = aSubList[i];
1392 //------------------------------------------------------------
1393 int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow)
1396 std::set<int> aIndexes;
1397 TViewToPrs3d aMap = theModule->getScalarBarsMap();
1398 TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(theViewWindow);
1399 if (aViewToPrsIter != aMap.end()) {
1400 TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
1401 for (; aPrsIter != (aViewToPrsIter->second).end(); aPrsIter++) {
1402 aIndexes.insert((*aPrsIter).second);
1405 std::set<int>::const_iterator aIter = aIndexes.begin();
1406 for (int i = 1,length = aIndexes.size(); i <= length; i++) {
1407 std::set<int>::const_iterator aIter = aIndexes.find(i);
1408 if (aIter == aIndexes.end()) { minIndx = i; break; }
1409 else minIndx = i + 1;
1414 //------------------------------------------------------------
1415 void AddScalarBarPosition (VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
1416 VISU::Prs3d_i* thePrs3d, int pos)
1418 TViewToPrs3d& aMap = theModule->getScalarBarsMap();
1419 TPrs3dToInd aPair; aPair.first = thePrs3d; aPair.second = pos;
1420 aMap[theViewWindow].insert(aPair);
1423 //------------------------------------------------------------
1424 void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
1425 VISU::Prs3d_i* thePrs3d)
1427 TViewToPrs3d& aMap = theModule->getScalarBarsMap();
1428 TSetPrs3d::iterator aIter = aMap[theViewWindow].begin();
1429 for (; aIter != aMap[theViewWindow].end(); aIter++)
1430 if ((*aIter).first == thePrs3d) {
1431 aMap[theViewWindow].erase(*aIter);
1435 //------------------------------------------------------------
1436 void initSpinBox( QSpinBox* spinBox,
1437 int min, int max, int step )
1439 spinBox->setRange( min, max );
1440 spinBox->setSingleStep( step );
1442 //------------------------------------------------------------
1443 void initSpinBox( QDoubleSpinBox* spinBox,
1444 double min, double max,
1445 double step, int decimals )
1447 spinBox->setRange( min, max );
1448 spinBox->setSingleStep( step );
1449 spinBox->setDecimals( decimals );
1451 //------------------------------------------------------------
1452 bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject)
1454 _PTR(SComponent) aVisuSO = theStudy->FindComponent("VISU");
1455 if (!aVisuSO) return false;
1456 _PTR(SObject) aFolder = theStudy->FindObject(CLIP_PLANES_FOLDER);
1458 _PTR(StudyBuilder) aBuilder = theStudy->NewBuilder();
1459 aFolder = aBuilder->NewObject(aVisuSO);
1461 _PTR(GenericAttribute) anAttr;
1462 anAttr = aBuilder->FindOrCreateAttribute(aFolder,"AttributeName");
1463 _PTR(AttributeName) aName(anAttr);
1464 aName->SetValue(CLIP_PLANES_FOLDER);
1466 theSObject = aFolder;