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 && theModule->application() ? theModule->application()->desktop() : 0;
92 //------------------------------------------------------------
93 LightApp_SelectionMgr*
94 GetSelectionMgr(const SalomeApp_Module* theModule)
96 return theModule && theModule->getApp() ? theModule->getApp()->selectionMgr() : 0;
99 //------------------------------------------------------------
101 GetAppStudy(const CAM_Module* theModule)
103 return theModule && theModule->application() ?
104 dynamic_cast<SalomeApp_Study*>(theModule->application()->activeStudy()) : 0;
107 //------------------------------------------------------------
109 GetCStudy(const SalomeApp_Study* theStudy)
111 return theStudy ? theStudy->studyDS() : _PTR(Study)();
114 //------------------------------------------------------------
116 IsStudyLocked( _PTR(Study) theStudy )
118 return theStudy ? theStudy->GetProperties()->IsLocked() : true;
121 //------------------------------------------------------------
123 CheckLock( _PTR(Study) theStudy,
126 if(IsStudyLocked(theStudy)){
127 SUIT_MessageBox::warning(theWidget,
128 QObject::tr("WRN_VISU_WARNING"),
129 QObject::tr("WRN_STUDY_LOCKED") );
135 //------------------------------------------------------------
137 runAndWait( QDialog* dlg, const bool modal )
139 VisuGUI_DialogRunner r( dlg );
140 return r.run( modal );
143 //------------------------------------------------------------
145 FindDataObject(SUIT_DataObject* theDataObject,
146 const QString& theEntry,
149 int aLevel = theDataObject->level() + 2;
150 QString aSourceEntry = theEntry.section(':',0,aLevel);
151 DataObjectList aList;
152 theDataObject->children(aList);
153 DataObjectList::Iterator aDataObjectIter = aList.begin();
154 while( aDataObjectIter!= aList.end() ) {
155 if(LightApp_DataObject* aChildDataObject = dynamic_cast<LightApp_DataObject*>(*aDataObjectIter)){
156 QString anEntry = aChildDataObject->entry();
157 QString aCurrentEntry = anEntry.section(':',0,aLevel);
158 if(aSourceEntry == aCurrentEntry){
159 if(theLevel == aLevel){
160 return aChildDataObject;
162 return FindDataObject(aChildDataObject,theEntry,theLevel);
171 //------------------------------------------------------------
173 FindDataObject(CAM_Module* theModule,
174 _PTR(SObject) theSObject)
176 CAM_DataModel* aDataModel = theModule->dataModel();
177 CAM_DataObject* aRootDataObject = aDataModel->root();
178 if(_PTR(SComponent) aComponent = theSObject)
179 return dynamic_cast<LightApp_DataObject*>(aRootDataObject);
181 int aLevel = theSObject->Depth();
182 std::string anEntry = theSObject->GetID();
183 return FindDataObject(aRootDataObject,anEntry.c_str(),aLevel);
186 //------------------------------------------------------------
188 UpdateObjBrowser(SalomeApp_Module* theModule,
189 bool theIsUpdateDataModel,
190 _PTR(SObject) theSObject)
192 LightApp_DataObject* aDataObject = NULL;
194 aDataObject = FindDataObject(theModule,theSObject);
196 theModule->updateObjBrowser(theIsUpdateDataModel,aDataObject);
197 theModule->getApp()->updateActions();
200 //------------------------------------------------------------
202 IsSObjectTable( _PTR(SObject) theSObject )
205 _PTR(GenericAttribute) anAttr;
206 if (theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
208 if (theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
214 //------------------------------------------------------------
216 GetVisuGen(const CAM_Module* theModule)
218 static VISU_Gen_i* aGen = NULL;
220 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
221 Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","VISU");
222 VISU_Gen_var aVISU = VISU_Gen::_narrow(aComponent);
223 if(!CORBA::is_nil(aVISU)){
224 if((aGen = VISU_Gen_i::GetVisuGenImpl()))
225 aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
229 throw std::runtime_error(QObject::tr("ERR_CANT_FIND_VISU_COMPONENT").toLatin1().data());
233 //------------------------------------------------------------
234 SALOME_MED::MED_Gen_var
237 static SALOME_MED::MED_Gen_var aGen;
238 if(CORBA::is_nil(aGen)){
239 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
240 Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
241 aGen = SALOME_MED::MED_Gen::_narrow(aComponent);
243 if(CORBA::is_nil(aGen))
244 throw std::runtime_error(QObject::tr("ERR_CANT_FIND_MED_COMPONENT").toLatin1().data());
249 //----------------------------------------------------------------------------
252 GetSelectedObjects(const SalomeApp_Module* theModule)
254 TSelectionInfo aSelectionInfo;
255 const SalomeApp_Study* aStudy = GetAppStudy(theModule);
256 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
257 if ( aStudy && aSelectionMgr ) {
258 SALOME_ListIO aListIO;
259 aSelectionMgr->selectedObjects(aListIO);
260 SALOME_ListIteratorOfListIO anIter(aListIO);
263 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
266 TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
267 if(anObjectInfo.mySObject){
268 TSelectionItem aSelectionItem;
269 aSelectionItem.myObjectInfo = anObjectInfo;
270 aSelectionItem.myIO = anIO;
271 aSelectionInfo.push_back(aSelectionItem);
274 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();
634 void ChangeQuadratic2DRepresentation (const SalomeApp_Module* theModule,
635 VISU::Quadratic2DPresentationType theType)
637 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
638 if(aSelectionInfo.empty())
641 TSelectionItem aSelectionItem = aSelectionInfo.front();
643 VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
645 SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
647 if(!aPrs3d || !aViewWindow)
650 VISU_Actor *anActor = FindActor(aViewWindow, aPrs3d);
654 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
655 aMesh->SetQuadratic2DPresentationType(theType);
656 RecreateActor(theModule, aMesh);
660 anActor->SetQuadratic2DRepresentation(VISU_Actor::eLines);
663 anActor->SetQuadratic2DRepresentation(VISU_Actor::eArcs);
671 //------------------------------------------------------------
673 SetShading ( const SalomeApp_Module* theModule,
676 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
677 if(aSelectionInfo.empty())
680 TSelectionItem aSelectionItem = GetSelectedObjects(theModule).front();
681 VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
685 SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
689 VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
693 if(VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor)){
694 aScalarMapActor->SetShading(theOn);
695 aViewWindow->Repaint();
699 //------------------------------------------------------------
702 CheckTimeStamp(const SalomeApp_Module* theModule,
703 _PTR(SObject)& theSObject,
704 Handle(SALOME_InteractiveObject)& theIO,
705 ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
707 TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
708 if(!aSelectionInfo.empty()){
709 TSelectionItem aSelectionItem = aSelectionInfo.front();
710 theIO = aSelectionItem.myIO;
711 theSObject = aSelectionItem.myObjectInfo.mySObject;
712 VISU::VISUType aType = VISU::Storable::SObject2Type(theSObject);
713 if (VISU::TTIMESTAMP == aType){
714 thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
717 if (VISU::TFIELD == aType){
718 thePublishInStudyMode = ColoredPrs3d_i::EPublishIndependently;
719 if(theSObject->FindSubObject(2,theSObject))
723 SUIT_MessageBox::warning(GetDesktop(theModule),
724 QObject::tr("WRN_VISU"),
725 QObject::tr("WRN_NO_AVAILABLE_DATA") );
729 //------------------------------------------------------------
731 CheckResult(const SalomeApp_Module* theModule,
732 _PTR(SObject) theSource,
733 VISU::Result_var& theResult)
735 if(theSource->Depth() < 3) // Bug of SALOMEDS : can\t get father from root object
738 _PTR(SObject) aSObj = theSource->GetFather();
742 aSObj = aSObj->GetFather();
746 aSObj = aSObj->GetFather();
750 CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObj);
751 if (CORBA::is_nil(anObject)) {
752 aSObj = aSObj->GetFather();
755 anObject = VISU::ClientSObjectToObject(aSObj);
758 if (CORBA::is_nil(anObject))
761 theResult = VISU::Result::_narrow(anObject);
762 return dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
765 //------------------------------------------------------------
768 PublishMeshInView(const SalomeApp_Module* theModule,
769 VISU::Prs3d_i* thePrs,
770 SVTK_ViewWindow* theViewWindow)
772 VISU_Actor* aActor = NULL;
773 if (!thePrs || !theViewWindow)
776 QApplication::setOverrideCursor( Qt::WaitCursor );
778 if ((aActor = thePrs->CreateActor()))
779 theViewWindow->AddActor(aActor);
780 } catch(std::exception& exc) {
781 SUIT_MessageBox::warning
782 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
783 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
785 QApplication::restoreOverrideCursor();
790 //------------------------------------------------------------
792 RepaintViewWindows (const SalomeApp_Module* theModule,
793 const Handle(SALOME_InteractiveObject)& theIObject)
795 TViewWindows aViewWindows;
796 if (SalomeApp_Application* anApp = theModule->getApp()) {
797 ViewManagerList aViewManagerList;
798 anApp->viewManagers(SVTK_Viewer::Type(),aViewManagerList);
799 QList<SUIT_ViewManager*>::Iterator anIter = aViewManagerList.begin();
800 while ( anIter != aViewManagerList.end() )
802 QVector<SUIT_ViewWindow*> aViews = (*anIter)->getViews();
803 for (int i = 0, iEnd = aViews.size(); i < iEnd; i++) {
804 if (SUIT_ViewWindow* aViewWindow = aViews.at(i)) {
805 if (SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
806 if (vw->isVisible(theIObject)) {
807 vw->getRenderer()->ResetCameraClippingRange();
809 vw->highlight(theIObject, true, true);
819 //------------------------------------------------------------
821 FindActor(const SalomeApp_Study* theStudy,
822 SVTK_ViewWindow* theViewWindow,
823 const QString& theEntry)
825 TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().data());
826 VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
827 return FindActor(theViewWindow, aPrs3d);
830 //------------------------------------------------------------
832 FindActorBase(const SalomeApp_Study* theStudy,
833 SVTK_ViewWindow* theViewWindow,
834 const QString& theEntry)
836 TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry.toLatin1().constData());
837 VISU::PointMap3d_i* aTable = dynamic_cast<VISU::PointMap3d_i*>(anObjectInfo.myBase);
838 return FindActorBase(theViewWindow, aTable);
841 //------------------------------------------------------------
843 RecreateActor (const SalomeApp_Module* theModule,
844 VISU::Prs3d_i* thePrs)
846 QApplication::setOverrideCursor(Qt::WaitCursor);
848 SALOMEDS::SObject_var aSObject = thePrs->GetSObject();
849 CORBA::String_var anEntry = aSObject->GetID();
852 thePrs->UpdateActors();
853 } catch (std::runtime_error& exc) {
855 QApplication::restoreOverrideCursor();
856 SUIT_MessageBox::warning
857 (GetDesktop(theModule), QObject::tr("WRN_VISU"),
858 QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(exc.what()) );
860 thePrs->RemoveActors();
863 QApplication::restoreOverrideCursor();
866 //------------------------------------------------------------
868 ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow,
869 vtkFloatingPointType allBounds[6],
870 const char* theActorClassName)
872 vtkRenderer *aRen = theViewWindow->getRenderer();
873 vtkActorCollection *anActColl = aRen->GetActors();
875 vtkFloatingPointType *bounds;
876 int somethingVisible = false;
878 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
879 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
880 // loop through all props
881 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ) {
882 // if it's invisible, or has no geometry, we can skip the rest
883 if (prop->GetVisibility() && prop->IsA(theActorClassName)) {
884 bounds = prop->GetBounds();
885 // make sure we haven't got bogus bounds
886 if (bounds != NULL &&
887 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
888 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
889 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT)
891 somethingVisible = true;
892 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
893 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
894 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
895 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
896 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
897 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
901 return somethingVisible;
904 //------------------------------------------------------------
905 void SetFitAll(SVTK_ViewWindow* theViewWindow)
907 static vtkFloatingPointType PRECISION = 0.000001;
908 static vtkFloatingPointType DEVIATION = 600;
909 vtkFloatingPointType XYZ_Bnd[6];
910 if (!ComputeVisiblePropBounds(theViewWindow, XYZ_Bnd)) return;
912 vtkFloatingPointType absX = XYZ_Bnd[1] - XYZ_Bnd[0];
913 vtkFloatingPointType absY = XYZ_Bnd[3] - XYZ_Bnd[2];
914 vtkFloatingPointType absZ = XYZ_Bnd[5] - XYZ_Bnd[4];
916 enum CameraOrient {e3D, eFront, eLeft, eTop};
917 CameraOrient aCameraOrient = e3D;
918 if (absX <= PRECISION) aCameraOrient = eFront;
920 if (absY <= PRECISION) aCameraOrient = eLeft;
922 if (absZ <= PRECISION) aCameraOrient = eTop;
924 // all the three dimensions exceeds precision
925 vtkFloatingPointType dev_abs_XY = absX / absY;
926 vtkFloatingPointType dev_abs_YZ = absY / absZ;
927 vtkFloatingPointType dev_abs_XZ = absX / absZ;
928 if (dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION)
929 aCameraOrient = eLeft;
931 if (1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION)
932 aCameraOrient = eFront;
934 if (dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION)
935 aCameraOrient = eTop;
942 switch (aCameraOrient) {
943 case eFront: theViewWindow->onFrontView(); break;
944 case eLeft: theViewWindow->onLeftView(); break;
945 case eTop: theViewWindow->onTopView(); break;
946 case e3D: theViewWindow->onResetView(); break;
948 theViewWindow->getRenderer()->ResetCameraClippingRange();
949 theViewWindow->onFitAll();
952 //************************************************************
956 GetPlot2dViewer(const SalomeApp_Module* theModule, const bool theCreate)
958 if(SalomeApp_Application* anApp = theModule->getApp()){
959 if(SUIT_ViewManager* aViewManager = anApp->getViewManager( Plot2d_Viewer::Type(), theCreate )){
960 return dynamic_cast<SPlot2d_Viewer*>(aViewManager->getViewModel());
966 //------------------------------------------------------------
967 // Internal function used by several public functions below
969 UpdateCurve(VISU::Curve_i* theCurve,
970 Plot2d_ViewFrame* aPlot,
971 SPlot2d_Curve* plotCurve,
974 if ( theDisplaying == VISU::eErase ) {
975 if ( plotCurve && aPlot )
976 aPlot->eraseCurve( plotCurve, false );
978 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
980 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
981 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
982 plotCurve->setVerTitle( theCurve->GetName().c_str() );
983 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
984 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
988 int nbPoints = theCurve->GetData( xList, yList, zList );
989 if ( nbPoints > 0 && xList && yList ) {
990 plotCurve->setData( xList, yList, nbPoints, zList );
992 if ( !theCurve->IsAuto() ) {
993 plotCurve->setLine( (Plot2d::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
994 plotCurve->setMarker( (Plot2d::MarkerType)theCurve->GetMarker() );
995 SALOMEDS::Color color = theCurve->GetColor();
996 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
998 plotCurve->setAutoAssign( theCurve->IsAuto() );
1000 aPlot->displayCurve( plotCurve, false );
1003 Plot2d_Curve* crv = theCurve->CreatePresentation();
1006 aPlot->displayCurve( crv, false );
1007 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1008 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1009 SALOMEDS::Color newColor;
1010 newColor.R = crv->getColor().red()/255.;
1011 newColor.G = crv->getColor().green()/255.;
1012 newColor.B = crv->getColor().blue()/255.;
1013 theCurve->SetColor( newColor );
1014 crv->setAutoAssign( theCurve->IsAuto() );
1020 //------------------------------------------------------------
1022 PlotTable(const SalomeApp_Module* theModule,
1023 VISU::Table_i* table,
1026 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true ); // create if necessary
1029 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1033 if ( theDisplaying == VISU::eDisplayOnly )
1035 QList<Plot2d_Curve*> clist;
1036 aPlot->getCurves( clist );
1037 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
1038 _PTR(SObject) TableSO = aStudy->FindObjectID( table->GetEntry() );
1040 _PTR(ChildIterator) Iter = aStudy->NewChildIterator( TableSO );
1041 for ( ; Iter->More(); Iter->Next() ) {
1042 CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() );
1043 if( !CORBA::is_nil( childObject ) ) {
1044 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1045 if( !CORBA::is_nil( aCurve ) ) {
1046 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1047 SPlot2d_Curve* plotCurve = 0;
1048 SPlot2d_Curve* tmpCurve;
1049 for ( int i = 0; i < clist.count(); i++ ) {
1050 tmpCurve = dynamic_cast<SPlot2d_Curve*>( clist.at( i ) );
1051 if (tmpCurve && tmpCurve->hasIO() &&
1052 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1053 plotCurve = tmpCurve;
1058 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1060 if ( theDisplaying == VISU::eErase && plotCurve ) {
1061 clist.removeAll(plotCurve );
1070 //------------------------------------------------------------
1072 PlotCurve(const SalomeApp_Module* theModule,
1073 VISU::Curve_i* theCurve,
1076 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1079 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1083 // if ( theDisplaying == VISU::eDisplayOnly )
1084 // aPlot->EraseAll();
1085 QList<Plot2d_Curve*> clist;
1086 aPlot->getCurves( clist );
1087 SPlot2d_Curve* plotCurve = 0;
1088 SPlot2d_Curve* tmpCurve;
1089 if(theDisplaying == VISU::eErase) {
1090 // 23.06.2008 skl for IPAL17672
1091 for (int i = 0; i < clist.count(); i++) {
1092 tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
1093 if (tmpCurve && tmpCurve->hasIO() &&
1094 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1095 plotCurve = tmpCurve;
1096 aPlot->eraseCurve(clist.at(i));
1100 UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
1103 for (int i = 0; i < clist.count(); i++) {
1104 tmpCurve = dynamic_cast<SPlot2d_Curve*>(clist.at(i));
1105 if (tmpCurve && tmpCurve->hasIO() &&
1106 theCurve->GetEntry() == tmpCurve->getIO()->getEntry()) {
1107 plotCurve = tmpCurve;
1109 else if (theDisplaying == VISU::eDisplayOnly) {
1110 aPlot->eraseCurve(clist.at(i));
1113 UpdateCurve(theCurve, aPlot, plotCurve, theDisplaying);
1119 //------------------------------------------------------------
1121 PlotRemoveCurve(const SalomeApp_Module* theModule,
1122 VISU::Curve_i* pCrv)
1124 QString anEntry = pCrv->GetEntry().c_str();
1125 ViewManagerList pvm_list;
1126 theModule->getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
1127 ViewManagerList::Iterator pvm_it = pvm_list.begin();
1128 for( ; pvm_it != pvm_list.end(); pvm_it++ ){
1129 Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( *pvm_it );
1131 SPlot2d_Viewer* aSPlot2d = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
1133 Plot2d_ViewFrame* aPlot = aSPlot2d->getActiveViewFrame();
1135 QList<Plot2d_Curve*> clist;
1136 aPlot->getCurves( clist );
1137 for (int i = 0; i < clist.count(); i++) {
1138 if(SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>(clist[i]))
1139 if(plotCurve->hasIO() && (plotCurve->getIO()->getEntry() == anEntry))
1140 aPlot->eraseCurve(clist[i]);
1148 //------------------------------------------------------------
1150 PlotContainer(const SalomeApp_Module* theModule,
1151 VISU::Container_i* container,
1154 SPlot2d_Viewer* aView = GetPlot2dViewer( theModule, true );
1157 Plot2d_ViewFrame* aPlot = aView->getActiveViewFrame();
1161 if ( theDisplaying == VISU::eDisplayOnly )
1163 QList<Plot2d_Curve*> clist;
1164 aPlot->getCurves( clist );
1165 if ( container->GetNbCurves() > 0 ) {
1166 int nbCurves = container->GetNbCurves();
1167 for ( int k = 1; k <= nbCurves; k++ ) {
1168 VISU::Curve_i* theCurve = container->GetCurve( k );
1169 if ( theCurve && theCurve->IsValid() ) {
1170 SPlot2d_Curve* plotCurve = dynamic_cast<SPlot2d_Curve*>
1171 (aView->getCurveByIO(new SALOME_InteractiveObject(theCurve->GetEntry().c_str(), "", "")));
1173 UpdateCurve( theCurve, aPlot, plotCurve, theDisplaying );
1175 if ( plotCurve && theDisplaying == VISU::eErase ) {
1176 clist.removeAll( plotCurve );
1182 if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
1185 qApp->processEvents();
1188 //------------------------------------------------------------
1190 CreatePlot(SalomeApp_Module* theModule,
1191 _PTR(SObject) theTableSO)
1193 if ( IsSObjectTable(theTableSO) ) {
1194 CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
1195 CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
1196 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1197 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1198 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1200 if ( pContainer && pTable ) {
1201 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
1202 CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
1203 if( !CORBA::is_nil( aNewCurve ) ) {
1204 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
1206 pContainer->AddCurve( pCrv->_this() );
1210 PlotContainer( theModule, pContainer, VISU::eDisplay );
1212 QString anEntry = pContainer->GetEntry().c_str();
1213 _PTR(Study) aStudy = theTableSO->GetStudy();
1214 _PTR(SObject) aContainerSO = aStudy->FindObjectID(anEntry.toLatin1().data());
1215 _PTR(SObject) aParentSO = aContainerSO->GetFather();
1216 UpdateObjBrowser(theModule,true,aParentSO);
1222 //************************************************************
1225 CreateMesh(VisuGUI* theModule,
1226 const Handle(SALOME_InteractiveObject)& theIO,
1227 SVTK_ViewWindow* theViewWindow)
1229 _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
1230 //if (CheckLock(aStudy))
1233 _PTR(SObject) aResultSObj = aStudy->FindObjectID(theIO->getEntry());
1236 VISU::Result_var aResult;
1237 VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
1238 if (pResult == NULL)
1241 Storable::TRestoringMap aMap = Storable::GetStorableMap(aResultSObj);
1245 CORBA::Object_var aMesh;
1246 string aComment = Storable::FindValue(aMap,"myComment").toLatin1().data();
1247 string aMeshName = Storable::FindValue(aMap,"myMeshName").toLatin1().data();
1252 if (aComment == "ENTITY") {
1253 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
1254 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1255 aMesh = GetVisuGen(theModule)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1256 } else if (aComment == "FAMILY") {
1257 VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
1258 string aFamilyName = Storable::FindValue(aMap,"myName").toLatin1().data();
1259 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1260 aMesh = GetVisuGen(theModule)->FamilyMeshOnEntity
1261 (aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1262 } else if (aComment == "GROUP") {
1263 string aGroupName = Storable::FindValue(aMap,"myName").toLatin1().data();
1264 if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1265 aMesh = GetVisuGen(theModule)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1269 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1273 //QApplication::restoreOverrideCursor();
1274 VISU::Mesh_i* pPresent = NULL;
1275 if (!CORBA::is_nil(aMesh))
1276 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1277 if (pPresent == NULL) {
1278 SUIT_MessageBox::warning (GetDesktop(theModule),
1279 QObject::tr("WRN_VISU"),
1280 QObject::tr("ERR_CANT_BUILD_PRESENTATION") );
1284 if (theViewWindow) {
1290 if(GetResourceMgr()->booleanValue("VISU","display_only",false)){
1291 const VisuGUI* av = dynamic_cast<const VisuGUI*>(theModule);
1292 if(av)(const_cast<VisuGUI*>(av))->OnEraseAll();
1294 PublishMeshInView(theModule, pPresent, theViewWindow);
1295 if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
1296 SetFitAll(theViewWindow);
1300 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1303 } catch (std::runtime_error& exc) {
1305 SUIT_MessageBox::warning(GetDesktop(theModule), QObject::tr("WRN_VISU"),
1306 QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
1310 UpdateObjBrowser(theModule, false, aResultSObj);
1312 theModule->application()->putInfo(QObject::tr("INF_DONE"));
1313 // Make "Save" button active
1314 theModule->getApp()->updateActions();
1318 // ========================================================================================
1319 // GetPrs3dList: find list of presentations for the given object
1320 // ========================================================================================
1321 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1322 const Handle(SALOME_InteractiveObject)& theIO,
1325 std::vector<VISU::Prs3d_i*> aList;
1326 if (!theIO.IsNull() && theIO->hasEntry()) {
1327 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1328 _PTR(SObject) aSObject = aCStudy->FindObjectID(theIO->getEntry());
1329 aList = GetPrs3dList(theModule, aSObject, theGP);
1334 std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
1335 _PTR(SObject) theObject,
1338 std::vector<VISU::Prs3d_i*> aList; int k = 0;
1342 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
1344 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(theObject);
1345 if (!CORBA::is_nil(aCORBAObject)) {
1346 VISU::Base_var aVisuObj = VISU::Base::_narrow(aCORBAObject);
1347 if (!CORBA::is_nil(aVisuObj)) {
1348 VISU::VISUType aType = aVisuObj->GetType();
1350 case VISU::TGAUSSPOINTS:
1351 if ( !theGP ) break;
1352 case VISU::TSCALARMAP:
1353 case VISU::TISOSURFACES:
1354 case VISU::TDEFORMEDSHAPE:
1355 case VISU::TCUTPLANES:
1356 case VISU::TCUTLINES:
1357 case VISU::TVECTORS:
1358 case VISU::TSTREAMLINES:
1360 case VISU::TSCALARMAPONDEFORMEDSHAPE:
1361 case VISU::TDEFORMEDSHAPEANDSCALARMAP:
1364 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1365 if (aServant.in()) {
1366 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1368 aList[k] = aPrsObject;
1375 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1376 _PTR(SObject) aTimeStamp;
1377 anIter->Next(); // First is reference on support
1378 for (; anIter->More(); anIter->Next()) {
1379 aTimeStamp = anIter->Value();
1380 if (!aTimeStamp) continue;
1381 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1382 if (!aSubList.empty()) {
1383 int n = aSubList.size();
1385 for (int i = 0; i < n; i++) {
1386 aList[k] = aSubList[i];
1396 VISU::VISUType aType = VISU::Storable::SObject2Type(theObject);
1398 case VISU::TFIELD: {
1399 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1400 _PTR(SObject) aTimeStamp;
1401 anIter->Next(); // First is reference on support
1402 for (; anIter->More(); anIter->Next()) {
1403 aTimeStamp = anIter->Value();
1404 if (!aTimeStamp) continue;
1405 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
1406 if (!aSubList.empty()) {
1407 int n = aSubList.size();
1409 for (int i = 0; i < n; i++) {
1410 aList[k] = aSubList[i];
1417 case VISU::TTIMESTAMP: {
1418 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
1420 for (; anIter->More(); anIter->Next()) {
1421 aPrs = anIter->Value();
1422 if (!aPrs) continue;
1423 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
1424 if (!aSubList.empty()) {
1425 int n = aSubList.size();
1427 for (int i = 0; i < n; i++) {
1428 aList[k] = aSubList[i];
1439 //------------------------------------------------------------
1440 int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow)
1443 std::set<int> aIndexes;
1444 TViewToPrs3d aMap = theModule->getScalarBarsMap();
1445 TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(theViewWindow);
1446 if (aViewToPrsIter != aMap.end()) {
1447 TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
1448 for (; aPrsIter != (aViewToPrsIter->second).end(); aPrsIter++) {
1449 aIndexes.insert((*aPrsIter).second);
1452 std::set<int>::const_iterator aIter = aIndexes.begin();
1453 for (int i = 1,length = aIndexes.size(); i <= length; i++) {
1454 std::set<int>::const_iterator aIter = aIndexes.find(i);
1455 if (aIter == aIndexes.end()) { minIndx = i; break; }
1456 else minIndx = i + 1;
1461 //------------------------------------------------------------
1462 void AddScalarBarPosition (VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
1463 VISU::Prs3d_i* thePrs3d, int pos)
1465 TViewToPrs3d& aMap = theModule->getScalarBarsMap();
1466 TPrs3dToInd aPair; aPair.first = thePrs3d; aPair.second = pos;
1467 aMap[theViewWindow].insert(aPair);
1470 //------------------------------------------------------------
1471 void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
1472 VISU::Prs3d_i* thePrs3d)
1474 TViewToPrs3d& aMap = theModule->getScalarBarsMap();
1475 TSetPrs3d::iterator aIter = aMap[theViewWindow].begin();
1476 for (; aIter != aMap[theViewWindow].end(); aIter++)
1477 if ((*aIter).first == thePrs3d) {
1478 aMap[theViewWindow].erase(*aIter);
1482 //------------------------------------------------------------
1483 void initSpinBox( QSpinBox* spinBox,
1484 int min, int max, int step )
1486 spinBox->setRange( min, max );
1487 spinBox->setSingleStep( step );
1489 //------------------------------------------------------------
1490 void initSpinBox( QDoubleSpinBox* spinBox,
1491 double min, double max,
1492 double step, int decimals )
1494 spinBox->setRange( min, max );
1495 spinBox->setSingleStep( step );
1496 spinBox->setDecimals( decimals );
1498 //------------------------------------------------------------
1499 bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject)
1501 _PTR(SComponent) aVisuSO = theStudy->FindComponent("VISU");
1502 if (!aVisuSO) return false;
1503 _PTR(SObject) aFolder = theStudy->FindObject(CLIP_PLANES_FOLDER);
1505 _PTR(StudyBuilder) aBuilder = theStudy->NewBuilder();
1506 aFolder = aBuilder->NewObject(aVisuSO);
1508 _PTR(GenericAttribute) anAttr;
1509 anAttr = aBuilder->FindOrCreateAttribute(aFolder,"AttributeName");
1510 _PTR(AttributeName) aName(anAttr);
1511 aName->SetValue(CLIP_PLANES_FOLDER);
1513 theSObject = aFolder;