1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 // Author : Laurent CORNABE
38 #include <qptrvector.h>
39 #include <qcolordialog.h>
42 #include <vtkRenderer.h>
43 #include <vtkRenderWindow.h>
44 #include <vtkActorCollection.h>
47 #include "SALOME_LifeCycleCORBA.hxx"
49 #include "SUIT_ResourceMgr.h"
50 #include "SUIT_MessageBox.h"
52 #include "SUIT_ViewWindow.h"
53 #include "SUIT_ViewManager.h"
55 #include "CAM_Module.h"
57 #include "SVTK_RenderWindow.h"
58 #include "SVTK_ViewWindow.h"
59 #include "SVTK_ViewModel.h"
60 #include "SVTK_Functor.h"
62 #include "SPlot2d_ViewModel.h"
63 #include "VisuGUI_SetupPlot2dDlg.h"
64 #include "Plot2d_SetupCurveDlg.h"
66 #include "OB_Browser.h"
68 #include "SALOME_ListIO.hxx"
69 #include "SALOME_ListIteratorOfListIO.hxx"
71 #include "SalomeApp_Application.h"
72 #include "SalomeApp_DataModel.h"
73 #include "SalomeApp_Study.h"
74 #include "LightApp_SelectionMgr.h"
75 #include "LightApp_Selection.h"
76 #include "LightApp_Preferences.h"
78 #include "QtxAction.h"
80 #include "VISUConfig.hh"
81 #include "VISU_Gen_i.hh"
82 #include "VISU_Mesh_i.hh"
83 #include "VISU_Table_i.hh"
84 #include "VISU_Result_i.hh"
85 #include "VISU_View_i.hh"
86 #include "VISU_ViewManager_i.hh"
87 #include "VISU_Plot3D_i.hh"
89 #include "VISU_Actor.h"
91 #include "VisuGUI_Prs3dTools.h"
92 #include "VisuGUI_Tools.h"
94 #include "VisuGUI_PopupTools.h"
95 #include "VisuGUI_NameDlg.h"
96 #include "VisuGUI_FileDlg.h"
97 #include "VisuGUI_CursorDlg.h"
98 #include "VisuGUI_Selection.h"
99 #include "VisuGUI_TimeAnimation.h"
100 #include "VisuGUI_EditContainerDlg.h"
101 #include "VisuGUI_NonIsometricDlg.h"
102 #include "VisuGUI_ClippingDlg.h"
103 #include "VisuGUI_Plot3DDlg.h"
104 #include "VisuGUI_CubeAxesDlg.h"
105 #include "VisuGUI_OffsetDlg.h"
106 #include "VisuGUI_Displayer.h"
108 #include "VISU_ScalarMap_i.hh"
109 #include "VisuGUI_ScalarBarDlg.h"
111 #include "VISU_DeformedShape_i.hh"
112 #include "VisuGUI_DeformedShapeDlg.h"
114 #include "VISU_IsoSurfaces_i.hh"
115 #include "VisuGUI_IsoSurfacesDlg.h"
117 #include "VISU_CutPlanes_i.hh"
118 #include "VisuGUI_CutPlanesDlg.h"
120 #include "VISU_CutLines_i.hh"
121 #include "VisuGUI_CutLinesDlg.h"
123 #include "VISU_StreamLines_i.hh"
124 #include "VisuGUI_StreamLinesDlg.h"
126 #include "VISU_Vectors_i.hh"
127 #include "VisuGUI_VectorsDlg.h"
129 #include "VisuGUI_TableDlg.h"
131 #include "SALOMEconfig.h"
132 #include CORBA_SERVER_HEADER(MED_Gen)
134 #include "utilities.h"
136 #include "VisuGUI_ActionsDef.h"
138 using namespace VISU;
141 static int MYDEBUG = 1;
143 static int MYDEBUG = 0;
146 //////////////////////////////////////////////////
148 //////////////////////////////////////////////////
151 SalomeApp_Module( "VISU" ),
166 if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
167 if ( CheckLock(GetCStudy(GetAppStudy(this))) )
169 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
172 aFilter.append( tr("FLT_MED_FILES") );
173 aFilter.append( tr("FLT_ALL_FILES") );
175 QFileInfo aFileInfo =
176 SUIT_FileDlg::getFileName(GetDesktop(this),
179 tr("MEN_IMPORT_FROM_FILE"),
181 if(aFileInfo.exists()) {
182 application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
184 VISU::Result_var aResult;
185 bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
186 if (VisuGUI_FileDlg::IsBuild) {
187 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
188 if (!CORBA::is_nil(aResult.in()))
189 if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
190 if (!aRes->IsPossible())
191 SUIT_MessageBox::warn1(GetDesktop(this),
193 tr("ERR_CANT_BUILD_PRESENTATION"),
199 aResourceMgr->setValue("VISU", "full_med_loading", false);
200 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
201 aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
204 if (CORBA::is_nil(aResult.in())) {
205 SUIT_MessageBox::warn1(GetDesktop(this),
207 tr("ERR_ERROR_IN_THE_FILE"),
210 application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
211 UpdateObjBrowser(this);
221 if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
222 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
223 if ( CheckLock(aStudy) )
226 SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
229 aFilter.append( tr("FLT_MED_FILES") );
230 aFilter.append( tr("FLT_ALL_FILES") );
232 QFileInfo aFileInfo =
233 SUIT_FileDlg::getFileName(GetDesktop(this),
236 tr("MEN_EXPLORE_MED_FILE"),
238 if(aFileInfo.exists()){
239 application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
240 std::string aStudyName = aStudy->Name();
243 aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
247 SUIT_MessageBox::warn1(GetDesktop(this),
249 tr("ERR_ERROR_IN_THE_FILE"),
252 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
253 getApp()->updateObjectBrowser(true); // as need to update MED tree
254 getApp()->updateActions();
261 OnImportTableFromFile()
263 if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
264 if ( CheckLock(GetCStudy(GetAppStudy(this))) )
268 aFilter.append( tr("FLT_TABLE_FILES") );
269 aFilter.append( tr("FLT_ALL_FILES") );
271 QFileInfo aFileInfo =
272 SUIT_FileDlg::getFileName(GetDesktop(this),
275 tr("MEN_IMPORT_TABLE"),
277 if (aFileInfo.exists()) {
278 application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
280 CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
282 if (CORBA::is_nil(anObject.in())) {
283 SUIT_MessageBox::warn1(GetDesktop(this),
285 tr("ERR_ERROR_IN_THE_FILE"),
288 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
289 UpdateObjBrowser(this);
296 OnExportTableToFile()
298 if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
300 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
302 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
303 SALOME_ListIO aListIO;
304 aSelectionMgr->selectedObjects(aListIO);
306 if (aListIO.Extent() > 0) {
307 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
308 if (anIO->hasEntry()) {
309 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
312 // find table attribute
314 _PTR(GenericAttribute) anAttr;
316 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
318 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
319 // if the current SObject is a table title
320 // we take a father contaning the table
321 aSObj = aSObj->GetFather();
323 if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
326 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
333 // get table title in order to have default name of the file
336 _PTR(AttributeTableOfReal) aTabAttr (anAttr);
337 if (!aTabAttr) return;
338 aTitle = aTabAttr->GetTitle().c_str();
340 _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
341 if (!aTabAttr) return;
342 aTitle = aTabAttr->GetTitle().c_str();
344 aTitle.simplifyWhiteSpace();
345 aTitle = aTitle.replace(QRegExp(" "), "_").replace(QRegExp("\\*"), "" );
347 // get default path for the file
348 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
349 QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
350 if (aDir.isEmpty()) {
351 aDir = aResourceMgr->stringValue("VISU","InputDir","");
352 if (aDir.isEmpty()) {
353 aDir = getenv("CSF_PATHData");
356 QString aPath = Qtx::addSlash(aDir) + aTitle;
358 // get name for the file
360 aFilter.append("Table Files (*.xls)");
362 QFileInfo aFileInfo =
363 SUIT_FileDlg::getFileName(GetDesktop(this),
366 tr("MEN_EXPORT_TABLE"), // "Export Table To File"
370 QString aFile = aFileInfo.filePath();
371 if (!aFile.isEmpty()) {
372 application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
373 aDir = Qtx::dir(aFile, true);
374 aResourceMgr->setValue("VISU", "OutputDir", aDir);
377 GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
378 application()->putInfo(aFile + " " + tr("INF_DONE"));
379 } catch(std::exception& ex) {
381 SUIT_MessageBox::warn1(GetDesktop(this),
383 tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
386 INFOS(tr("ERR_ERROR_DURING_EXPORT"));
387 SUIT_MessageBox::warn1(GetDesktop(this),
389 tr("ERR_ERROR_DURING_EXPORT"),
401 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
402 if (CheckLock(aCStudy))
404 SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
406 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
407 SALOME_ListIO aListIO;
408 aSelectionMgr->selectedObjects(aListIO);
410 SALOME_ListIteratorOfListIO It (aListIO);
411 QApplication::setOverrideCursor(Qt::waitCursor);
412 for (; It.More(); It.Next()) {
413 Handle(SALOME_InteractiveObject) anIO = It.Value();
414 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
415 if (!aSObject->_is_nil()) {
416 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
417 if (!CORBA::is_nil(anObject)) {
418 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
419 if (!CORBA::is_nil(aMED.in()))
420 GetVisuGen(this)->ImportMed(aSObject);
421 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
422 if (!CORBA::is_nil(aField.in()))
423 GetVisuGen(this)->ImportMedField(aField);
425 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
426 SALOMEDS::GenericAttribute_var anAttr;
427 aSFather->FindAttribute(anAttr, "AttributeName");
428 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
429 CORBA::String_var aValue = aName->Value();
430 if (strcmp(aValue.in(), "MEDFIELD") == 0)
431 GetVisuGen(this)->ImportMed(aSObject);
435 UpdateObjBrowser(this, true);
436 QApplication::restoreOverrideCursor();
440 CreateCurves( SalomeApp_Module* theModule,
441 VISU::CutLines_i* thePrs,
443 const bool theCreate = true )
447 VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
451 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
452 _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
454 if ( !theCreate && aSObject ) {
456 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
457 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
458 for (; aIter->More(); aIter->Next()) {
459 _PTR(SObject) aTblObj = aIter->Value();
461 _PTR(GenericAttribute) anAttr;
462 if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
463 aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
470 if ( aCutDlg->isGenerateTable() ) {
471 GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
472 if ( aCutDlg->isGenerateCurves() ) {
474 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
475 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
476 for (; aIter->More(); aIter->Next()) {
477 _PTR(SObject) aTblObj = aIter->Value();
479 _PTR(GenericAttribute) anAttr;
480 if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
481 CreatePlot( theModule, aTblObj );
489 if (!theCreate && aSObject) {
490 UpdateObjBrowser(theModule);
498 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
499 if (CheckLock(aStudy))
502 // Get selected SObject
503 Handle(SALOME_InteractiveObject) anIO;
504 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
505 if (anIO.IsNull() || !anIO->hasEntry())
508 // create a VTK view window if it does not exist
509 GetViewWindow( this, /*create=*/true );
511 CreateMesh(this, anIO);
518 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
519 if (CheckLock(aStudy))
522 // create a VTK view window if it does not exist
523 GetViewWindow( this, /*create=*/true );
525 // Get selected SObject
526 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
527 SALOME_ListIO aListIO;
528 aSelectionMgr->selectedObjects(aListIO);
529 SALOME_ListIteratorOfListIO anIter (aListIO);
530 for (; anIter.More(); anIter.Next()) {
531 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
532 if (anIO.IsNull() || !anIO->hasEntry())
535 CreateMesh(this, anIO);
543 CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
549 OnCreateDeformedShape()
551 CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
558 CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
563 OnCreateIsoSurfaces()
565 CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
572 CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,0>(this);
579 CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,0>(this);
584 OnCreateStreamLines()
586 CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
593 CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,0>(this);
600 CheckLock(GetCStudy(GetAppStudy(this)));
601 GetVisuGen( this )->CreateContainer();
602 UpdateObjBrowser(this);
609 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
611 QApplication::setOverrideCursor(Qt::waitCursor);
613 LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
614 mgr->selectedObjects(aList);
616 Handle(SALOME_InteractiveObject) anIO;
617 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
619 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
620 if ( !CORBA::is_nil( anObject ) ) {
621 // is it Prs3d object ?
622 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
624 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
625 UpdateViewer( this, aPrsObject );
626 SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true );
628 vw->highlight(anIO, 1);
633 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
635 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
636 PlotCurve( this, aCurve, VISU::eDisplay );
640 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
642 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
643 PlotContainer( this, aContainer, VISU::eDisplay );
647 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
649 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
650 PlotTable( this, aTable, VISU::eDisplay );
655 SVTK_ViewWindow* vw = GetViewWindow( this );
657 vw->getRenderer()->ResetCameraClippingRange();
660 QApplication::restoreOverrideCursor();
675 if(MYDEBUG) MESSAGE("OnErasePrs");
677 QApplication::setOverrideCursor(Qt::waitCursor);
679 SVTK_ViewWindow* vw = GetViewWindow( this );
681 vw->unHighlightAll();
684 LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
685 mgr->selectedObjects(aList);
687 Handle(SALOME_InteractiveObject) anIO;
688 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
690 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
691 ErasePrs( this, anObject, false );
697 QApplication::restoreOverrideCursor();
705 Handle(SALOME_InteractiveObject) anIO;
706 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
707 EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg,1>(this, aPrs3d);
708 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
709 aViewWindow->highlight(anIO, 1);
717 OnEditDeformedShape()
719 Handle(SALOME_InteractiveObject) anIO;
720 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
721 EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg,1>(this, aPrs3d);
722 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
723 aViewWindow->highlight(anIO, 1);
733 Handle(SALOME_InteractiveObject) anIO;
734 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
735 EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg,0>(this, aPrs3d);
736 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
737 aViewWindow->highlight(anIO, 1);
747 Handle(SALOME_InteractiveObject) anIO;
748 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
749 EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg,0>(this, aPrs3d);
750 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
751 aViewWindow->highlight(anIO, 1);
761 Handle(SALOME_InteractiveObject) anIO;
762 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
763 EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg,1>(this, aPrs3d);
764 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
765 aViewWindow->highlight(anIO, 1);
775 Handle(SALOME_InteractiveObject) anIO;
776 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
777 EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg,1>(this, aPrs3d);
778 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
779 aViewWindow->highlight(anIO, 1);
789 Handle(SALOME_InteractiveObject) anIO;
790 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
791 EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg,1>(this, aPrs3d);
792 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
793 aViewWindow->highlight(anIO, 1);
803 Handle(SALOME_InteractiveObject) anIO;
804 if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){
805 EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg,0>(this, aPrs3d);
806 if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){
807 aViewWindow->highlight(anIO, 1);
817 if (SVTK_ViewWindow* vw = GetViewWindow()) {
818 vw->unHighlightAll();
819 if (vtkRenderer *aRen = vw->getRenderer()) {
821 vtkActorCollection *anActColl = aRen->GetActors();
822 for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
823 if (anActor->GetVisibility() > 0)
824 if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
825 anVISUActor = anVISUActor->GetParent();
826 anVISUActor->VisibilityOff();
831 } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
840 ChangeRepresentation(this, VISU::SURFACEFRAME);
847 ChangeRepresentation(this, VISU::INSIDEFRAME);
854 ChangeRepresentation(this, VISU::WIREFRAME);
861 ChangeRepresentation(this, VISU::SHADED);
868 ChangeRepresentation(this, VISU::POINT);
875 ChangeRepresentation(this, VISU::SHRINK);
882 SetShading(this, true);
889 SetShading(this, false);
896 Handle(SALOME_InteractiveObject) anIO;
897 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
898 if (CORBA::is_nil(anObject)) return;
899 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
900 if (!aServant.in()) return;
902 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
905 SVTK_ViewWindow* vw = GetViewWindow();
908 VISU_Actor* anActor = GetActor(aPrs3d, vw);
909 if (!anActor) return;
911 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
912 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
913 SALOMEDS::Color anOldColor, aNewColor;
914 int aRepresent = anActor->GetRepresentation();
916 switch (aRepresent) {
918 anOldColor = aMesh->GetNodeColor();
920 case VISU::WIREFRAME :
921 case VISU::INSIDEFRAME :
922 anOldColor = aMesh->GetLinkColor();
925 case VISU::SURFACEFRAME :
926 anOldColor = aMesh->GetCellColor();
929 } else if (aDeformedShape) {
930 anOldColor = aDeformedShape->GetColor();
935 QColor aColor (int(255*anOldColor.R),
936 int(255*anOldColor.G),
937 int(255*anOldColor.B));
938 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
939 if (aColorNew.isValid()) {
940 aNewColor.R = aColorNew.red()/255.;
941 aNewColor.G = aColorNew.green()/255.;
942 aNewColor.B = aColorNew.blue()/255.;
944 switch (aRepresent) {
946 aMesh->SetNodeColor(aNewColor);
948 case VISU::WIREFRAME :
949 case VISU::INSIDEFRAME :
950 aMesh->SetLinkColor(aNewColor);
953 case VISU::SURFACEFRAME :
954 aMesh->SetCellColor(aNewColor);
958 aDeformedShape->SetColor(aNewColor);
960 RecreateActor(this, aPrs3d);
966 OnChangeWireframeColor()
968 Handle(SALOME_InteractiveObject) anIO;
969 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
970 if (CORBA::is_nil(anObject)) return;
971 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
972 if (!aServant.in()) return;
974 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
977 SVTK_ViewWindow* vw = GetViewWindow();
980 VISU_Actor* anActor = GetActor(aPrs3d, vw);
981 if (!anActor) return;
983 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
984 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
985 QColor aColor (int(255*anOldColor.R),
986 int(255*anOldColor.G),
987 int(255*anOldColor.B));
988 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
989 if (aColorNew.isValid()) {
990 aNewColor.R = aColorNew.red()/255.;
991 aNewColor.G = aColorNew.green()/255.;
992 aNewColor.B = aColorNew.blue()/255.;
993 aMesh->SetLinkColor(aNewColor);
994 RecreateActor(this, aMesh);
1003 Handle(SALOME_InteractiveObject) anIO;
1004 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1005 if (CORBA::is_nil(anObject)) return;
1006 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1007 if (!aServant.in()) return;
1009 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1010 if (!aPrsObject) return;
1012 SVTK_ViewWindow* vw = GetViewWindow();
1015 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1016 if (!anActor) return;
1018 VisuGUI_CursorDlg* CursorDlg =
1019 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
1021 CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1022 CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1023 CursorDlg->SpinBox1->setMinValue(0);
1024 CursorDlg->SpinBox1->setMaxValue(100);
1026 float oldopac = anActor->GetOpacity();
1027 int intopac = int(oldopac*100. + 0.5);
1028 CursorDlg->SpinBox1->setValue(intopac);
1030 int ret = CursorDlg->exec();
1032 intopac = CursorDlg->SpinBox1->value();
1033 float newopac = intopac/100.;
1034 anActor->SetOpacity(newopac);
1043 Handle(SALOME_InteractiveObject) anIO;
1044 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1045 if (CORBA::is_nil(anObject)) return;
1046 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1047 if (!aServant.in()) return;
1049 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1050 if (!aPrsObject) return;
1052 SVTK_ViewWindow* vw = GetViewWindow();
1055 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1056 if (!anActor) return;
1058 VisuGUI_CursorDlg* CursorDlg =
1059 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1061 CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1062 CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1063 CursorDlg->SpinBox1->setMinValue(1);
1064 CursorDlg->SpinBox1->setMaxValue(10);
1066 float oldlwid = anActor->GetLineWidth();
1067 int intlwid = int(oldlwid);
1068 CursorDlg->SpinBox1->setValue(intlwid);
1070 int ret = CursorDlg->exec();
1072 intlwid = CursorDlg->SpinBox1->value();
1073 float newlwid = intlwid;
1074 anActor->SetLineWidth(newlwid);
1083 Handle(SALOME_InteractiveObject) anIO;
1084 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1086 if ( !CORBA::is_nil( anObject ) ) {
1087 VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1088 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1089 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1090 if( !CORBA::is_nil( aTable ) ) {
1091 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1093 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1098 // possibly this is Table SObject
1099 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1102 if( !IsSObjectTable( SO ) )
1105 VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1108 //SAL2670 Orientation of show tables
1109 VisuGUI_TableDlg::ttAuto,
1118 Handle(SALOME_InteractiveObject) anIO;
1119 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1120 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1121 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1122 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1123 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1124 GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1125 UpdateObjBrowser(this);
1133 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1134 if (CheckLock(aCStudy))
1137 SALOME_ListIO aList;
1138 LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
1139 mgr->selectedObjects(aList,QString::null,false);
1140 int i = 0, nbSelected = aList.Extent();
1141 if (nbSelected < 1) return;
1143 const char* entries [nbSelected];
1144 Handle(SALOME_InteractiveObject) anIO;
1145 for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1147 if (anIO->hasEntry())
1148 entries[i++] = anIO->getEntry();
1151 if (nbSelected < 1) return;
1153 // There is a transaction
1154 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1155 aStudyBuilder->NewCommand();
1157 for (i = 0; i < nbSelected; i++) {
1158 _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1160 DeleteSObject(this, aCStudy, aSObject);
1164 // Finish transaction
1165 aStudyBuilder->CommitCommand();
1167 //GetActiveStudy()->unHighlightAll();
1168 UpdateObjBrowser(this, true);
1175 Handle(SALOME_InteractiveObject) anIO;
1176 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1178 _PTR(GenericAttribute) anAttr;
1179 _PTR(AttributeName) aName;
1181 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1183 if ( !CORBA::is_nil( anObject ) ) {
1184 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1185 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1186 // Table (VISU object) is selected
1187 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1188 if( !CORBA::is_nil( aTbl ) ) {
1189 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1191 _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1192 if ( IsSObjectTable(SO) ) {
1193 // get name of SObject
1194 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1196 SOName = QString( aName->Value().c_str() );
1198 VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
1199 if ( dlg->exec() == QDialog::Accepted ) {
1200 if ( !IsStudyLocked( aStudy ) ) {
1201 // if study is not locked - create new container, create curves and insert them
1202 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1204 QValueList<int> verIndices;
1205 dlg->getCurvesSource( horIndex, verIndices );
1206 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1207 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1208 if( !CORBA::is_nil( aContainer ) ) {
1209 VISU::Container_i* pContainer =
1210 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1212 for ( int i = 0; i < verIndices.count(); i++ ) {
1213 CORBA::Object_var aNewCurve =
1214 GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1215 if( !CORBA::is_nil( aNewCurve ) ) {
1216 VISU::Curve_i* pCrv =
1217 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1220 int marker, line, lineWidth;
1222 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1223 line, lineWidth, color) && !isAuto ) {
1225 c.R = color.red() /255.;
1226 c.G = color.green()/255.;
1227 c.B = color.blue() /255.;
1228 pCrv->SetColor( c );
1229 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1230 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1232 pContainer->AddCurve( pCrv->_this() );
1236 UpdateObjBrowser(this);
1237 PlotContainer( this, pContainer, VISU::eDisplay );
1243 // if study is locked just get curves info and plot them
1244 // if current viewer is of VIEW_PLOT2D type
1245 QPtrList<Plot2d_Curve> container;
1246 dlg->getCurves( container );
1247 if ( !container.isEmpty() ) {
1248 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1249 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1259 else if ( !anIO.IsNull() ) {
1260 // check if Table SObject is selected
1261 SO = aStudy->FindObjectID( anIO->getEntry() );
1262 if ( IsSObjectTable(SO) ) {
1263 // get name of SObject
1264 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1266 SOName = QString( aName->Value().c_str() );
1268 VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
1269 if ( dlg->exec() == QDialog::Accepted ) {
1270 if ( !IsStudyLocked( aStudy ) ) {
1271 // if study is not locked - create new table and container objects, create curves
1272 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1274 QValueList<int> verIndices;
1275 dlg->getCurvesSource( horIndex, verIndices );
1276 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1277 CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1278 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1279 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1280 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1281 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1283 if ( pContainer && pTable ) {
1284 for ( int i = 0; i < verIndices.count(); i++ ) {
1285 CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1286 ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1287 if( !CORBA::is_nil( aNewCurve ) ) {
1288 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1291 int marker, line, lineWidth;
1293 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1294 line, lineWidth, color) && !isAuto ) {
1296 c.R = color.red()/255.;
1297 c.G = color.green()/255.;
1298 c.B = color.blue()/255.;
1299 pCrv->SetColor( c );
1300 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1301 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1303 pContainer->AddCurve( pCrv->_this() );
1307 UpdateObjBrowser(this);
1308 PlotContainer( this, pContainer, VISU::eDisplay );
1313 // if study is locked just get curves info and plot them
1314 QPtrList<Plot2d_Curve> container;
1315 dlg->getCurves( container );
1316 if ( !container.isEmpty() ) {
1317 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1318 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1331 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1332 SALOME_ListIO aListIO;
1333 aSelectionMgr->selectedObjects(aListIO);
1334 if (aListIO.Extent() != 1) return;
1336 SalomeApp_Study* aAppStudy = GetAppStudy(this);
1337 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1338 CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1339 if (CORBA::is_nil( anObject )) return;
1341 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1342 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1344 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1345 if( !CORBA::is_nil( aCurve ) ) {
1346 VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1347 if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1348 Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1350 aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1351 aDlg.setMarker( (int)aDSCurve->GetMarker() );
1352 SALOMEDS::Color aColor = aDSCurve->GetColor();
1353 aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1354 if( aDlg.exec() == QDialog::Accepted ) {
1355 aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1356 aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1357 SALOMEDS::Color newColor;
1358 newColor.R = aDlg.getColor().red()/255.;
1359 newColor.G = aDlg.getColor().green()/255.;
1360 newColor.B = aDlg.getColor().blue()/255.;
1361 aDSCurve->SetColor( newColor );
1362 PlotCurve(this, aDSCurve, VISU::eDisplay);
1373 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1374 if (CheckLock(aCStudy))
1376 Handle(SALOME_InteractiveObject) anIO;
1377 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1378 if (anIO.IsNull() || CORBA::is_nil(anObject))
1381 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1382 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1384 CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1385 if (!CORBA::is_nil(aCnt)) {
1386 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1387 if (container && container->GetNbCurves() > 0) {
1389 UpdateObjBrowser(this);
1399 Handle(SALOME_InteractiveObject) anIO;
1400 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1401 if (CORBA::is_nil(anObject)) return;
1403 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1404 if (!aServant.in()) return;
1405 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1406 if (!aContainer) return;
1408 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1409 aDlg->initFromPrsObject(aContainer);
1411 aDlg->storeToPrsObject(aContainer);
1412 UpdateObjBrowser(this, true);
1421 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1422 if (CheckLock(aCStudy))
1425 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1426 if (aViewMgr->getType() != SVTK_Viewer::Type())
1429 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1430 SALOME_ListIO aListIO;
1431 aSelectionMgr->selectedObjects(aListIO);
1432 if (aListIO.Extent() > 1)
1435 if (aListIO.Extent() == 0) {
1436 VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1438 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1439 VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1441 UpdateObjBrowser(this);
1446 OnRestoreViewParams()
1448 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1449 if (aViewMgr->getType() != SVTK_Viewer::Type())
1452 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1453 SALOME_ListIO aListIO;
1454 aSelectionMgr->selectedObjects(aListIO);
1455 if (aListIO.Extent() != 1)
1458 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1459 //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1460 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1461 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1462 VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1469 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1470 if (CheckLock(aCStudy))
1473 Handle(SALOME_InteractiveObject) anIO;
1474 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1476 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1479 //TEST DU PARENT == VISU
1480 _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
1481 _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
1483 _PTR(AttributeName) aName (anAttr);
1484 QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1485 if (!Name.isEmpty()) {
1486 QApplication::setOverrideCursor(Qt::waitCursor);
1488 // rename specific objects
1489 if (!CORBA::is_nil(anObject)) {
1490 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1491 if (!CORBA::is_nil(aVisuObj)) {
1492 switch (aVisuObj->GetType()) {
1493 case VISU::TCURVE: // Curve object
1495 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1496 if (!CORBA::is_nil(aCurve)) {
1497 VISU::Curve_i* curve =
1498 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1500 curve->SetName(Name.latin1());
1504 case VISU::TTABLE: // Table object
1506 CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1507 if (!CORBA::is_nil(aTable)) {
1508 VISU::Table_i* table =
1509 dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1511 table->SetName(Name.latin1());
1515 case VISU::TCONTAINER: // Container object
1517 CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1518 if (!CORBA::is_nil(aContainer)) {
1519 VISU::Container_i* container =
1520 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1522 container->SetName(Name.latin1());
1533 // rename the study object
1534 aName->SetValue(Name.latin1()); // rename the SObject
1535 anIO->setName(Name.latin1()); // rename the InteractiveObject
1536 UpdateObjBrowser(this, false);
1538 QApplication::restoreOverrideCursor();
1547 new VisuGUI_ClippingDlg (this, "", false);
1555 Handle(SALOME_InteractiveObject) anIO;
1556 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1557 if (CORBA::is_nil(anObject)) return;
1558 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1559 if (!aServant.in()) return;
1561 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1562 if (!aPrsObject) return;
1564 SVTK_ViewWindow* vw = GetViewWindow();
1567 VISU_Actor* aActor = GetActor(aPrsObject, vw);
1568 if (!aActor) return;
1570 if (!aActor->GetVisibility()) {
1571 aActor->VisibilityOn();
1574 // Get sweep parameters
1575 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1577 double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1578 int aTemp = int(1.E6 * aTempoDbl);
1580 int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1581 int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1584 QApplication::setOverrideCursor(Qt::waitCursor);
1585 for (int j = 0; j < aCycles; j++) {
1586 for (int i = 0; i <= aSteps; i++) {
1588 float aPercents = float(i)/aSteps;
1589 aPrsObject->SetMapScale(aPercents);
1590 aPrsObject->UpdateActor(aActor);
1591 vw->getRenderWindow()->getRenderWindow()->Render();
1593 } catch (std::exception& exc) {
1594 INFOS("Follow exception was occured :\n" << exc.what());
1596 INFOS("Unknown exception was occured!");
1600 QApplication::restoreOverrideCursor();
1607 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1608 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1609 // new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1610 new VisuGUI_TimeAnimationDlg (this, aCStudy);
1612 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1613 SALOME_ListIO aListIO;
1614 aSelectionMgr->selectedObjects(aListIO);
1616 bool isDefined = false;
1618 SALOME_ListIteratorOfListIO It (aListIO);
1619 for (; It.More(); It.Next()) {
1620 _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1621 if (!aSObject) continue;
1622 if (getValue(aSObject, "myComment") == QString("FIELD")) {
1623 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1627 aAnimationDlg->addField(aSObject);
1629 } else if (aNbTimes == aNumber) {
1630 aAnimationDlg->addField(aSObject);
1635 if (isDefined) aAnimationDlg->show();
1636 else delete aAnimationDlg;
1639 //************************************************************************
1644 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1645 SALOME_ListIO aListIO;
1646 aSelectionMgr->selectedObjects(aListIO);
1648 if (aListIO.Extent() != 1)
1651 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1653 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1655 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1658 VISU::Storable::TRestoringMap aMap;
1659 _PTR(GenericAttribute) anAttr;
1660 if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1662 _PTR(AttributeComment) aComment (anAttr);
1663 string aComm = aComment->Value();
1664 QString strIn (aComm.c_str());
1665 VISU::Storable::StrToMap(strIn, aMap);
1667 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1668 if (aType != VISU::TANIMATION) return;
1670 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1671 new VisuGUI_TimeAnimationDlg(this, aCStudy);
1672 aAnimationDlg->restoreFromStudy(aSObj);
1673 aAnimationDlg->show();
1678 OnCopyPresentation()
1680 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1681 if (CheckLock(aCStudy))
1684 Handle(SALOME_InteractiveObject) anIO;
1685 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1686 if (CORBA::is_nil(anObject)) return;
1687 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1688 if (!aServant.in()) return;
1690 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1691 if (!aPrsObject) return;
1693 switch (aPrsObject->GetType()) {
1696 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1697 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1698 aSameMesh->SameAs(aMeshPrs);
1699 UpdateViewer(this, aSameMesh);
1702 case VISU::TSCALARMAP:
1704 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1705 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1706 aSameScalar->SameAs(aScalarPrs);
1707 UpdateViewer(this, aSameScalar);
1710 case VISU::TDEFORMEDSHAPE:
1712 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1713 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1714 aSameDeformed->SameAs(aDefPrs);
1715 UpdateViewer(this, aSameDeformed);
1718 case VISU::TCUTPLANES:
1720 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1721 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1722 aSameCut->SameAs(aCutPrs);
1723 UpdateViewer(this, aSameCut);
1726 case VISU::TCUTLINES:
1728 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1729 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1730 aSameCut->SameAs(aCutPrs);
1731 UpdateViewer(this, aSameCut);
1734 case VISU::TISOSURFACE:
1736 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1737 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1738 aSameIso->SameAs(aIsoPrs);
1739 UpdateViewer(this, aSameIso);
1742 case VISU::TSTREAMLINES:
1744 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1745 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1746 aSameLines->SameAs(aLinesPrs);
1747 UpdateViewer(this, aSameLines);
1750 case VISU::TVECTORS:
1752 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1753 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1754 aSameVectors->SameAs(aVectorsPrs);
1755 UpdateViewer(this, aSameVectors);
1760 VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1761 VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1762 aSamePlot3D->SameAs(aPlot3DPrs);
1763 UpdateViewer(this, aSamePlot3D);
1767 UpdateObjBrowser(this);
1774 if (GetViewWindow())
1775 (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1777 SUIT_MessageBox::warn1(GetDesktop(this),
1779 tr("ERR_ACTIVATE_VIEW3D"),
1787 VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1788 new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1789 false, Qt::WDestructiveClose);
1790 m_NonIsoDlg->show();
1797 //Show dialog that allows to select scale function and corresponding scale factor
1798 VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1806 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1807 SALOME_ListIO aListIO;
1808 aSelectionMgr->selectedObjects(aListIO);
1810 SALOME_ListIteratorOfListIO It (aListIO);
1812 // first find the bounds
1813 double aMin, aMax; bool first = true;
1814 for (; It.More(); It.Next()) {
1815 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1816 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1817 if (!aPrsList.empty()) {
1818 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1819 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1821 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1825 aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1827 if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1828 if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1836 // set the computed range to every selected ScalarMap
1837 bool update = false;
1838 for (It.Initialize(aListIO); It.More(); It.Next() ) {
1839 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1840 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1841 if (!aPrsList.empty()) {
1842 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1843 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1845 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1847 aScalar->SetRange(aMin, aMax);
1848 RecreateActor(this, aScalar);
1856 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1857 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1858 vw->getRenderer()->ResetCameraClippingRange();
1869 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1870 SALOME_ListIO aListIO;
1871 aSelectionMgr->selectedObjects(aListIO);
1873 SALOME_ListIteratorOfListIO It (aListIO);
1875 // restore the source range for every ScalarMap
1876 bool update = false;
1877 for (; It.More(); It.Next()) {
1878 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1879 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1880 if (!aPrsList.empty()) {
1881 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1882 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1884 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1886 aScalar->SetSourceRange();
1887 RecreateActor(this, aScalar);
1895 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1896 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1897 vw->getRenderer()->ResetCameraClippingRange();
1908 if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1909 VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1911 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1913 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1914 SALOME_ListIO aListIO;
1915 aSelectionMgr->selectedObjects(aListIO);
1917 SALOME_ListIteratorOfListIO It (aListIO);
1918 for (; It.More(); It.Next()) {
1919 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1920 if (anIO->hasEntry()) {
1921 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1923 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1924 if (!CORBA::is_nil(aCORBAObject)) {
1925 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1926 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1927 aDlg->addPresentation(aPrsObject);
1933 if (aDlg->getPrsCount() > 0)
1943 SVTK_ViewWindow* vw = GetViewWindow();
1945 ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1954 initialize( CAM_Application* theApp )
1956 SalomeApp_Module::initialize( theApp );
1969 QWidget* aParent = application()->desktop();
1970 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
1973 createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
1974 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
1975 this, SLOT(OnImportFromFile()));
1977 createAction( VISU_EXPLORE_MED, "", QIconSet(),
1978 tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
1979 this, SLOT(OnExploreMEDFile()));
1981 createAction( VISU_IMPORT_TABLE, "", QIconSet(),
1982 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
1983 this, SLOT(OnImportTableFromFile()));
1985 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
1986 createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
1987 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
1988 this, SLOT(OnCreateScalarMap()));
1990 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
1991 createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
1992 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
1993 this, SLOT(OnCreateDeformedShape()));
1995 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
1996 createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
1997 tr("MEN_VECTORS"), "", 0, aParent, false,
1998 this, SLOT(OnCreateVectors()));
2000 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
2001 createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
2002 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
2003 this, SLOT(OnCreateIsoSurfaces()));
2005 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
2006 createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
2007 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
2008 this, SLOT(OnCreateCutPlanes()));
2010 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
2011 createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
2012 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
2013 this, SLOT(OnCreateStreamLines()));
2015 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
2016 createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
2017 tr("MEN_CUT_LINES"), "", 0, aParent, false,
2018 this, SLOT(OnCreateCutLines()));
2020 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2021 createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
2022 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2023 this, SLOT(OnCreatePlot3D()));
2025 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2026 createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
2027 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2028 this, SLOT(OnCreatePlot2dView()));
2030 createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
2031 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
2032 this, SLOT(OnDeleteObjects()));
2034 createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
2035 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2036 this, SLOT(OnShowTable()));
2038 createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
2039 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2040 this, SLOT(OnPlotData()));
2042 createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
2043 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2044 this, SLOT(OnExportTableToFile()));
2046 createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
2047 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2048 this, SLOT(OnImportMedField()));
2050 createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
2051 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2052 this, SLOT(OnImportMedField()));
2054 createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2055 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2056 this, SLOT(OnImportMedField()));
2058 createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
2059 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2060 this, SLOT(OnCreateMesh()));
2062 createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2063 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2064 this, SLOT(OnCreateManyMesh()));
2066 createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2067 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2068 this, SLOT(OnTranslatePrs()));
2070 createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2071 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2072 this, SLOT(OnMergeScalarBars()));
2074 createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2075 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2076 this, SLOT(OnFreeScalarBars()));
2078 createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
2079 tr("MEN_ERASE"), "", 0, aParent, false,
2080 this, SLOT(OnErasePrs()));
2082 createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
2083 tr("MEN_DISPLAY"), "", 0, aParent, false,
2084 this, SLOT(OnDisplayPrs()));
2086 createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
2087 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2088 this, SLOT(OnDisplayOnlyPrs()));
2090 createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
2091 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2092 this, SLOT(OnCopyPresentation()));
2094 createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
2095 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2096 this, SLOT(OnCurveProperties()));
2098 createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2099 this, SLOT(OnRename()));
2101 createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
2102 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2103 this, SLOT(OnEditContainer()));
2105 createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
2106 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2107 this, SLOT(OnClearContainer()));
2109 createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2110 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2111 this, SLOT(OnSaveViewParams()));
2112 createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2113 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2114 this, SLOT(OnSaveViewParams()));
2116 createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2117 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2118 this, SLOT(OnRestoreViewParams()));
2120 //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2121 // tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2122 // this, SLOT(OnDeleteObjects()));
2124 createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2125 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2126 this, SLOT(OnArrangeActors()));
2128 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2129 createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
2130 tr("MEN_POINTS"), "", 0, aParent, false,
2131 this, SLOT(OnMakePoints()));
2133 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2134 createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
2135 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2136 this, SLOT(OnMakeWireframe()));
2138 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2139 createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
2140 tr("MEN_SURFACE"), "", 0, aParent, false,
2141 this, SLOT(OnMakeSurface()));
2143 createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
2144 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2145 this, SLOT(OnMakeInsideframe()));
2147 createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
2148 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2149 this, SLOT(OnMakeSurfaceframe()));
2151 createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
2152 tr("MEN_SHRINK"), "", 0, aParent, false,
2153 this, SLOT(OnMakeShrink()));
2155 createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
2156 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2157 this, SLOT(OnMakeShrink()));
2159 createAction( VISU_SHADING, tr("MEN_SHADING"), QIconSet(),
2160 tr("MEN_SHADING"), "", 0, aParent, false,
2161 this, SLOT(OnSetShadingOn()));
2163 createAction( VISU_NOSHADING, tr("MEN_NOSHADING"), QIconSet(),
2164 tr("MEN_NOSHADING"), "", 0, aParent, false,
2165 this, SLOT(OnSetShadingOff()));
2167 createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
2168 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2169 this, SLOT(OnChangeColor()));
2171 createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
2172 tr("MEN_COLOR"), "", 0, aParent, false,
2173 this, SLOT(OnChangeColor()));
2175 createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
2176 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2177 this, SLOT(OnChangeWireframeColor()));
2179 createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
2180 tr("MEN_OPACITY"), "", 0, aParent, false,
2181 this, SLOT(OnChangeOpacity()));
2183 createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
2184 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2185 this, SLOT(OnChangeLines()));
2188 createAction( VISU_EDIT_SCALARMAP, tr("MEN_EDIT_PRS"), QIconSet(),
2189 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2190 this, SLOT(OnEditScalarMap()));
2192 createAction( VISU_EDIT_DEFORMEDSHAPE, tr("MEN_EDIT_PRS"), QIconSet(),
2193 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2194 this, SLOT(OnEditDeformedShape()));
2196 createAction( VISU_EDIT_CUTPLANES, tr("MEN_EDIT_PRS"), QIconSet(),
2197 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2198 this, SLOT(OnEditCutPlanes()));
2200 createAction( VISU_EDIT_CUTLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2201 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2202 this, SLOT(OnEditCutLines()));
2204 createAction( VISU_EDIT_ISOSURFACE, tr("MEN_EDIT_PRS"), QIconSet(),
2205 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2206 this, SLOT(OnEditIsoSurfaces()));
2208 createAction( VISU_EDIT_VECTORS, tr("MEN_EDIT_PRS"), QIconSet(),
2209 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2210 this, SLOT(OnEditVectors()));
2212 createAction( VISU_EDIT_STREAMLINES, tr("MEN_EDIT_PRS"), QIconSet(),
2213 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2214 this, SLOT(OnEditStreamLines()));
2216 createAction( VISU_EDIT_PLOT3D, tr("MEN_EDIT_PRS"), QIconSet(),
2217 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2218 this, SLOT(OnEditPlot3D()));
2221 createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
2222 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2223 this, SLOT(OnCreateTable()));
2225 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2226 createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
2227 tr("MEN_SWEEP"), "", 0, aParent, false,
2228 this, SLOT(OnSweep()));
2230 createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2231 tr("MEN_CLIPPING"), "", 0, aParent, false,
2232 this, SLOT(OnClippingPlanes()));
2234 createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2235 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2236 this, SLOT(OnSelectionInfo()));
2238 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2239 createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
2240 tr("MEN_ANIMATION"), "", 0, aParent, false,
2241 this, SLOT(OnTimeAnimation()));
2243 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2244 createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2245 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2246 this, SLOT(OnEraseAll()));
2248 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2249 createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2250 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2251 //this, SLOT(OnEraseAll()));
2254 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2255 createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2256 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2257 //this, SLOT(OnEraseAll()));
2260 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2261 createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2262 tr("MEN_SCALING"), "", 0, aParent, false,
2263 this, SLOT(OnScaling()));
2265 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2266 createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2267 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2268 this, SLOT(OnCubeAxes()));
2270 createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2271 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2272 this, SLOT(OnShowAnimation()));
2279 // Add actions to menus
2281 aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2282 createMenu( separator(), aMenuId, -1, 10 );
2283 createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2284 createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2285 createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2287 aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2288 createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2289 createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2290 createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2291 createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2292 createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2293 createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2294 createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2295 createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2297 aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2298 createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2300 aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2302 createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2303 createMenu( VISU_POINTS, parentId, 10 ); // points
2304 createMenu( VISU_WIREFRAME, parentId, 10 ); // wireframe
2305 createMenu( VISU_SURFACE, parentId, 10 ); // surface
2306 createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2307 createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2308 createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2309 createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2310 createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2317 int aToolId = createTool(tr("TOOL_VISUALISATION"));
2318 createTool( VISU_SCALAR_MAP, aToolId );
2319 createTool( VISU_DEFORMED_SHAPE, aToolId );
2320 createTool( VISU_VECTORS, aToolId );
2321 createTool( VISU_ISO_SURFACES, aToolId );
2322 createTool( VISU_CUT_PLANES, aToolId );
2323 createTool( VISU_CUT_LINES, aToolId );
2324 createTool( VISU_STREAM_LINES, aToolId );
2325 createTool( VISU_PLOT_3D, aToolId );
2327 aToolId = createTool(tr("TOOL_REPRESENTATION"));
2328 createTool( VISU_POINTS, aToolId );
2329 createTool( VISU_WIREFRAME, aToolId );
2330 createTool( VISU_SURFACE, aToolId );
2331 createTool( VISU_ERASE_ALL, aToolId );
2332 createTool( VISU_GLOBAL_SELECTION, aToolId );
2333 createTool( VISU_PARTIAL_SELECTION, aToolId );
2334 createTool( VISU_SCALING, aToolId );
2335 createTool( VISU_CUBE_AXES, aToolId );
2342 // Prepare popup menus
2343 QtxPopupMgr* mgr = popupMgr();
2345 // VISU root commands
2346 mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2347 mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2348 mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2350 //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2353 mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2354 mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2355 mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2356 mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2357 mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2358 mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2359 mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2360 mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2362 mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2363 mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2365 mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2368 mgr->insert( action( VISU_EDIT_SCALARMAP ), -1, -1, -1 );
2369 mgr->insert( action( VISU_EDIT_DEFORMEDSHAPE ), -1, -1, -1 );
2370 mgr->insert( action( VISU_EDIT_CUTPLANES ), -1, -1, -1 );
2371 mgr->insert( action( VISU_EDIT_CUTLINES ), -1, -1, -1 );
2372 mgr->insert( action( VISU_EDIT_ISOSURFACE ), -1, -1, -1 );
2373 mgr->insert( action( VISU_EDIT_VECTORS ), -1, -1, -1 );
2374 mgr->insert( action( VISU_EDIT_STREAMLINES ), -1, -1, -1 );
2375 mgr->insert( action( VISU_EDIT_PLOT3D ), -1, -1, -1 );
2376 mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2379 mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2382 mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2385 mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2388 //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2389 //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2390 //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2392 mgr->insert( separator(), -1, -1, -1 );
2394 mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2395 mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2396 mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2398 // "Representation" submenu
2399 int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2400 mgr->insert( action( VISU_POINTS ) , parentId, -1, -1 ); // points
2401 mgr->insert( action( VISU_WIREFRAME ) , parentId, -1, -1 ); // wireframe
2402 mgr->insert( action( VISU_SURFACE ) , parentId, -1, -1 ); // surface
2403 mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2404 mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2405 mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink
2406 mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink
2407 mgr->insert( separator(), parentId, -1, -1 );
2408 mgr->insert( action( VISU_SHADING ) , parentId, -1, -1 ); // shading
2409 mgr->insert( action( VISU_NOSHADING ) , parentId, -1, -1 ); // noshading
2411 // "Properties" submenu
2412 parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2413 mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2414 mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2415 mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color
2416 mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity
2417 mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2419 mgr->insert( separator(), -1, -1, -1 );
2421 // Other presentations management
2422 mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2423 mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2425 mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2426 mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2428 mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2429 mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2431 mgr->insert( separator(), -1, -1, -1 );
2433 // view parameters commands
2434 mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2435 mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
2436 mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2437 //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2439 mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2441 mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2443 mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2447 QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2448 "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2450 // VISU root commands
2451 QString aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TVISUGEN'";
2452 mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2453 mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2454 mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2456 // timestamp commands
2457 aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TTIMESTAMP'";
2458 mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2459 mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2460 mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2461 mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2462 mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2463 aRule += " and nbComponents>1";
2464 mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2465 mgr->setRule( action( VISU_VECTORS ), aRule, true );
2466 mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2468 // display/erase commands
2469 QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))";
2470 QString aTableOrCont = "(type='VISU::TTABLE' and nbChildren>0) or type='VISU::TCONTAINER'";
2471 QString orCurveVisible = "or (type='VISU::TCURVE' and isVisible)";
2472 QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")";
2473 QString aPrsVisible = "(($type in {'VISU::TMESH' " + aPrsAll + "}) and isVisible)";
2474 QString aPrsInvisible = "(($type in {'VISU::TMESH' " + aPrsAll + "})" + andInvisible + ")";
2476 QString anEraseRule = "selcount>0 and (" + aPrsVisible +
2477 " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + ")))";
2479 QString aDisplayRule = "selcount>0 and (" + aPrsInvisible +
2480 " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + ")))";
2482 QString aDOnlyRule = "selcount>0 and (($type in {'VISU::TMESH' " + aPrsAll + "})"
2483 " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or"
2484 " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))))";
2486 mgr->setRule( action( VISU_ERASE ), anEraseRule, true );
2487 mgr->setRule( action( VISU_DISPLAY ), aDisplayRule, true );
2488 mgr->setRule( action( VISU_DISPLAY_ONLY ), aDOnlyRule, true );
2490 aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2491 mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2493 aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2494 mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2495 mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2498 aRule = "selcount=1 and type='VISU::TVIEW3D'";
2499 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2500 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2501 mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2502 //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2504 mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2506 // 3D presentations commands
2507 QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2508 QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2509 QString aSurfType = " and $type in {'VISU::TMESH'}";
2510 QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2511 "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2512 QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2513 "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2515 aRule = "selcount=1";
2516 mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2518 // "Representation" submenu
2519 QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2520 QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2521 QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2522 QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2523 QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2525 mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints, true );
2526 mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr, true );
2527 mgr->setRule( action( VISU_SURFACE ) , aRule + aPrsType + aNotSurfac, true );
2528 mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2529 mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2531 mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true );
2532 mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2534 mgr->setRule( action( VISU_SHADING ) , aRule + " and isScalarMapAct=1 and isShading=0", true );
2535 mgr->setRule( action( VISU_NOSHADING ), aRule + " and isScalarMapAct=1 and isShading=1", true );
2537 // "Properties" submenu
2538 mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2539 mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2540 mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2541 " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2542 "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2543 mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2544 mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2547 QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2549 aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
2550 mgr->setRule( action( VISU_RENAME ), aRule, true );
2552 // copy presentation command
2553 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2554 mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2557 aRule = "selcount=1 and type='VISU::TCURVE'";
2558 mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2560 // curve container commands
2561 aRule = "client='ObjectBrowser' and selcount=1 and type='VISU::TCONTAINER'";
2562 mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2563 mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2565 mgr->setRule( action( VISU_EDIT_SCALARMAP ),
2566 "selcount=1 and type='VISU::TSCALARMAP'", true );
2567 mgr->setRule( action( VISU_EDIT_DEFORMEDSHAPE ),
2568 "selcount=1 and type='VISU::TDEFORMEDSHAPE'", true );
2569 mgr->setRule( action( VISU_EDIT_CUTPLANES ),
2570 "selcount=1 and type='VISU::TCUTPLANES'", true );
2571 mgr->setRule( action( VISU_EDIT_CUTLINES ),
2572 "selcount=1 and type='VISU::TCUTLINES'", true );
2573 mgr->setRule( action( VISU_EDIT_ISOSURFACE ),
2574 "selcount=1 and type='VISU::TISOSURFACE'", true );
2575 mgr->setRule( action( VISU_EDIT_VECTORS ),
2576 "selcount=1 and type='VISU::TVECTORS'", true );
2577 mgr->setRule( action( VISU_EDIT_STREAMLINES ),
2578 "selcount=1 and type='VISU::TSTREAMLINES'", true );
2579 mgr->setRule( action( VISU_EDIT_PLOT3D ),
2580 "selcount=1 and type='VISU::TPLOT3D'", true );
2582 aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2583 mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2585 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2586 mgr->setRule( action( VISU_SWEEP ), aRule, true );
2588 // "Selection info" popup item
2589 aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2590 mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2592 aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2593 mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2595 aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2596 mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2597 mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2599 //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2600 //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2603 //***************************************************************************
2604 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2606 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2608 OB_Browser* ob = getApp()->objectBrowser();
2609 bool isOBClient = (ob && theClient == ob->popupClientType());
2611 LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2612 SALOME_ListIO aListIO;
2613 aSelectionMgr->selectedObjects(aListIO);
2615 if (aListIO.Extent() < 1) return;
2617 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2619 // Check if "Merge Scalar Range" can be applied
2621 SALOME_ListIteratorOfListIO It (aListIO);
2622 for (; It.More(); It.Next()) {
2623 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2625 if (!anIO.IsNull() && anIO->hasEntry()) {
2626 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2627 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2628 if (CORBA::is_nil(aCORBAObject)) {
2629 _PTR(GenericAttribute) anAttr;
2630 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2631 _PTR(AttributeComment) aComment (anAttr);
2632 string aComm = aComment->Value();
2633 QString strIn (aComm.c_str());
2634 VISU::Storable::TRestoringMap pMap;
2635 VISU::Storable::StrToMap(strIn, pMap);
2637 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2638 if (isExist && aType == VISU::TTIMESTAMP) {
2639 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2641 for (; anIter->More(); anIter->Next()) {
2642 aPrs = anIter->Value();
2643 if (!aPrs) continue;
2644 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2645 nbPrs += aSubList.size();
2654 theMenu->insertSeparator();
2655 action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2656 action( VISU_FREE_SCALAR_BARS )->addTo(theMenu);
2659 theMenu->insertSeparator();
2661 // Check if some (nb > 0) removable objects selected
2662 if (isOBClient && IsRemovableSelected(this)) {
2663 action( VISU_DELETE_OBJS )->addTo(theMenu);
2666 // Check single selection
2667 if (aListIO.Extent() != 1) return;
2669 Handle(SALOME_InteractiveObject) anIO;
2670 VISU::Storable::TRestoringMap aMap;
2671 CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2673 _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2675 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2677 if (aType == VISU::TANIMATION) {
2678 action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2680 } else if (isOBClient) {
2681 if (IsSObjectTable(SO)) {
2682 action( VISU_SHOW_TABLE )->addTo(theMenu);
2683 action( VISU_CREATE_CURVES )->addTo(theMenu);
2684 action( VISU_EXPORT_TABLE )->addTo(theMenu);
2685 theMenu->insertSeparator();
2687 if (!CORBA::is_nil(anObject)) {
2688 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2689 if (!CORBA::is_nil(aMED.in())) {
2690 action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2693 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2694 if (!CORBA::is_nil(aField)) {
2695 action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2698 _PTR(SObject) aSFather = SO->GetFather();
2700 _PTR(GenericAttribute) anAttr;
2701 aSFather->FindAttribute(anAttr, "AttributeName");
2703 _PTR(AttributeName) aName (anAttr);
2704 std::string aValue = aName->Value();
2705 if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2706 action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2716 //***************************************************************************
2719 windows( QMap<int, int>& theMap ) const
2722 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2723 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2729 viewManagers( QStringList& theList ) const
2732 theList.append( SVTK_Viewer::Type() );
2740 CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2741 return QString(anIOR.in());
2747 activateModule( SUIT_Study* theStudy )
2749 SalomeApp_Module::activateModule( theStudy );
2751 setMenuShown( true );
2752 setToolShown( true );
2759 deactivateModule( SUIT_Study* theStudy )
2761 setMenuShown( false );
2762 setToolShown( false );
2764 SalomeApp_Module::deactivateModule( theStudy );
2770 createSelection() const
2772 return new VisuGUI_Selection( (SalomeApp_Module*)this );
2775 //******************************************************************
2776 void VisuGUI::studyActivated()
2778 GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2786 return new VisuGUI();
2790 void VisuGUI::createPreferences()
2792 int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2794 int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2795 int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2796 addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2797 int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2798 addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2801 fam.append( tr( "VISU_FONT_ARIAL" ) );
2802 fam.append( tr( "VISU_FONT_COURIER" ) );
2803 fam.append( tr( "VISU_FONT_TIMES" ) );
2804 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2806 setPreferenceProperty( tfont, "families", fam );
2807 setPreferenceProperty( tfont, "system", false );
2808 setPreferenceProperty( tfont, "widget_flags", wflag );
2809 setPreferenceProperty( lfont, "families", fam );
2810 setPreferenceProperty( lfont, "system", false );
2811 setPreferenceProperty( lfont, "widget_flags", wflag );
2813 int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2815 int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2816 setPreferenceProperty( numcol, "min", 2 );
2817 setPreferenceProperty( numcol, "max", 64 );
2819 int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2820 setPreferenceProperty( numlab, "min", 2 );
2821 setPreferenceProperty( numlab, "max", 65 );
2823 int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2824 int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2825 QStringList orients;
2826 orients.append( tr( "VISU_VERTICAL" ) );
2827 orients.append( tr( "VISU_HORIZONTAL" ) );
2828 QValueList<QVariant> indices;
2829 indices.append( 0 );
2830 indices.append( 1 );
2831 setPreferenceProperty( orient, "strings", orients );
2832 setPreferenceProperty( orient, "indexes", indices );
2834 int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2835 int xv = addPreference( tr( "VISU_X" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2836 int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
2837 int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2838 int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2839 setPreferenceProperty( xv, "step", 0.1 );
2840 setPreferenceProperty( yv, "step", 0.1 );
2841 setPreferenceProperty( wv, "step", 0.1 );
2842 setPreferenceProperty( hv, "step", 0.1 );
2843 setPreferenceProperty( xv, "min", 0.0 );
2844 setPreferenceProperty( yv, "min", 0.0 );
2845 setPreferenceProperty( wv, "min", 0.0 );
2846 setPreferenceProperty( hv, "min", 0.0 );
2847 setPreferenceProperty( xv, "max", 1.0 );
2848 setPreferenceProperty( yv, "max", 1.0 );
2849 setPreferenceProperty( wv, "max", 1.0 );
2850 setPreferenceProperty( hv, "max", 1.0 );
2852 int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2853 int xh = addPreference( tr( "VISU_X" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2854 int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2855 int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2856 int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2857 setPreferenceProperty( xh, "step", 0.1 );
2858 setPreferenceProperty( yh, "step", 0.1 );
2859 setPreferenceProperty( wh, "step", 0.1 );
2860 setPreferenceProperty( hh, "step", 0.1 );
2861 setPreferenceProperty( xh, "min", 0.0 );
2862 setPreferenceProperty( yh, "min", 0.0 );
2863 setPreferenceProperty( wh, "min", 0.0 );
2864 setPreferenceProperty( hh, "min", 0.0 );
2865 setPreferenceProperty( xh, "max", 1.0 );
2866 setPreferenceProperty( yh, "max", 1.0 );
2867 setPreferenceProperty( wh, "max", 1.0 );
2868 setPreferenceProperty( hh, "max", 1.0 );
2870 int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2872 int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2873 setPreferenceProperty( rangeGr, "columns", 1 );
2875 int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2877 modes.append( tr( "VISU_MODULUS" ) );
2878 modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2879 modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2880 modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2882 indices.append( 0 );
2883 indices.append( 1 );
2884 indices.append( 2 );
2885 indices.append( 3 );
2886 setPreferenceProperty( mode, "strings", modes );
2887 setPreferenceProperty( mode, "indexes", indices );
2889 addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, LightApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2891 int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_range_type" );
2893 types.append( tr( "VISU_FIELD_RANGE" ) );
2894 types.append( tr( "VISU_IMPOSED_RANGE" ) );
2896 indices.append( 0 );
2897 indices.append( 1 );
2898 setPreferenceProperty( rangetype, "strings", types );
2899 setPreferenceProperty( rangetype, "indexes", indices );
2901 int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2903 int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2904 int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2905 setPreferenceProperty( min, "step", 0.1 );
2906 setPreferenceProperty( max, "step", 0.1 );
2908 int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2909 setPreferenceProperty( sweepGr, "columns", 1 );
2911 int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2912 int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2913 int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2914 setPreferenceProperty( timestep, "min", 0.1 );
2915 setPreferenceProperty( timestep, "step", 0.1 );
2916 setPreferenceProperty( timestep, "max", 1000 );
2917 setPreferenceProperty( nbcycles, "max", 100 );
2918 setPreferenceProperty( nbsteps, "max", 200 );
2920 int importGr = addPreference( tr( "MED files import" ), srangeTab );
2921 addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" );
2924 void VisuGUI::preferencesChanged( const QString&, const QString& )
2930 ::getViewManager(const QString& theType,
2931 const bool theIsCreate)
2933 return getApp()->getViewManager(theType,theIsCreate);
2936 LightApp_Displayer* VisuGUI::displayer()
2939 myDisplayer = new VisuGUI_Displayer( dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() ) );