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_ActorProps.h"
36 #include "SMESH_ActorUtils.h"
37 #include "SMESH_CellLabelActor.h"
38 #include "SMESH_ControlsDef.hxx"
39 #include "SMESH_NodeLabelActor.h"
40 #include "SMESH_ObjectDef.h"
42 // SALOME GUI includes
43 #include <SUIT_Desktop.h>
44 #include <SUIT_Session.h>
45 #include <SUIT_MessageBox.h>
46 #include <SUIT_ViewManager.h>
47 #include <SUIT_ResourceMgr.h>
49 #include <SALOME_ListIO.hxx>
51 #include <SVTK_Selector.h>
52 #include <SVTK_ViewModel.h>
53 #include <SVTK_ViewWindow.h>
55 #include <VTKViewer_Algorithm.h>
57 #include <LightApp_SelectionMgr.h>
58 #include <SalomeApp_Application.h>
59 #include <SalomeApp_Study.h>
61 // SALOME KERNEL includes
62 #include <utilities.h>
65 #include <SALOMEconfig.h>
66 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
67 #include CORBA_CLIENT_HEADER(SMESH_Group)
71 #include <vtkRenderer.h>
72 #include <vtkActorCollection.h>
73 #include <vtkUnstructuredGrid.h>
76 #include <Standard_ErrorHandler.hxx>
80 typedef std::map<std::string,TVisualObjPtr> TVisualObjCont;
81 static TVisualObjCont VISUAL_OBJ_CONT;
83 //=============================================================================
85 * \brief Allocate some memory at construction and release it at destruction.
86 * Is used to be able to continue working after mesh generation or visualization
87 * break due to lack of memory
89 //=============================================================================
94 MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
95 void Free() { if (myBuf) { delete [] myBuf; myBuf = 0; }}
96 ~MemoryReserve() { Free(); }
98 static MemoryReserve* theVISU_MemoryReserve = new MemoryReserve;
100 //================================================================================
102 * \brief Remove VisualObj and its actor from all views
104 //================================================================================
106 void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews )
108 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
111 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
114 ViewManagerList aList;
117 app->viewManagers(SVTK_Viewer::Type() , aList);
119 SUIT_ViewManager* aVM = app->getViewManager(SVTK_Viewer::Type(), true);
123 bool actorRemoved = false;
124 ViewManagerList::ConstIterator it = aList.begin();
125 SUIT_ViewManager* aViewManager = 0;
126 for( ; it!=aList.end();it++) {
128 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
129 for ( int iV = 0; iV < views.count(); ++iV ) {
130 if ( SMESH_Actor* actor = FindActorByEntry( views[iV], theEntry)) {
131 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
132 vtkWnd->RemoveActor(actor);
140 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
141 if(anIter != VISUAL_OBJ_CONT.end()) {
142 // for unknown reason, object destructor is not called, so clear object manually
143 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
144 anIter->second->GetUnstructuredGrid()->SetPoints(0);
146 VISUAL_OBJ_CONT.erase(theEntry);
149 aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
151 //================================================================================
153 * \brief Remove all VisualObjs and their actors from all views
155 //================================================================================
157 void RemoveAllObjectsWithActors()
159 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
160 ( SUIT_Session::session()->activeApplication() );
162 ViewManagerList viewMgrs = app->viewManagers();
163 for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
164 SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
165 if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type()) {
166 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
167 for ( int iV = 0; iV < views.count(); ++iV ) {
168 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
169 vtkRenderer *aRenderer = vtkWnd->getRenderer();
170 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
171 vtkActorCollection *actors = aCopy.GetActors();
172 for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
173 // size of actors changes inside the loop
174 if (SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
176 vtkWnd->RemoveActor(actor);
184 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
185 for ( ; anIter != VISUAL_OBJ_CONT.end(); ++anIter ) {
186 // for unknown reason, object destructor is not called, so clear object manually
187 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
188 anIter->second->GetUnstructuredGrid()->SetPoints(0);
190 VISUAL_OBJ_CONT.clear();
193 //================================================================================
195 * \brief Remove all VisualObjs of a study
197 //================================================================================
199 void RemoveVisuData()
201 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
202 ( SUIT_Session::session()->activeApplication() );
204 ViewManagerList viewMgrs = app->viewManagers();
205 for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
206 SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
207 if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type() ) {
208 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
209 for ( int iV = 0; iV < views.count(); ++iV ) {
210 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
211 vtkRenderer *aRenderer = vtkWnd->getRenderer();
212 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
213 vtkActorCollection *actors = aCopy.GetActors();
214 for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
215 // size of actors changes inside the loop
216 if(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
218 vtkWnd->RemoveActor(actor);
226 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
227 for ( ; anIter != VISUAL_OBJ_CONT.end(); ) {
228 // for unknown reason, object destructor is not called, so clear object manually
229 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
230 anIter->second->GetUnstructuredGrid()->SetPoints(0);
231 VISUAL_OBJ_CONT.erase( anIter++ ); // anIter++ returns a copy of self before incrementing
235 //================================================================================
237 * \brief Notify the user on problems during visualization
239 //================================================================================
241 void OnVisuException()
245 // PAL16774 (Crash after display of many groups). Salome sometimes crashes just
246 // after or at showing this message, so we do an additional check of available memory
247 // char* buf = new char[100*1024];
249 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
250 QObject::tr("SMESH_VISU_PROBLEM"));
252 // no more memory at all: last resort
253 MESSAGE_BEGIN ( "SMESHGUI_VTKUtils::OnVisuException(), exception even at showing a message!!!" <<
254 std::endl << "Try to remove all visual data..." );
255 if (theVISU_MemoryReserve) {
256 delete theVISU_MemoryReserve;
257 theVISU_MemoryReserve = 0;
259 RemoveAllObjectsWithActors();
260 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
261 QObject::tr("SMESH_VISU_PROBLEM_CLEAR"));
262 MESSAGE_END ( "...done" );
265 //================================================================================
267 * \brief Returns an updated visual object
269 //================================================================================
271 TVisualObjPtr GetVisualObj(const char* theEntry, bool nulData){
272 TVisualObjPtr aVisualObj;
275 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
276 if(anIter != VISUAL_OBJ_CONT.end()){
277 aVisualObj = anIter->second;
279 SalomeApp_Application* app =
280 dynamic_cast<SalomeApp_Application*>( SMESHGUI::activeStudy()->application() );
281 _PTR(Study) aStudy = SMESH::getStudy();
282 _PTR(SObject) aSObj = aStudy->FindObjectID(theEntry);
284 _PTR(GenericAttribute) anAttr;
285 if(aSObj->FindAttribute(anAttr,"AttributeIOR")){
286 _PTR(AttributeIOR) anIOR = anAttr;
287 CORBA::String_var aVal = anIOR->Value().c_str();
288 CORBA::Object_var anObj = app->orb()->string_to_object( aVal.in() );
289 if(!CORBA::is_nil(anObj)){
290 //Try narrow to SMESH_Mesh interface
291 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
292 if(!aMesh->_is_nil()){
293 aVisualObj.reset(new SMESH_MeshObj(aMesh));
294 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
295 VISUAL_OBJ_CONT.insert(aValue);
297 //Try narrow to SMESH_Group interface
298 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObj);
299 if(!aGroup->_is_nil()){
300 _PTR(SObject) aFatherSObj = aSObj->GetFather();
301 if(!aFatherSObj) return aVisualObj;
302 aFatherSObj = aFatherSObj->GetFather();
303 if(!aFatherSObj) return aVisualObj;
304 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
305 TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
306 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
307 aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj));
308 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
309 VISUAL_OBJ_CONT.insert(aValue);
312 //Try narrow to SMESH_subMesh interface
313 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
314 if(!aSubMesh->_is_nil()){
315 _PTR(SObject) aFatherSObj = aSObj->GetFather();
316 if(!aFatherSObj) return aVisualObj;
317 aFatherSObj = aFatherSObj->GetFather();
318 if(!aFatherSObj) return aVisualObj;
319 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
320 TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
321 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
322 aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj));
323 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
324 VISUAL_OBJ_CONT.insert(aValue);
332 INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!");
333 return TVisualObjPtr();
336 bool objModified = false;
341 objModified = aVisualObj->NulData();
343 objModified = aVisualObj->Update();
346 MESSAGE ( "Exception in SMESHGUI_VTKUtils::GetVisualObj()" );
347 RemoveVisualObjectWithActors( theEntry ); // remove this object
354 // PAL16631. Measurements showed that to show aVisualObj in SHADING(default) mode,
355 // ~5 times more memory is used than it occupies.
356 // Warn the user if there is less free memory than 30 sizes of a grid
357 // TODO: estimate memory usage in other modes and take current mode into account
358 int freeMB = SMDS_Mesh::CheckMemory(true);
359 int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024;
360 //MESSAGE("SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB << ", usedMB=" <<usedMB);
361 if ( freeMB > 0 && usedMB * 5 > freeMB ) {
362 bool continu = false;
363 if ( usedMB * 3 > freeMB )
364 // don't even try to show
365 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
366 QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
368 // there is a chance to succeed
369 continu = SUIT_MessageBox::warning
370 (SMESHGUI::desktop(),
371 QObject::tr("SMESH_WRN_WARNING"),
372 QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
373 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
374 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
376 // remove the corresponding actors from all views
377 RemoveVisualObjectWithActors( theEntry );
387 /*! Return active view window, if it instantiates SVTK_ViewWindow class,
388 * otherwise find or create corresponding view window, make it active and return it.
389 * \note Active VVTK_ViewWindow can be returned, because it inherits SVTK_ViewWindow.
391 SVTK_ViewWindow* GetViewWindow (const SalomeApp_Module* theModule,
392 bool createIfNotFound)
394 SalomeApp_Application* anApp;
396 anApp = theModule->getApp();
398 anApp = dynamic_cast<SalomeApp_Application*>
399 (SUIT_Session::session()->activeApplication());
402 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow()))
405 SUIT_ViewManager* aViewManager =
406 anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound);
408 if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
409 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
410 aViewWindow->raise();
411 aViewWindow->setFocus();
420 SVTK_ViewWindow* FindVtkViewWindow (SUIT_ViewManager* theMgr,
421 SUIT_ViewWindow * theWindow)
426 QVector<SUIT_ViewWindow*> views = theMgr->getViews();
427 if( views.contains( theWindow ) )
428 return GetVtkViewWindow( theWindow );
433 SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow* theWindow){
434 return dynamic_cast<SVTK_ViewWindow*>(theWindow);
437 /* SUIT_ViewWindow* GetActiveWindow()
439 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
442 SUIT_ViewManager* mgr = app->activeViewManager();
444 return mgr->getActiveView();
449 SVTK_ViewWindow* GetCurrentVtkView(){
450 return GetVtkViewWindow( GetActiveWindow() );
454 void RepaintCurrentView()
456 if (SVTK_ViewWindow* wnd = GetCurrentVtkView())
460 wnd->getRenderer()->Render();
464 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintCurrentView()" );
470 void RepaintViewWindow(SVTK_ViewWindow* theWindow)
474 theWindow->getRenderer()->Render();
475 theWindow->Repaint();
478 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintViewWindow(SVTK_ViewWindow*)" );
483 void RenderViewWindow(SVTK_ViewWindow* theWindow)
487 theWindow->getRenderer()->Render();
488 theWindow->Repaint();
491 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RenderViewWindow(SVTK_ViewWindow*)" );
497 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){
504 MESSAGE ( "Exception in SMESHGUI_VTKUtils::FitAll()" );
511 SMESH_Actor* FindActorByEntry(SUIT_ViewWindow *theWindow,
512 const char* theEntry)
514 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
515 vtkRenderer *aRenderer = aViewWindow->getRenderer();
516 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
517 vtkActorCollection *aCollection = aCopy.GetActors();
518 aCollection->InitTraversal();
519 while(vtkActor *anAct = aCollection->GetNextActor()){
520 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
521 if(anActor->hasIO()){
522 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
523 if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
534 SMESH_Actor* FindActorByEntry(const char* theEntry){
535 return FindActorByEntry(GetActiveWindow(),theEntry);
539 SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){
540 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
544 if(!CORBA::is_nil(theObject)){
545 _PTR(Study) aStudy = getStudy();
546 CORBA::String_var anIOR = app->orb()->object_to_string( theObject );
547 _PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in());
549 CORBA::String_var anEntry = aSObject->GetID().c_str();
550 return FindActorByEntry(anEntry.in());
557 SMESH_Actor* CreateActor(const char* theEntry,
560 SMESH_Actor *anActor = NULL;
561 if(TVisualObjPtr aVisualObj = GetVisualObj(theEntry)){
562 _PTR(SObject) aSObj = getStudy()->FindObjectID(theEntry);
564 _PTR(GenericAttribute) anAttr;
565 if(aSObj->FindAttribute(anAttr,"AttributeName")){
566 _PTR(AttributeName) aName = anAttr;
567 std::string aNameVal = aName->Value();
568 anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear);
571 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( aSObj ));
572 if(!CORBA::is_nil(aGroup) && anActor)
576 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
577 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
578 c = SMESH::GetColor( "SMESH", "default_grp_color", c );
579 SALOMEDS::Color aColor = aGroup->GetColor();
580 if( !( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 ))
583 aColor.G = c.greenF();
584 aColor.B = c.blueF();
585 aGroup->SetColor( aColor );
587 if( aGroup->GetType() == SMESH::NODE )
588 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
589 else if( aGroup->GetType() == SMESH::EDGE )
590 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
591 else if( aGroup->GetType() == SMESH::ELEM0D )
592 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
593 else if( aGroup->GetType() == SMESH::BALL )
594 anActor->SetBallColor( aColor.R, aColor.G, aColor.B );
595 else if( aGroup->GetType() == SMESH::VOLUME )
596 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, deltaV );
598 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, deltaF );
602 //MESSAGE("CreateActor " << anActor);
604 if( SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI() )
605 aSMESHGUI->addActorAsObserver( anActor );
610 void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
611 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
614 //MESSAGE("DisplayActor " << theActor);
615 vtkWnd->AddActor(theActor);
619 MESSAGE ( "Exception in SMESHGUI_VTKUtils::DisplayActor()" );
626 void RemoveActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor)
628 if ( SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)) {
629 //MESSAGE("RemoveActor " << theActor);
630 vtkWnd->RemoveActor(theActor);
631 if(theActor->hasIO()){
632 Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
633 if(anIO->hasEntry()){
634 std::string anEntry = anIO->getEntry();
635 VISUAL_OBJ_CONT.erase(anEntry);
643 //================================================================================
645 * \brief Return true if there are no SMESH actors in a view
647 //================================================================================
649 bool noSmeshActors(SUIT_ViewWindow *theWnd)
651 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWnd)) {
652 vtkRenderer *aRenderer = aViewWindow->getRenderer();
653 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
654 vtkActorCollection *aCollection = aCopy.GetActors();
655 aCollection->InitTraversal();
656 while(vtkActor *anAct = aCollection->GetNextActor())
657 if(dynamic_cast<SMESH_Actor*>(anAct))
663 bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
665 //MESSAGE("UpdateView");
667 SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd);
671 SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd);
675 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( vtkWnd->getViewManager()->study() );
682 vtkRenderer *aRenderer = aViewWnd->getRenderer();
683 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
684 vtkActorCollection *aCollection = aCopy.GetActors();
685 aCollection->InitTraversal();
689 while (vtkActor *anAct = aCollection->GetNextActor()) {
690 if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
691 //MESSAGE("--- display " << anActor);
692 anActor->SetVisibility(true);
694 if(anActor->hasIO()){
695 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
696 if(anIO->hasEntry()){
697 aStudy->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
706 //MESSAGE("---case eDisplayOnly");
707 while (vtkActor *anAct = aCollection->GetNextActor()) {
708 if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
709 //MESSAGE("--- erase " << anActor);
710 anActor->SetVisibility(false);
713 aStudy->setVisibilityStateForAll(Qtx::HiddenState);
716 if (SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)) {
720 //MESSAGE("--- display " << anActor);
722 anActor->SetVisibility(true);
723 if (theAction == eDisplayOnly) aRenderer->ResetCameraClippingRange();
724 aStudy->setVisibilityState(theEntry, Qtx::ShownState);
727 //MESSAGE("--- erase " << anActor);
728 anActor->SetVisibility(false);
729 aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
739 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(theWnd->getViewManager()->study());
740 TVisualObjPtr aVisualObj;
741 if ( (aVisualObj = GetVisualObj(theEntry)) && aVisualObj->IsValid())
743 if ((anActor = CreateActor(theEntry,true))) {
744 bool needFitAll = noSmeshActors(theWnd); // fit for the first object only
745 DisplayActor(theWnd,anActor);
746 anActor->SetVisibility(true);
747 aStudy->setVisibilityState(theEntry, Qtx::ShownState);
748 // FitAll(); - PAL16770(Display of a group performs an automatic fit all)
749 if (needFitAll) FitAll();
766 bool UpdateView(EDisplaing theAction, const char* theEntry) {
767 //MESSAGE("UpdateView");
768 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
769 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
770 if ( SUIT_ViewManager* vm = app->activeViewManager() )
772 SUIT_ViewWindow *aWnd = vm->getActiveView();
773 return UpdateView(aWnd,theAction,theEntry);
778 void UpdateView( bool withChildrenOfSelected )
780 if ( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()) {
781 LightApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
782 SALOME_ListIO selected; mgr->selectedObjects( selected );
784 if ( selected.Extent() == 0 ) {
785 vtkRenderer* aRenderer = aWnd->getRenderer();
786 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
787 vtkActorCollection *aCollection = aCopy.GetActors();
788 aCollection->InitTraversal();
789 while(vtkActor *anAct = aCollection->GetNextActor()){
790 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
792 if (!Update(anActor->getIO(),anActor->GetVisibility()))
793 break; // avoid multiple warnings if visu failed
799 SALOME_ListIteratorOfListIO anIter( selected );
800 for( ; anIter.More(); anIter.Next())
802 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
803 if ( !Update( anIO, true ))
804 break; // avoid multiple warnings if visu failed
806 if ( withChildrenOfSelected ) // update all visible children
808 QString aFatherID = anIO->getEntry();
809 vtkRenderer* aRenderer = aWnd->getRenderer();
810 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
811 vtkActorCollection *aCollection = aCopy.GetActors();
812 aCollection->InitTraversal();
813 while ( vtkActor *anAct = aCollection->GetNextActor() ) {
814 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct )) {
815 if ( anActor->hasIO() && anActor->GetVisibility() )
817 QString aChildID = anActor->getIO()->getEntry();
818 if ( aChildID.size() > aFatherID.size() &&
819 aChildID.startsWith( aFatherID ))
820 if ( ! Update( anActor->getIO(), true ))
828 RepaintCurrentView();
833 bool Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
836 if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry())) {
838 UpdateView(SMESH::eDisplay,theIO->getEntry());
844 bool UpdateNulData(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
846 //MESSAGE("UpdateNulData");
847 if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry(), true)) {
849 UpdateView(SMESH::eDisplay,theIO->getEntry());
855 void UpdateSelectionProp( SMESHGUI* theModule )
860 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
863 MESSAGE( "UpdateSelectionProp: Application is null" );
867 SUIT_ViewManager* vm = app->activeViewManager();
870 MESSAGE( "UpdateSelectionProp: View manager is null" );
874 QVector<SUIT_ViewWindow*> views = vm->getViews();
876 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
879 MESSAGE( "UpdateSelectionProp: Resource manager is null" );
883 SMESH_ActorProps::props()->reset();
886 aHiColor = mgr->colorValue( "SMESH", "selection_object_color", Qt::white ),
887 aSelColor = mgr->colorValue( "SMESH", "selection_element_color", Qt::yellow ),
888 aPreColor = mgr->colorValue( "SMESH", "highlight_color", Qt::cyan );
890 int aElem0DSize = mgr->integerValue("SMESH", "elem0d_size", 5);
891 // int aBallSize = mgr->integerValue("SMESH", "ball_elem_size", 5);
892 int aLineWidth = mgr->integerValue("SMESH", "element_width", 1);
893 int maxSize = aElem0DSize;
894 if (aElem0DSize > maxSize) maxSize = aElem0DSize;
895 if (aLineWidth > maxSize) maxSize = aLineWidth;
896 // if (aBallSize > maxSize) maxSize = aBallSize;
899 SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
900 SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 ),
901 SP3 = mgr->doubleValue( "SMESH", "selection_precision_object", 0.025 );
903 for ( int i=0, n=views.count(); i<n; i++ )
905 // update VTK viewer properties
906 if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] ))
908 // mesh element selection
909 aVtkView->SetSelectionProp(aSelColor.red()/255.,
910 aSelColor.green()/255.,
911 aSelColor.blue()/255.);
913 aVtkView->SetSelectionTolerance(SP1, SP2, SP3);
916 aVtkView->SetPreselectionProp(aPreColor.red()/255.,
917 aPreColor.green()/255.,
918 aPreColor.blue()/255.);
920 vtkRenderer* aRenderer = aVtkView->getRenderer();
921 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
922 vtkActorCollection *aCollection = aCopy.GetActors();
923 aCollection->InitTraversal();
924 while ( vtkActor *anAct = aCollection->GetNextActor() ) {
925 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct) ) {
926 anActor->UpdateSelectionProps();
934 void UpdateFontProp( SMESHGUI* theModule )
936 if ( !theModule ) return;
938 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
941 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
944 double anRGBNd[3] = {1,1,1};
945 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
947 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
949 bool anItalicNd = false;
950 bool aShadowNd = false;
952 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
953 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
954 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
955 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
956 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
958 anItalicNd = f.italic();
959 aShadowNd = f.overline();
960 aSizeNd = f.pointSize();
963 double anRGBEl[3] = {0,1,0};
964 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
966 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
968 bool anItalicEl = false;
969 bool aShadowEl = false;
971 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
972 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
974 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
975 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
976 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
978 anItalicEl = f.italic();
979 aShadowEl = f.overline();
980 aSizeEl = f.pointSize();
983 ViewManagerList vmList;
984 app->viewManagers( SVTK_Viewer::Type(), vmList );
985 foreach ( SUIT_ViewManager* vm, vmList ) {
986 QVector<SUIT_ViewWindow*> views = vm->getViews();
987 foreach ( SUIT_ViewWindow* vw, views ) {
988 // update VTK viewer properties
989 if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( vw ) ) {
991 vtkRenderer* aRenderer = aVtkView->getRenderer();
992 VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() );
993 vtkActorCollection* aCollection = aCopy.GetActors();
994 aCollection->InitTraversal();
995 while ( vtkActor* anAct = aCollection->GetNextActor() ) {
996 if ( SMESH_NodeLabelActor* anActor = dynamic_cast< SMESH_NodeLabelActor* >( anAct ) ) {
997 anActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
999 else if ( SMESH_CellLabelActor* anActor = dynamic_cast< SMESH_CellLabelActor* >( anAct ) ) {
1000 anActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
1003 aVtkView->Repaint( false );
1009 //----------------------------------------------------------------------------
1011 GetSelector(SUIT_ViewWindow *theWindow)
1013 if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow))
1014 return aWnd->GetSelector();
1019 void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
1020 SVTK_Selector* theSelector)
1023 theSelector->SetFilter(theFilter);
1026 Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_Selector* theSelector)
1028 return theSelector->GetFilter(theId);
1031 bool IsFilterPresent(int theId, SVTK_Selector* theSelector)
1033 return theSelector->IsFilterPresent(theId);
1036 void RemoveFilter(int theId, SVTK_Selector* theSelector)
1038 theSelector->RemoveFilter(theId);
1041 void RemoveFilters(SVTK_Selector* theSelector)
1043 for ( int id = SMESH::NodeFilter; theSelector && id < SMESH::LastFilter; id++ )
1044 theSelector->RemoveFilter( id );
1047 bool IsValid(SALOME_Actor* theActor, int theCellId,
1048 SVTK_Selector* theSelector)
1050 return theSelector->IsValid(theActor,theCellId);
1054 //----------------------------------------------------------------------------
1055 void SetPointRepresentation(bool theIsVisible)
1057 if ( SVTK_ViewWindow* aViewWindow = GetCurrentVtkView() ) {
1058 vtkRenderer *aRenderer = aViewWindow->getRenderer();
1059 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1060 vtkActorCollection *aCollection = aCopy.GetActors();
1061 aCollection->InitTraversal();
1062 while(vtkActor *anAct = aCollection->GetNextActor()){
1063 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1064 if(anActor->GetVisibility()){
1065 anActor->SetPointRepresentation(theIsVisible);
1069 RepaintCurrentView();
1074 void SetPickable(SMESH_Actor* theActor)
1076 if ( SVTK_ViewWindow* aWnd = GetCurrentVtkView() ) {
1077 int anIsAllPickable = (theActor == NULL);
1078 vtkRenderer *aRenderer = aWnd->getRenderer();
1079 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1080 vtkActorCollection *aCollection = aCopy.GetActors();
1081 aCollection->InitTraversal();
1082 while(vtkActor *anAct = aCollection->GetNextActor()){
1083 if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
1084 if(anActor->GetVisibility()){
1085 anActor->SetPickable(anIsAllPickable);
1090 theActor->SetPickable(!anIsAllPickable);
1091 RepaintCurrentView();
1096 //----------------------------------------------------------------------------
1097 int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
1098 const Handle(SALOME_InteractiveObject)& theIO,
1102 TColStd_IndexedMapOfInteger aMapIndex;
1103 theSelector->GetIndex(theIO,aMapIndex);
1105 for(int i = 1; i <= aMapIndex.Extent(); i++)
1106 theName += QString(" %1").arg(aMapIndex(i));
1108 return aMapIndex.Extent();
1111 int GetNameOfSelectedElements(SVTK_Selector* theSelector,
1112 const Handle(SALOME_InteractiveObject)& theIO,
1116 TColStd_IndexedMapOfInteger aMapIndex;
1117 theSelector->GetIndex(theIO,aMapIndex);
1119 typedef std::set<int> TIdContainer;
1120 TIdContainer anIdContainer;
1121 for( int i = 1; i <= aMapIndex.Extent(); i++)
1122 anIdContainer.insert(aMapIndex(i));
1124 TIdContainer::const_iterator anIter = anIdContainer.begin();
1125 for( ; anIter != anIdContainer.end(); anIter++)
1126 theName += QString(" %1").arg(*anIter);
1128 return aMapIndex.Extent();
1132 int GetEdgeNodes(SVTK_Selector* theSelector,
1133 const TVisualObjPtr& theVisualObject,
1137 const SALOME_ListIO& selected = theSelector->StoredIObjects();
1139 if ( selected.Extent() != 1 )
1142 Handle(SALOME_InteractiveObject) anIO = selected.First();
1143 if ( anIO.IsNull() || !anIO->hasEntry() )
1146 TColStd_IndexedMapOfInteger aMapIndex;
1147 theSelector->GetIndex( anIO, aMapIndex );
1148 if ( aMapIndex.Extent() != 2 )
1151 int anObjId = -1, anEdgeNum = -1;
1152 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
1153 int aVal = aMapIndex( i );
1157 anEdgeNum = abs( aVal ) - 1;
1160 if ( anObjId == -1 || anEdgeNum == -1 )
1163 return theVisualObject->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
1166 //----------------------------------------------------------------------------
1167 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr,
1168 const Handle(SALOME_InteractiveObject)& theIO,
1172 if(theIO->hasEntry()){
1173 if(FindActorByEntry(theIO->getEntry())){
1174 TColStd_IndexedMapOfInteger aMapIndex;
1175 theMgr->GetIndexes(theIO,aMapIndex);
1176 for(int i = 1; i <= aMapIndex.Extent(); i++){
1177 theName += QString(" %1").arg(aMapIndex(i));
1179 return aMapIndex.Extent();
1185 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr, QString& theName)
1188 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1189 if(selected.Extent() == 1){
1190 Handle(SALOME_InteractiveObject) anIO = selected.First();
1191 return GetNameOfSelectedNodes(theMgr,anIO,theName);
1197 int GetNameOfSelectedElements(LightApp_SelectionMgr * theMgr,
1198 const Handle(SALOME_InteractiveObject)& theIO,
1202 if(theIO->hasEntry()){
1203 if(FindActorByEntry(theIO->getEntry())){
1204 TColStd_IndexedMapOfInteger aMapIndex;
1205 theMgr->GetIndexes(theIO,aMapIndex);
1206 typedef std::set<int> TIdContainer;
1207 TIdContainer anIdContainer;
1208 for( int i = 1; i <= aMapIndex.Extent(); i++)
1209 anIdContainer.insert(aMapIndex(i));
1210 TIdContainer::const_iterator anIter = anIdContainer.begin();
1211 for( ; anIter != anIdContainer.end(); anIter++){
1212 theName += QString(" %1").arg(*anIter);
1214 return aMapIndex.Extent();
1221 int GetNameOfSelectedElements(LightApp_SelectionMgr *theMgr, QString& theName)
1224 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1226 if( selected.Extent() == 1){
1227 Handle(SALOME_InteractiveObject) anIO = selected.First();
1228 return GetNameOfSelectedElements(theMgr,anIO,theName);
1233 int GetSelected(LightApp_SelectionMgr* theMgr,
1234 TColStd_IndexedMapOfInteger& theMap,
1235 const bool theIsElement)
1238 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1240 if ( selected.Extent() == 1 )
1242 Handle(SALOME_InteractiveObject) anIO = selected.First();
1243 if ( anIO->hasEntry() ) {
1244 theMgr->GetIndexes( anIO, theMap );
1247 return theMap.Extent();
1251 int GetEdgeNodes( LightApp_SelectionMgr* theMgr, int& theId1, int& theId2 )
1253 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1255 if ( selected.Extent() != 1 )
1258 Handle(SALOME_InteractiveObject) anIO = selected.First();
1259 if ( anIO.IsNull() || !anIO->hasEntry() )
1262 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1266 TColStd_IndexedMapOfInteger aMapIndex;
1267 theMgr->GetIndexes( anIO, aMapIndex );
1268 if ( aMapIndex.Extent() != 2 )
1271 int anObjId = -1, anEdgeNum = -1;
1272 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
1273 int aVal = aMapIndex( i );
1277 anEdgeNum = abs( aVal );
1280 if ( anObjId == -1 || anEdgeNum == -1 )
1283 return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
1286 void SetControlsPrecision( const long theVal )
1288 if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
1290 vtkRenderer *aRenderer = aWnd->getRenderer();
1291 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1292 vtkActorCollection *aCollection = aCopy.GetActors();
1293 aCollection->InitTraversal();
1295 while ( vtkActor *anAct = aCollection->GetNextActor())
1297 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) )
1299 anActor->SetControlsPrecision( theVal );
1300 anActor->SetControlMode( anActor->GetControlMode() );
1307 //----------------------------------------------------------------------------
1308 // internal function
1309 void ComputeBoundsParam( double theBounds[6],
1310 double theDirection[3],
1311 double theMinPnt[3],
1312 double& theMaxBoundPrj,
1313 double& theMinBoundPrj )
1315 //Enlarge bounds in order to avoid conflicts of precision
1316 for(int i = 0; i < 6; i += 2){
1317 static double EPS = 1.0E-3;
1318 double aDelta = (theBounds[i+1] - theBounds[i])*EPS;
1319 theBounds[i] -= aDelta;
1320 theBounds[i+1] += aDelta;
1323 double aBoundPoints[8][3] = { {theBounds[0],theBounds[2],theBounds[4]},
1324 {theBounds[1],theBounds[2],theBounds[4]},
1325 {theBounds[0],theBounds[3],theBounds[4]},
1326 {theBounds[1],theBounds[3],theBounds[4]},
1327 {theBounds[0],theBounds[2],theBounds[5]},
1328 {theBounds[1],theBounds[2],theBounds[5]},
1329 {theBounds[0],theBounds[3],theBounds[5]},
1330 {theBounds[1],theBounds[3],theBounds[5]}};
1333 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1334 theMinBoundPrj = theMaxBoundPrj;
1335 for(int i = 1; i < 8; i++){
1336 double aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1337 if(theMaxBoundPrj < aTmp){
1338 theMaxBoundPrj = aTmp;
1341 if(theMinBoundPrj > aTmp){
1342 theMinBoundPrj = aTmp;
1345 double *aMinPnt = aBoundPoints[aMaxId];
1346 theMinPnt[0] = aMinPnt[0];
1347 theMinPnt[1] = aMinPnt[1];
1348 theMinPnt[2] = aMinPnt[2];
1351 // internal function
1352 void DistanceToPosition( double theBounds[6],
1353 double theDirection[3],
1357 double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1358 ComputeBoundsParam(theBounds,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1359 double aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1360 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1361 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1362 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1365 // internal function (currently unused, left just in case)
1366 void PositionToDistance( double theBounds[6],
1367 double theDirection[3],
1371 double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1372 ComputeBoundsParam(theBounds,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1373 double aPrj = vtkMath::Dot(theDirection,thePos);
1374 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1377 bool ComputeClippingPlaneParameters( std::list<vtkActor*> theActorList,
1378 double theNormal[3],
1380 double theBounds[6],
1381 double theOrigin[3] )
1383 bool anIsOk = false;
1384 anIsOk = ComputeBounds( theActorList, theBounds );
1390 DistanceToPosition( theBounds, theNormal, theDist, theOrigin );
1394 bool ComputeBounds( std::list<vtkActor*> theActorList,
1395 double theBounds[6])
1397 bool anIsOk = false;
1398 theBounds[0] = theBounds[2] = theBounds[4] = VTK_DOUBLE_MAX;
1399 theBounds[1] = theBounds[3] = theBounds[5] = -VTK_DOUBLE_MAX;
1400 std::list<vtkActor*>::iterator anIter = theActorList.begin();
1401 for( ; anIter != theActorList.end(); anIter++ ) {
1402 if( vtkActor* aVTKActor = *anIter ) {
1403 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
1405 anActor->GetUnstructuredGrid()->GetBounds( aBounds );
1406 theBounds[0] = std::min( theBounds[0], aBounds[0] );
1407 theBounds[1] = std::max( theBounds[1], aBounds[1] );
1408 theBounds[2] = std::min( theBounds[2], aBounds[2] );
1409 theBounds[3] = std::max( theBounds[3], aBounds[3] );
1410 theBounds[4] = std::min( theBounds[4], aBounds[4] );
1411 theBounds[5] = std::max( theBounds[5], aBounds[5] );
1419 #ifndef DISABLE_PLOT2DVIEWER
1420 //================================================================================
1422 * \brief Find all SMESH_Actor's in the View Window.
1423 * If actor contains Plot2d_Histogram object remove it from each Plot2d Viewer.
1425 //================================================================================
1427 void ClearPlot2Viewers( SUIT_ViewWindow* theWindow )
1429 if ( SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow) ) {
1430 vtkRenderer *aRenderer = aViewWindow->getRenderer();
1431 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1432 vtkActorCollection *aCollection = aCopy.GetActors();
1433 aCollection->InitTraversal();
1434 while(vtkActor *anAct = aCollection->GetNextActor()){
1435 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1436 if(anActor->hasIO() && anActor->GetPlot2Histogram() ){
1437 ProcessIn2DViewers(anActor,RemoveFrom2dViewer);
1446 } // end of namespace SMESH