1 // Copyright (C) 2007-2016 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, or (at your option) any later version.
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
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_VTKUtils.cxx
25 // Author : Open CASCADE S.A.S.
28 #include "SMESHGUI_VTKUtils.h"
31 #include "SMESHGUI_Filter.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMDS_Mesh.hxx"
34 #include "SMESH_Actor.h"
35 #include "SMESH_ActorUtils.h"
36 #include "SMESH_CellLabelActor.h"
37 #include "SMESH_ControlsDef.hxx"
38 #include "SMESH_NodeLabelActor.h"
39 #include "SMESH_ObjectDef.h"
41 // SALOME GUI includes
42 #include <SUIT_Desktop.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_ViewManager.h>
46 #include <SUIT_ResourceMgr.h>
48 #include <SALOME_ListIO.hxx>
50 #include <SVTK_Selector.h>
51 #include <SVTK_ViewModel.h>
52 #include <SVTK_ViewWindow.h>
54 #include <VTKViewer_Algorithm.h>
56 #include <LightApp_SelectionMgr.h>
57 #include <SalomeApp_Application.h>
58 #include <SalomeApp_Study.h>
60 // SALOME KERNEL includes
61 #include <utilities.h>
64 #include <SALOMEconfig.h>
65 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
66 #include CORBA_CLIENT_HEADER(SMESH_Group)
70 #include <vtkRenderer.h>
71 #include <vtkActorCollection.h>
72 #include <vtkUnstructuredGrid.h>
75 #include <Standard_ErrorHandler.hxx>
79 typedef std::map<std::string,TVisualObjPtr> TVisualObjCont;
80 static TVisualObjCont VISUAL_OBJ_CONT;
82 //=============================================================================
84 * \brief Allocate some memory at construction and release it at destruction.
85 * Is used to be able to continue working after mesh generation or visualization
86 * break due to lack of memory
88 //=============================================================================
93 MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
94 void Free() { if (myBuf) { delete [] myBuf; myBuf = 0; }}
95 ~MemoryReserve() { Free(); }
97 static MemoryReserve* theVISU_MemoryReserve = new MemoryReserve;
99 //================================================================================
101 * \brief Remove VisualObj and its actor from all views
103 //================================================================================
105 void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews )
107 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
110 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
113 ViewManagerList aList;
116 app->viewManagers(SVTK_Viewer::Type() , aList);
118 SUIT_ViewManager* aVM = app->getViewManager(SVTK_Viewer::Type(), true);
122 bool actorRemoved = false;
123 ViewManagerList::ConstIterator it = aList.begin();
124 SUIT_ViewManager* aViewManager = 0;
125 for( ; it!=aList.end();it++) {
127 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
128 for ( int iV = 0; iV < views.count(); ++iV ) {
129 if ( SMESH_Actor* actor = FindActorByEntry( views[iV], theEntry)) {
130 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
131 vtkWnd->RemoveActor(actor);
139 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
140 if(anIter != VISUAL_OBJ_CONT.end()) {
141 // for unknown reason, object destructor is not called, so clear object manually
142 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
143 anIter->second->GetUnstructuredGrid()->SetPoints(0);
145 VISUAL_OBJ_CONT.erase(theEntry);
148 aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
150 //================================================================================
152 * \brief Remove all VisualObjs and their actors from all views
154 //================================================================================
156 void RemoveAllObjectsWithActors()
158 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
159 ( SUIT_Session::session()->activeApplication() );
161 ViewManagerList viewMgrs = app->viewManagers();
162 for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
163 SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
164 if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type()) {
165 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
166 for ( int iV = 0; iV < views.count(); ++iV ) {
167 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
168 vtkRenderer *aRenderer = vtkWnd->getRenderer();
169 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
170 vtkActorCollection *actors = aCopy.GetActors();
171 for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
172 // size of actors changes inside the loop
173 if (SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
175 vtkWnd->RemoveActor(actor);
183 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
184 for ( ; anIter != VISUAL_OBJ_CONT.end(); ++anIter ) {
185 // for unknown reason, object destructor is not called, so clear object manually
186 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
187 anIter->second->GetUnstructuredGrid()->SetPoints(0);
189 VISUAL_OBJ_CONT.clear();
192 //================================================================================
194 * \brief Remove all VisualObjs of a study
196 //================================================================================
198 void RemoveVisuData()
200 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
201 ( SUIT_Session::session()->activeApplication() );
203 ViewManagerList viewMgrs = app->viewManagers();
204 for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
205 SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
206 if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type() ) {
207 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
208 for ( int iV = 0; iV < views.count(); ++iV ) {
209 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
210 vtkRenderer *aRenderer = vtkWnd->getRenderer();
211 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
212 vtkActorCollection *actors = aCopy.GetActors();
213 for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
214 // size of actors changes inside the loop
215 if(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
217 vtkWnd->RemoveActor(actor);
225 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
226 for ( ; anIter != VISUAL_OBJ_CONT.end(); ) {
227 // for unknown reason, object destructor is not called, so clear object manually
228 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
229 anIter->second->GetUnstructuredGrid()->SetPoints(0);
230 VISUAL_OBJ_CONT.erase( anIter++ ); // anIter++ returns a copy of self before incrementing
234 //================================================================================
236 * \brief Notify the user on problems during visualization
238 //================================================================================
240 void OnVisuException()
244 // PAL16774 (Crash after display of many groups). Salome sometimes crashes just
245 // after or at showing this message, so we do an additional check of available memory
246 // char* buf = new char[100*1024];
248 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
249 QObject::tr("SMESH_VISU_PROBLEM"));
251 // no more memory at all: last resort
252 MESSAGE_BEGIN ( "SMESHGUI_VTKUtils::OnVisuException(), exception even at showing a message!!!" <<
253 std::endl << "Try to remove all visual data..." );
254 if (theVISU_MemoryReserve) {
255 delete theVISU_MemoryReserve;
256 theVISU_MemoryReserve = 0;
258 RemoveAllObjectsWithActors();
259 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
260 QObject::tr("SMESH_VISU_PROBLEM_CLEAR"));
261 MESSAGE_END ( "...done" );
264 //================================================================================
266 * \brief Returns an updated visual object
268 //================================================================================
270 TVisualObjPtr GetVisualObj(const char* theEntry, bool nulData){
271 TVisualObjPtr aVisualObj;
274 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
275 if(anIter != VISUAL_OBJ_CONT.end()){
276 aVisualObj = anIter->second;
278 SalomeApp_Application* app =
279 dynamic_cast<SalomeApp_Application*>( SMESHGUI::activeStudy()->application() );
280 _PTR(Study) aStudy = SMESH::getStudy();
281 _PTR(SObject) aSObj = aStudy->FindObjectID(theEntry);
283 _PTR(GenericAttribute) anAttr;
284 if(aSObj->FindAttribute(anAttr,"AttributeIOR")){
285 _PTR(AttributeIOR) anIOR = anAttr;
286 CORBA::String_var aVal = anIOR->Value().c_str();
287 CORBA::Object_var anObj = app->orb()->string_to_object( aVal.in() );
288 if(!CORBA::is_nil(anObj)){
289 //Try narrow to SMESH_Mesh interface
290 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
291 if(!aMesh->_is_nil()){
292 aVisualObj.reset(new SMESH_MeshObj(aMesh));
293 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
294 VISUAL_OBJ_CONT.insert(aValue);
296 //Try narrow to SMESH_Group interface
297 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObj);
298 if(!aGroup->_is_nil()){
299 _PTR(SObject) aFatherSObj = aSObj->GetFather();
300 if(!aFatherSObj) return aVisualObj;
301 aFatherSObj = aFatherSObj->GetFather();
302 if(!aFatherSObj) return aVisualObj;
303 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
304 TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
305 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
306 aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj));
307 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
308 VISUAL_OBJ_CONT.insert(aValue);
311 //Try narrow to SMESH_subMesh interface
312 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
313 if(!aSubMesh->_is_nil()){
314 _PTR(SObject) aFatherSObj = aSObj->GetFather();
315 if(!aFatherSObj) return aVisualObj;
316 aFatherSObj = aFatherSObj->GetFather();
317 if(!aFatherSObj) return aVisualObj;
318 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
319 TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
320 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
321 aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj));
322 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
323 VISUAL_OBJ_CONT.insert(aValue);
331 INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!");
332 return TVisualObjPtr();
335 bool objModified = false;
340 objModified = aVisualObj->NulData();
342 objModified = aVisualObj->Update();
345 MESSAGE ( "Exception in SMESHGUI_VTKUtils::GetVisualObj()" );
346 RemoveVisualObjectWithActors( theEntry ); // remove this object
353 // PAL16631. Measurements showed that to show aVisualObj in SHADING(default) mode,
354 // ~5 times more memory is used than it occupies.
355 // Warn the user if there is less free memory than 30 sizes of a grid
356 // TODO: estimate memory usage in other modes and take current mode into account
357 int freeMB = SMDS_Mesh::CheckMemory(true);
358 int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024;
359 //MESSAGE("SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB << ", usedMB=" <<usedMB);
360 if ( freeMB > 0 && usedMB * 5 > freeMB ) {
361 bool continu = false;
362 if ( usedMB * 3 > freeMB )
363 // don't even try to show
364 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
365 QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
367 // there is a chance to succeed
368 continu = SUIT_MessageBox::warning
369 (SMESHGUI::desktop(),
370 QObject::tr("SMESH_WRN_WARNING"),
371 QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
372 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
373 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
375 // remove the corresponding actors from all views
376 RemoveVisualObjectWithActors( theEntry );
386 /*! Return active view window, if it instantiates SVTK_ViewWindow class,
387 * otherwise find or create corresponding view window, make it active and return it.
388 * \note Active VVTK_ViewWindow can be returned, because it inherits SVTK_ViewWindow.
390 SVTK_ViewWindow* GetViewWindow (const SalomeApp_Module* theModule,
391 bool createIfNotFound)
393 SalomeApp_Application* anApp;
395 anApp = theModule->getApp();
397 anApp = dynamic_cast<SalomeApp_Application*>
398 (SUIT_Session::session()->activeApplication());
401 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow()))
404 SUIT_ViewManager* aViewManager =
405 anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound);
407 if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
408 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
409 aViewWindow->raise();
410 aViewWindow->setFocus();
419 SVTK_ViewWindow* FindVtkViewWindow (SUIT_ViewManager* theMgr,
420 SUIT_ViewWindow * theWindow)
425 QVector<SUIT_ViewWindow*> views = theMgr->getViews();
426 if( views.contains( theWindow ) )
427 return GetVtkViewWindow( theWindow );
432 SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow* theWindow){
433 return dynamic_cast<SVTK_ViewWindow*>(theWindow);
436 /* SUIT_ViewWindow* GetActiveWindow()
438 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
441 SUIT_ViewManager* mgr = app->activeViewManager();
443 return mgr->getActiveView();
448 SVTK_ViewWindow* GetCurrentVtkView(){
449 return GetVtkViewWindow( GetActiveWindow() );
453 void RepaintCurrentView()
455 if (SVTK_ViewWindow* wnd = GetCurrentVtkView())
459 wnd->getRenderer()->Render();
463 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintCurrentView()" );
469 void RepaintViewWindow(SVTK_ViewWindow* theWindow)
473 theWindow->getRenderer()->Render();
474 theWindow->Repaint();
477 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintViewWindow(SVTK_ViewWindow*)" );
482 void RenderViewWindow(SVTK_ViewWindow* theWindow)
486 theWindow->getRenderer()->Render();
487 theWindow->Repaint();
490 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RenderViewWindow(SVTK_ViewWindow*)" );
496 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){
503 MESSAGE ( "Exception in SMESHGUI_VTKUtils::FitAll()" );
510 SMESH_Actor* FindActorByEntry(SUIT_ViewWindow *theWindow,
511 const char* theEntry)
513 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
514 vtkRenderer *aRenderer = aViewWindow->getRenderer();
515 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
516 vtkActorCollection *aCollection = aCopy.GetActors();
517 aCollection->InitTraversal();
518 while(vtkActor *anAct = aCollection->GetNextActor()){
519 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
520 if(anActor->hasIO()){
521 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
522 if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
533 SMESH_Actor* FindActorByEntry(const char* theEntry){
534 return FindActorByEntry(GetActiveWindow(),theEntry);
538 SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){
539 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
543 if(!CORBA::is_nil(theObject)){
544 _PTR(Study) aStudy = getStudy();
545 CORBA::String_var anIOR = app->orb()->object_to_string( theObject );
546 _PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in());
548 CORBA::String_var anEntry = aSObject->GetID().c_str();
549 return FindActorByEntry(anEntry.in());
556 SMESH_Actor* CreateActor(const char* theEntry,
559 SMESH_Actor *anActor = NULL;
560 if(TVisualObjPtr aVisualObj = GetVisualObj(theEntry)){
561 _PTR(SObject) aSObj = getStudy()->FindObjectID(theEntry);
563 _PTR(GenericAttribute) anAttr;
564 if(aSObj->FindAttribute(anAttr,"AttributeName")){
565 _PTR(AttributeName) aName = anAttr;
566 std::string aNameVal = aName->Value();
567 anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear);
570 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( aSObj ));
571 if(!CORBA::is_nil(aGroup) && anActor)
575 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
576 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
577 c = SMESH::GetColor( "SMESH", "default_grp_color", c );
578 SALOMEDS::Color aColor = aGroup->GetColor();
579 if( !( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 ))
582 aColor.G = c.greenF();
583 aColor.B = c.blueF();
584 aGroup->SetColor( aColor );
586 if( aGroup->GetType() == SMESH::NODE )
587 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
588 else if( aGroup->GetType() == SMESH::EDGE )
589 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
590 else if( aGroup->GetType() == SMESH::ELEM0D )
591 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
592 else if( aGroup->GetType() == SMESH::BALL )
593 anActor->SetBallColor( aColor.R, aColor.G, aColor.B );
594 else if( aGroup->GetType() == SMESH::VOLUME )
595 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, deltaV );
597 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, deltaF );
601 //MESSAGE("CreateActor " << anActor);
603 if( SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI() )
604 aSMESHGUI->addActorAsObserver( anActor );
609 void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
610 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
613 //MESSAGE("DisplayActor " << theActor);
614 vtkWnd->AddActor(theActor);
618 MESSAGE ( "Exception in SMESHGUI_VTKUtils::DisplayActor()" );
625 void RemoveActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor)
627 if ( SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)) {
628 //MESSAGE("RemoveActor " << theActor);
629 vtkWnd->RemoveActor(theActor);
630 if(theActor->hasIO()){
631 Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
632 if(anIO->hasEntry()){
633 std::string anEntry = anIO->getEntry();
634 VISUAL_OBJ_CONT.erase(anEntry);
642 //================================================================================
644 * \brief Return true if there are no SMESH actors in a view
646 //================================================================================
648 bool noSmeshActors(SUIT_ViewWindow *theWnd)
650 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWnd)) {
651 vtkRenderer *aRenderer = aViewWindow->getRenderer();
652 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
653 vtkActorCollection *aCollection = aCopy.GetActors();
654 aCollection->InitTraversal();
655 while(vtkActor *anAct = aCollection->GetNextActor())
656 if(dynamic_cast<SMESH_Actor*>(anAct))
662 bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
664 //MESSAGE("UpdateView");
666 SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd);
670 SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd);
674 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( vtkWnd->getViewManager()->study() );
681 vtkRenderer *aRenderer = aViewWnd->getRenderer();
682 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
683 vtkActorCollection *aCollection = aCopy.GetActors();
684 aCollection->InitTraversal();
688 while (vtkActor *anAct = aCollection->GetNextActor()) {
689 if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
690 //MESSAGE("--- display " << anActor);
691 anActor->SetVisibility(true);
693 if(anActor->hasIO()){
694 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
695 if(anIO->hasEntry()){
696 aStudy->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
705 //MESSAGE("---case eDisplayOnly");
706 while (vtkActor *anAct = aCollection->GetNextActor()) {
707 if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
708 //MESSAGE("--- erase " << anActor);
709 anActor->SetVisibility(false);
712 aStudy->setVisibilityStateForAll(Qtx::HiddenState);
715 if (SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)) {
719 //MESSAGE("--- display " << anActor);
721 anActor->SetVisibility(true);
722 if (theAction == eDisplayOnly) aRenderer->ResetCameraClippingRange();
723 aStudy->setVisibilityState(theEntry, Qtx::ShownState);
726 //MESSAGE("--- erase " << anActor);
727 anActor->SetVisibility(false);
728 aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
738 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(theWnd->getViewManager()->study());
739 TVisualObjPtr aVisualObj;
740 if ( (aVisualObj = GetVisualObj(theEntry)) && aVisualObj->IsValid())
742 if ((anActor = CreateActor(theEntry,true))) {
743 bool needFitAll = noSmeshActors(theWnd); // fit for the first object only
744 DisplayActor(theWnd,anActor);
745 anActor->SetVisibility(true);
746 aStudy->setVisibilityState(theEntry, Qtx::ShownState);
747 // FitAll(); - PAL16770(Display of a group performs an automatic fit all)
748 if (needFitAll) FitAll();
765 bool UpdateView(EDisplaing theAction, const char* theEntry) {
766 //MESSAGE("UpdateView");
767 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
768 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
769 if ( SUIT_ViewManager* vm = app->activeViewManager() )
771 SUIT_ViewWindow *aWnd = vm->getActiveView();
772 return UpdateView(aWnd,theAction,theEntry);
777 void UpdateView( bool withChildrenOfSelected )
779 if ( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()) {
780 LightApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
781 SALOME_ListIO selected; mgr->selectedObjects( selected );
783 if ( selected.Extent() == 0 ) {
784 vtkRenderer* aRenderer = aWnd->getRenderer();
785 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
786 vtkActorCollection *aCollection = aCopy.GetActors();
787 aCollection->InitTraversal();
788 while(vtkActor *anAct = aCollection->GetNextActor()){
789 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
791 if (!Update(anActor->getIO(),anActor->GetVisibility()))
792 break; // avoid multiple warnings if visu failed
798 SALOME_ListIteratorOfListIO anIter( selected );
799 for( ; anIter.More(); anIter.Next())
801 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
802 if ( !Update( anIO, true ))
803 break; // avoid multiple warnings if visu failed
805 if ( withChildrenOfSelected ) // update all visible children
807 QString aFatherID = anIO->getEntry();
808 vtkRenderer* aRenderer = aWnd->getRenderer();
809 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
810 vtkActorCollection *aCollection = aCopy.GetActors();
811 aCollection->InitTraversal();
812 while ( vtkActor *anAct = aCollection->GetNextActor() ) {
813 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct )) {
814 if ( anActor->hasIO() && anActor->GetVisibility() )
816 QString aChildID = anActor->getIO()->getEntry();
817 if ( aChildID.size() > aFatherID.size() &&
818 aChildID.startsWith( aFatherID ))
819 if ( ! Update( anActor->getIO(), true ))
827 RepaintCurrentView();
832 bool Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
835 if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry())) {
837 UpdateView(SMESH::eDisplay,theIO->getEntry());
843 bool UpdateNulData(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
845 //MESSAGE("UpdateNulData");
846 if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry(), true)) {
848 UpdateView(SMESH::eDisplay,theIO->getEntry());
854 void UpdateSelectionProp( SMESHGUI* theModule )
859 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
862 MESSAGE( "UpdateSelectionProp: Application is null" );
866 SUIT_ViewManager* vm = app->activeViewManager();
869 MESSAGE( "UpdateSelectionProp: View manager is null" );
873 QVector<SUIT_ViewWindow*> views = vm->getViews();
875 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
878 MESSAGE( "UpdateSelectionProp: Resource manager is null" );
883 aHiColor = mgr->colorValue( "SMESH", "selection_object_color", Qt::white ),
884 aSelColor = mgr->colorValue( "SMESH", "selection_element_color", Qt::yellow ),
885 aPreColor = mgr->colorValue( "SMESH", "highlight_color", Qt::cyan );
887 int aElem0DSize = mgr->integerValue("SMESH", "elem0d_size", 5);
888 // int aBallSize = mgr->integerValue("SMESH", "ball_elem_size", 5);
889 int aLineWidth = mgr->integerValue("SMESH", "element_width", 1);
890 int maxSize = aElem0DSize;
891 if (aElem0DSize > maxSize) maxSize = aElem0DSize;
892 if (aLineWidth > maxSize) maxSize = aLineWidth;
893 // if (aBallSize > maxSize) maxSize = aBallSize;
896 SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
897 SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 ),
898 SP3 = mgr->doubleValue( "SMESH", "selection_precision_object", 0.025 );
900 for ( int i=0, n=views.count(); i<n; i++ )
902 // update VTK viewer properties
903 if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] ))
905 // mesh element selection
906 aVtkView->SetSelectionProp(aSelColor.red()/255.,
907 aSelColor.green()/255.,
908 aSelColor.blue()/255.);
910 aVtkView->SetSelectionTolerance(SP1, SP2, SP3);
913 aVtkView->SetPreselectionProp(aPreColor.red()/255.,
914 aPreColor.green()/255.,
915 aPreColor.blue()/255.);
917 vtkRenderer* aRenderer = aVtkView->getRenderer();
918 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
919 vtkActorCollection *aCollection = aCopy.GetActors();
920 aCollection->InitTraversal();
921 while ( vtkActor *anAct = aCollection->GetNextActor() ) {
922 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct) ) {
923 anActor->SetHighlightColor(aHiColor.red()/255.,
924 aHiColor.green()/255.,
925 aHiColor.blue()/255.);
926 anActor->SetPreHighlightColor(aPreColor.red()/255.,
927 aPreColor.green()/255.,
928 aPreColor.blue()/255.);
936 void UpdateFontProp( SMESHGUI* theModule )
938 if ( !theModule ) return;
940 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
943 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
946 double anRGBNd[3] = {1,1,1};
947 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
949 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
951 bool anItalicNd = false;
952 bool aShadowNd = false;
954 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
955 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
956 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
957 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
958 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
960 anItalicNd = f.italic();
961 aShadowNd = f.overline();
962 aSizeNd = f.pointSize();
965 double anRGBEl[3] = {0,1,0};
966 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
968 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
970 bool anItalicEl = false;
971 bool aShadowEl = false;
973 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
974 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
976 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
977 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
978 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
980 anItalicEl = f.italic();
981 aShadowEl = f.overline();
982 aSizeEl = f.pointSize();
985 ViewManagerList vmList;
986 app->viewManagers( SVTK_Viewer::Type(), vmList );
987 foreach ( SUIT_ViewManager* vm, vmList ) {
988 QVector<SUIT_ViewWindow*> views = vm->getViews();
989 foreach ( SUIT_ViewWindow* vw, views ) {
990 // update VTK viewer properties
991 if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( vw ) ) {
993 vtkRenderer* aRenderer = aVtkView->getRenderer();
994 VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() );
995 vtkActorCollection* aCollection = aCopy.GetActors();
996 aCollection->InitTraversal();
997 while ( vtkActor* anAct = aCollection->GetNextActor() ) {
998 if ( SMESH_NodeLabelActor* anActor = dynamic_cast< SMESH_NodeLabelActor* >( anAct ) ) {
999 anActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
1001 else if ( SMESH_CellLabelActor* anActor = dynamic_cast< SMESH_CellLabelActor* >( anAct ) ) {
1002 anActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
1005 aVtkView->Repaint( false );
1011 //----------------------------------------------------------------------------
1013 GetSelector(SUIT_ViewWindow *theWindow)
1015 if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow))
1016 return aWnd->GetSelector();
1021 void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
1022 SVTK_Selector* theSelector)
1025 theSelector->SetFilter(theFilter);
1028 Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_Selector* theSelector)
1030 return theSelector->GetFilter(theId);
1033 bool IsFilterPresent(int theId, SVTK_Selector* theSelector)
1035 return theSelector->IsFilterPresent(theId);
1038 void RemoveFilter(int theId, SVTK_Selector* theSelector)
1040 theSelector->RemoveFilter(theId);
1043 void RemoveFilters(SVTK_Selector* theSelector)
1045 for ( int id = SMESH::NodeFilter; theSelector && id < SMESH::LastFilter; id++ )
1046 theSelector->RemoveFilter( id );
1049 bool IsValid(SALOME_Actor* theActor, int theCellId,
1050 SVTK_Selector* theSelector)
1052 return theSelector->IsValid(theActor,theCellId);
1056 //----------------------------------------------------------------------------
1057 void SetPointRepresentation(bool theIsVisible)
1059 if ( SVTK_ViewWindow* aViewWindow = GetCurrentVtkView() ) {
1060 vtkRenderer *aRenderer = aViewWindow->getRenderer();
1061 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1062 vtkActorCollection *aCollection = aCopy.GetActors();
1063 aCollection->InitTraversal();
1064 while(vtkActor *anAct = aCollection->GetNextActor()){
1065 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1066 if(anActor->GetVisibility()){
1067 anActor->SetPointRepresentation(theIsVisible);
1071 RepaintCurrentView();
1076 void SetPickable(SMESH_Actor* theActor)
1078 if ( SVTK_ViewWindow* aWnd = GetCurrentVtkView() ) {
1079 int anIsAllPickable = (theActor == NULL);
1080 vtkRenderer *aRenderer = aWnd->getRenderer();
1081 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1082 vtkActorCollection *aCollection = aCopy.GetActors();
1083 aCollection->InitTraversal();
1084 while(vtkActor *anAct = aCollection->GetNextActor()){
1085 if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
1086 if(anActor->GetVisibility()){
1087 anActor->SetPickable(anIsAllPickable);
1092 theActor->SetPickable(!anIsAllPickable);
1093 RepaintCurrentView();
1098 //----------------------------------------------------------------------------
1099 int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
1100 const Handle(SALOME_InteractiveObject)& theIO,
1104 TColStd_IndexedMapOfInteger aMapIndex;
1105 theSelector->GetIndex(theIO,aMapIndex);
1107 for(int i = 1; i <= aMapIndex.Extent(); i++)
1108 theName += QString(" %1").arg(aMapIndex(i));
1110 return aMapIndex.Extent();
1113 int GetNameOfSelectedElements(SVTK_Selector* theSelector,
1114 const Handle(SALOME_InteractiveObject)& theIO,
1118 TColStd_IndexedMapOfInteger aMapIndex;
1119 theSelector->GetIndex(theIO,aMapIndex);
1121 typedef std::set<int> TIdContainer;
1122 TIdContainer anIdContainer;
1123 for( int i = 1; i <= aMapIndex.Extent(); i++)
1124 anIdContainer.insert(aMapIndex(i));
1126 TIdContainer::const_iterator anIter = anIdContainer.begin();
1127 for( ; anIter != anIdContainer.end(); anIter++)
1128 theName += QString(" %1").arg(*anIter);
1130 return aMapIndex.Extent();
1134 int GetEdgeNodes(SVTK_Selector* theSelector,
1135 const TVisualObjPtr& theVisualObject,
1139 const SALOME_ListIO& selected = theSelector->StoredIObjects();
1141 if ( selected.Extent() != 1 )
1144 Handle(SALOME_InteractiveObject) anIO = selected.First();
1145 if ( anIO.IsNull() || !anIO->hasEntry() )
1148 TColStd_IndexedMapOfInteger aMapIndex;
1149 theSelector->GetIndex( anIO, aMapIndex );
1150 if ( aMapIndex.Extent() != 2 )
1153 int anObjId = -1, anEdgeNum = -1;
1154 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
1155 int aVal = aMapIndex( i );
1159 anEdgeNum = abs( aVal ) - 1;
1162 if ( anObjId == -1 || anEdgeNum == -1 )
1165 return theVisualObject->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
1168 //----------------------------------------------------------------------------
1169 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr,
1170 const Handle(SALOME_InteractiveObject)& theIO,
1174 if(theIO->hasEntry()){
1175 if(FindActorByEntry(theIO->getEntry())){
1176 TColStd_IndexedMapOfInteger aMapIndex;
1177 theMgr->GetIndexes(theIO,aMapIndex);
1178 for(int i = 1; i <= aMapIndex.Extent(); i++){
1179 theName += QString(" %1").arg(aMapIndex(i));
1181 return aMapIndex.Extent();
1187 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr, QString& theName)
1190 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1191 if(selected.Extent() == 1){
1192 Handle(SALOME_InteractiveObject) anIO = selected.First();
1193 return GetNameOfSelectedNodes(theMgr,anIO,theName);
1199 int GetNameOfSelectedElements(LightApp_SelectionMgr * theMgr,
1200 const Handle(SALOME_InteractiveObject)& theIO,
1204 if(theIO->hasEntry()){
1205 if(FindActorByEntry(theIO->getEntry())){
1206 TColStd_IndexedMapOfInteger aMapIndex;
1207 theMgr->GetIndexes(theIO,aMapIndex);
1208 typedef std::set<int> TIdContainer;
1209 TIdContainer anIdContainer;
1210 for( int i = 1; i <= aMapIndex.Extent(); i++)
1211 anIdContainer.insert(aMapIndex(i));
1212 TIdContainer::const_iterator anIter = anIdContainer.begin();
1213 for( ; anIter != anIdContainer.end(); anIter++){
1214 theName += QString(" %1").arg(*anIter);
1216 return aMapIndex.Extent();
1223 int GetNameOfSelectedElements(LightApp_SelectionMgr *theMgr, QString& theName)
1226 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1228 if( selected.Extent() == 1){
1229 Handle(SALOME_InteractiveObject) anIO = selected.First();
1230 return GetNameOfSelectedElements(theMgr,anIO,theName);
1235 int GetSelected(LightApp_SelectionMgr* theMgr,
1236 TColStd_IndexedMapOfInteger& theMap,
1237 const bool theIsElement)
1240 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1242 if ( selected.Extent() == 1 )
1244 Handle(SALOME_InteractiveObject) anIO = selected.First();
1245 if ( anIO->hasEntry() ) {
1246 theMgr->GetIndexes( anIO, theMap );
1249 return theMap.Extent();
1253 int GetEdgeNodes( LightApp_SelectionMgr* theMgr, int& theId1, int& theId2 )
1255 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1257 if ( selected.Extent() != 1 )
1260 Handle(SALOME_InteractiveObject) anIO = selected.First();
1261 if ( anIO.IsNull() || !anIO->hasEntry() )
1264 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1268 TColStd_IndexedMapOfInteger aMapIndex;
1269 theMgr->GetIndexes( anIO, aMapIndex );
1270 if ( aMapIndex.Extent() != 2 )
1273 int anObjId = -1, anEdgeNum = -1;
1274 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
1275 int aVal = aMapIndex( i );
1279 anEdgeNum = abs( aVal );
1282 if ( anObjId == -1 || anEdgeNum == -1 )
1285 return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
1288 void SetControlsPrecision( const long theVal )
1290 if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
1292 vtkRenderer *aRenderer = aWnd->getRenderer();
1293 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1294 vtkActorCollection *aCollection = aCopy.GetActors();
1295 aCollection->InitTraversal();
1297 while ( vtkActor *anAct = aCollection->GetNextActor())
1299 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) )
1301 anActor->SetControlsPrecision( theVal );
1302 anActor->SetControlMode( anActor->GetControlMode() );
1309 //----------------------------------------------------------------------------
1310 // internal function
1311 void ComputeBoundsParam( double theBounds[6],
1312 double theDirection[3],
1313 double theMinPnt[3],
1314 double& theMaxBoundPrj,
1315 double& theMinBoundPrj )
1317 //Enlarge bounds in order to avoid conflicts of precision
1318 for(int i = 0; i < 6; i += 2){
1319 static double EPS = 1.0E-3;
1320 double aDelta = (theBounds[i+1] - theBounds[i])*EPS;
1321 theBounds[i] -= aDelta;
1322 theBounds[i+1] += aDelta;
1325 double aBoundPoints[8][3] = { {theBounds[0],theBounds[2],theBounds[4]},
1326 {theBounds[1],theBounds[2],theBounds[4]},
1327 {theBounds[0],theBounds[3],theBounds[4]},
1328 {theBounds[1],theBounds[3],theBounds[4]},
1329 {theBounds[0],theBounds[2],theBounds[5]},
1330 {theBounds[1],theBounds[2],theBounds[5]},
1331 {theBounds[0],theBounds[3],theBounds[5]},
1332 {theBounds[1],theBounds[3],theBounds[5]}};
1335 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1336 theMinBoundPrj = theMaxBoundPrj;
1337 for(int i = 1; i < 8; i++){
1338 double aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1339 if(theMaxBoundPrj < aTmp){
1340 theMaxBoundPrj = aTmp;
1343 if(theMinBoundPrj > aTmp){
1344 theMinBoundPrj = aTmp;
1347 double *aMinPnt = aBoundPoints[aMaxId];
1348 theMinPnt[0] = aMinPnt[0];
1349 theMinPnt[1] = aMinPnt[1];
1350 theMinPnt[2] = aMinPnt[2];
1353 // internal function
1354 void DistanceToPosition( double theBounds[6],
1355 double theDirection[3],
1359 double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1360 ComputeBoundsParam(theBounds,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1361 double aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1362 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1363 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1364 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1367 // internal function (currently unused, left just in case)
1368 void PositionToDistance( double theBounds[6],
1369 double theDirection[3],
1373 double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1374 ComputeBoundsParam(theBounds,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1375 double aPrj = vtkMath::Dot(theDirection,thePos);
1376 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1379 bool ComputeClippingPlaneParameters( std::list<vtkActor*> theActorList,
1380 double theNormal[3],
1382 double theBounds[6],
1383 double theOrigin[3] )
1385 bool anIsOk = false;
1386 anIsOk = ComputeBounds( theActorList, theBounds );
1392 DistanceToPosition( theBounds, theNormal, theDist, theOrigin );
1396 bool ComputeBounds( std::list<vtkActor*> theActorList,
1397 double theBounds[6])
1399 bool anIsOk = false;
1400 theBounds[0] = theBounds[2] = theBounds[4] = VTK_DOUBLE_MAX;
1401 theBounds[1] = theBounds[3] = theBounds[5] = -VTK_DOUBLE_MAX;
1402 std::list<vtkActor*>::iterator anIter = theActorList.begin();
1403 for( ; anIter != theActorList.end(); anIter++ ) {
1404 if( vtkActor* aVTKActor = *anIter ) {
1405 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
1407 anActor->GetUnstructuredGrid()->GetBounds( aBounds );
1408 theBounds[0] = std::min( theBounds[0], aBounds[0] );
1409 theBounds[1] = std::max( theBounds[1], aBounds[1] );
1410 theBounds[2] = std::min( theBounds[2], aBounds[2] );
1411 theBounds[3] = std::max( theBounds[3], aBounds[3] );
1412 theBounds[4] = std::min( theBounds[4], aBounds[4] );
1413 theBounds[5] = std::max( theBounds[5], aBounds[5] );
1421 #ifndef DISABLE_PLOT2DVIEWER
1422 //================================================================================
1424 * \brief Find all SMESH_Actor's in the View Window.
1425 * If actor contains Plot2d_Histogram object remove it from each Plot2d Viewer.
1427 //================================================================================
1429 void ClearPlot2Viewers( SUIT_ViewWindow* theWindow )
1431 if ( SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow) ) {
1432 vtkRenderer *aRenderer = aViewWindow->getRenderer();
1433 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1434 vtkActorCollection *aCollection = aCopy.GetActors();
1435 aCollection->InitTraversal();
1436 while(vtkActor *anAct = aCollection->GetNextActor()){
1437 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1438 if(anActor->hasIO() && anActor->GetPlot2Histogram() ){
1439 ProcessIn2DViewers(anActor,RemoveFrom2dViewer);
1448 } // end of namespace SMESH