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 "SPlot2d_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 "SalomeApp_SelectionMgr.h"
75 #include "SalomeApp_Selection.h"
76 #include "SalomeApp_Preferences.h"
78 #include "VISUConfig.hh"
79 #include "VISU_Gen_i.hh"
80 #include "VISU_Mesh_i.hh"
81 #include "VISU_Table_i.hh"
82 #include "VISU_Result_i.hh"
83 #include "VISU_View_i.hh"
84 #include "VISU_ViewManager_i.hh"
85 #include "VISU_Plot3D_i.hh"
87 #include "VISU_Actor.h"
89 #include "VisuGUI_Tools.h"
90 #include "VisuGUI_PopupTools.h"
91 #include "VisuGUI_NameDlg.h"
92 #include "VisuGUI_FileDlg.h"
93 #include "VisuGUI_CursorDlg.h"
94 #include "VisuGUI_Selection.h"
95 #include "VisuGUI_TimeAnimation.h"
96 #include "VisuGUI_EditContainerDlg.h"
97 #include "VisuGUI_NonIsometricDlg.h"
98 #include "VisuGUI_ClippingDlg.h"
99 #include "VisuGUI_Plot3DDlg.h"
100 #include "VisuGUI_CubeAxesDlg.h"
101 #include "VisuGUI_OffsetDlg.h"
103 #include "VISU_ScalarMap_i.hh"
104 #include "VisuGUI_ScalarBarDlg.h"
106 #include "VISU_DeformedShape_i.hh"
107 #include "VisuGUI_DeformedShapeDlg.h"
109 #include "VISU_IsoSurfaces_i.hh"
110 #include "VisuGUI_IsoSurfacesDlg.h"
112 #include "VISU_CutPlanes_i.hh"
113 #include "VisuGUI_CutPlanesDlg.h"
115 #include "VISU_CutLines_i.hh"
116 #include "VisuGUI_CutLinesDlg.h"
118 #include "VISU_StreamLines_i.hh"
119 #include "VisuGUI_StreamLinesDlg.h"
121 #include "VISU_Vectors_i.hh"
122 #include "VisuGUI_VectorsDlg.h"
124 #include "VisuGUI_TableDlg.h"
126 #include "SALOMEconfig.h"
127 #include CORBA_SERVER_HEADER(MED_Gen)
129 #include "utilities.h"
131 #include "VisuGUI_ActionsDef.h"
133 using namespace VISU;
136 static int MYDEBUG = 1;
138 static int MYDEBUG = 0;
141 //////////////////////////////////////////////////
143 //////////////////////////////////////////////////
146 SalomeApp_Module( "VISU" )
160 if(MYDEBUG) MESSAGE("VisuGUI::OnImportFromFile()");
161 CheckLock(GetCStudy(GetAppStudy(this)));
162 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
165 aFilter.append( tr("FLT_MED_FILES") );
166 aFilter.append( tr("FLT_ALL_FILES") );
168 QFileInfo aFileInfo =
169 SUIT_FileDlg::getFileName(GetDesktop(this),
172 tr("MEN_IMPORT_FROM_FILE"),
174 if(aFileInfo.exists()) {
175 application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
177 VISU::Result_var aResult;
178 bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false);
179 if (VisuGUI_FileDlg::IsBuild) {
180 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
181 if (!CORBA::is_nil(aResult.in()))
182 if (Result_i* aRes = dynamic_cast<Result_i*>(GetServant(aResult).in())) {
183 if (!aRes->IsPossible())
184 SUIT_MessageBox::warn1(GetDesktop(this),
186 tr("ERR_CANT_BUILD_PRESENTATION"),
192 aResourceMgr->setValue("VISU", "full_med_loading", false);
193 aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath());
194 aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild);
197 if (CORBA::is_nil(aResult.in())) {
198 SUIT_MessageBox::warn1(GetDesktop(this),
200 tr("ERR_ERROR_IN_THE_FILE"),
203 application()->putInfo(aFileInfo.filePath() + tr("INF_DONE"));
204 UpdateObjBrowser(this);
214 if(MYDEBUG) MESSAGE("VisuGUI::OnExploreMEDFile()");
215 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
218 SALOME_MED::MED_Gen_var aGen = GetMEDEngine();
221 aFilter.append( tr("FLT_MED_FILES") );
222 aFilter.append( tr("FLT_ALL_FILES") );
224 QFileInfo aFileInfo =
225 SUIT_FileDlg::getFileName(GetDesktop(this),
228 tr("MEN_EXPLORE_MED_FILE"),
230 if(aFileInfo.exists()){
231 application()->putInfo( tr("MEN_EXPLORE_MED_FILE") + " " + aFileInfo.filePath() + "..." );
232 std::string aStudyName = aStudy->Name();
233 aGen->readStructFileWithFieldType(aFileInfo.filePath(),aStudyName.c_str());
234 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
235 getApp()->updateObjectBrowser(true); // as need to update MED tree
236 getApp()->updateActions();
243 OnImportTableFromFile()
245 if(MYDEBUG) MESSAGE("VisuGUI::OnImportTableFromFile()");
246 CheckLock(GetCStudy(GetAppStudy(this)));
249 aFilter.append( tr("FLT_TABLE_FILES") );
250 aFilter.append( tr("FLT_ALL_FILES") );
252 QFileInfo aFileInfo =
253 SUIT_FileDlg::getFileName(GetDesktop(this),
256 tr("MEN_IMPORT_TABLE"),
258 if (aFileInfo.exists()) {
259 application()->putInfo( tr("MEN_IMPORT_TABLE") + " " + aFileInfo.filePath() + " ..." );
261 CORBA::Object_var anObject = GetVisuGen(this)->ImportTables(aFileInfo.filePath());
263 if (CORBA::is_nil(anObject.in())) {
264 SUIT_MessageBox::warn1(GetDesktop(this),
266 tr("ERR_ERROR_IN_THE_FILE"),
269 application()->putInfo(aFileInfo.filePath()+tr("INF_DONE"));
270 UpdateObjBrowser(this);
277 OnExportTableToFile()
279 if(MYDEBUG) MESSAGE("VisuGUI::OnExportTableToFile()");
281 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
283 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
284 SALOME_ListIO aListIO;
285 aSelectionMgr->selectedObjects(aListIO);
287 if (aListIO.Extent() > 0) {
288 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
289 if (anIO->hasEntry()) {
290 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
293 // find table attribute
295 _PTR(GenericAttribute) anAttr;
297 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
299 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
300 // if the current SObject is a table title
301 // we take a father contaning the table
302 aSObj = aSObj->GetFather();
304 if (aSObj->FindAttribute(anAttr, "AttributeTableOfReal")) {
307 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
314 // get table title in order to have default name of the file
317 _PTR(AttributeTableOfReal) aTabAttr (anAttr);
318 if (!aTabAttr) return;
319 aTitle = aTabAttr->GetTitle();
321 _PTR(AttributeTableOfInteger) aTabAttr (anAttr);
322 if (!aTabAttr) return;
323 aTitle = aTabAttr->GetTitle();
325 aTitle.simplifyWhiteSpace();
326 aTitle = aTitle.replace(QRegExp(" "), "_");
328 // get default path for the file
329 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
330 QString aDir = aResourceMgr->stringValue("VISU","OutputDir","");
331 if (aDir.isEmpty()) {
332 aDir = aResourceMgr->stringValue("VISU","InputDir","");
333 if (aDir.isEmpty()) {
334 aDir = getenv("CSF_PATHData");
337 QString aPath = Qtx::addSlash(aDir) + aTitle;
339 // get name for the file
341 aFilter.append("Table Files (*.xls)");
343 QFileInfo aFileInfo =
344 SUIT_FileDlg::getFileName(GetDesktop(this),
347 tr("MEN_EXPORT_TABLE"), // "Export Table To File"
351 QString aFile = aFileInfo.filePath();
352 if (!aFile.isEmpty()) {
353 application()->putInfo(tr("MEN_EXPORT_TABLE") + " " + aFile + " ...");
354 aDir = Qtx::dir(aFile, true);
355 aResourceMgr->setValue("VISU", "OutputDir", aDir);
358 GetVisuGen(this)->ExportTableToFile(GetSObject(aSObj), aFile.latin1());
359 application()->putInfo(aFile + " " + tr("INF_DONE"));
360 } catch(std::exception& ex) {
362 SUIT_MessageBox::warn1(GetDesktop(this),
364 tr("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
367 INFOS(tr("ERR_ERROR_DURING_EXPORT"));
368 SUIT_MessageBox::warn1(GetDesktop(this),
370 tr("ERR_ERROR_DURING_EXPORT"),
382 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
383 if (CheckLock(aCStudy))
385 SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy);
387 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
388 SALOME_ListIO aListIO;
389 aSelectionMgr->selectedObjects(aListIO);
391 SALOME_ListIteratorOfListIO It (aListIO);
392 QApplication::setOverrideCursor(Qt::waitCursor);
393 for (; It.More(); It.Next()) {
394 Handle(SALOME_InteractiveObject) anIO = It.Value();
395 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
396 if (!aSObject->_is_nil()) {
397 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
398 if (!CORBA::is_nil(anObject)) {
399 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
400 if (!CORBA::is_nil(aMED.in()))
401 GetVisuGen(this)->ImportMed(aSObject);
402 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject);
403 if (!CORBA::is_nil(aField.in()))
404 GetVisuGen(this)->ImportMedField(aField);
406 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
407 SALOMEDS::GenericAttribute_var anAttr;
408 aSFather->FindAttribute(anAttr, "AttributeName");
409 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
410 CORBA::String_var aValue = aName->Value();
411 if (strcmp(aValue.in(), "MEDFIELD") == 0)
412 GetVisuGen(this)->ImportMed(aSObject);
416 UpdateObjBrowser(this, true);
417 QApplication::restoreOverrideCursor();
421 CreateCurves( SalomeApp_Module* theModule,
422 VISU::CutLines_i* thePrs,
424 const bool theCreate = true )
428 VisuGUI_CutLinesDlg* aCutDlg = dynamic_cast<VisuGUI_CutLinesDlg*>( theDlg );
432 _PTR(Study) aStudy = GetCStudy( GetAppStudy( theModule ) );
433 _PTR(SObject) aSObject = aStudy->FindObjectID( thePrs->GetEntry().latin1() );
435 if ( !theCreate && aSObject ) {
437 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
438 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
439 for (; aIter->More(); aIter->Next()) {
440 _PTR(SObject) aTblObj = aIter->Value();
442 _PTR(GenericAttribute) anAttr;
443 if (aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
444 aBuilder->RemoveObjectWithChildren( aIter->Value() ); // We should have only one child
451 if ( aCutDlg->isGenerateTable() ) {
452 GetVisuGen( theModule )->CreateTable( thePrs->GetEntry() );
453 if ( aCutDlg->isGenerateCurves() ) {
455 _PTR(StudyBuilder) aBuilder = aStudy->NewBuilder();
456 _PTR(ChildIterator) aIter = aStudy->NewChildIterator(aSObject);
457 for (; aIter->More(); aIter->Next()) {
458 _PTR(SObject) aTblObj = aIter->Value();
460 _PTR(GenericAttribute) anAttr;
461 if ( aTblObj->FindAttribute( anAttr, "AttributeName" ) ) {
462 CreatePlot( theModule, aTblObj );
470 if (!theCreate && aSObject) {
471 UpdateObjBrowser(theModule);
475 template<class TPrs3d_i>
477 CreatePrs3d(SalomeApp_Module* theModule,
478 _PTR(SObject) theTimeStamp,
479 const char* theMeshName,
480 VISU::Entity theEntity,
481 const char* theFieldName,
484 VISU::Result_var aResult;
485 if (CheckResult(theModule,theTimeStamp,aResult)){
486 QApplication::setOverrideCursor(Qt::waitCursor);
487 typedef typename TPrs3d_i::TInterface TPrs3d;
488 typename TPrs3d::_var_type aPrs3d =
489 GetVisuGen(theModule)->template Prs3dOnField<TPrs3d_i>
490 (aResult,theMeshName,theEntity,theFieldName,theTimeId);
491 QApplication::restoreOverrideCursor();
492 if (!CORBA::is_nil(aPrs3d.in()))
493 return dynamic_cast<TPrs3d_i*>(VISU::GetServant(aPrs3d.in()).in());
495 SUIT_MessageBox::warn1(GetDesktop(theModule),
496 QObject::tr("WRN_VISU"),
497 QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
498 QObject::tr("BUT_OK") );
503 template<class TPrs3d_i, class TDlg, int IsDlgModal>
505 CreatePrs3d(SalomeApp_Module* theModule,
506 _PTR(SObject) theTimeStamp,
507 const Handle(SALOME_InteractiveObject)& theIO)
509 using namespace VISU;
510 Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
512 QString aType = Storable::FindValue(aMap,"myType",&isExist);
513 if(!isExist || aType.toInt() != TTIMESTAMP )
515 QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
516 QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
517 QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
518 QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
519 QApplication::setOverrideCursor(Qt::waitCursor);
521 CreatePrs3d<TPrs3d_i>(theModule,
524 (Entity)anEntity.toInt(),
526 aTimeStampId.toInt());
527 QApplication::restoreOverrideCursor();
529 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
530 int aValue = aResourceMgr->integerValue("VISU","BuildDefaultPrs3d",0);
532 if(TDlg* aDlg = new TDlg(theModule)){ // dialog box in creation mode
533 aDlg->initFromPrsObject(aPrs3d);
535 if(aDlg->exec() && (aDlg->storeToPrsObject(aPrs3d))) {
536 // Optionally, create table and curves for cut lines
537 QApplication::setOverrideCursor(Qt::waitCursor);
538 CreateCurves( theModule,
539 dynamic_cast<VISU::CutLines_i*>( aPrs3d ),
541 true ); // in creation mode
542 QApplication::restoreOverrideCursor();
545 DeletePrs3d(theModule,aPrs3d,theIO);
555 PublishInView(theModule,aPrs3d);
562 template<class TPrs3d_i, class TDlg, int IsDlgModal>
564 CreatePrs3d(SalomeApp_Module* theModule)
566 if (CheckLock(GetCStudy(GetAppStudy(theModule))))
569 _PTR(SObject) aTimeStampSObj;
570 Handle(SALOME_InteractiveObject) anIO;
571 if (!CheckTimeStamp(theModule,aTimeStampSObj,&anIO))
574 if (!CreatePrs3d<TPrs3d_i,TDlg,IsDlgModal>(theModule,aTimeStampSObj,anIO))
577 theModule->application()->putInfo(QObject::tr("INF_DONE"));
578 theModule->updateObjBrowser();
579 UpdateObjBrowser(theModule);
581 if (SVTK_ViewWindow* aView = GetViewWindow(theModule))
589 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
590 if (CheckLock(aStudy))
593 // Get selected SObject
594 Handle(SALOME_InteractiveObject) anIO;
595 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
596 if (anIO.IsNull() || !anIO->hasEntry())
599 CreateMesh(this, anIO);
606 _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
607 if (CheckLock(aStudy))
610 // Get selected SObject
611 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
612 SALOME_ListIO aListIO;
613 aSelectionMgr->selectedObjects(aListIO);
614 SALOME_ListIteratorOfListIO anIter (aListIO);
615 for (; anIter.More(); anIter.Next()) {
616 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
617 if (anIO.IsNull() || !anIO->hasEntry())
620 CreateMesh(this, anIO);
628 CreatePrs3d<VISU::ScalarMap_i,VisuGUI_ScalarBarDlg,1>(this);
634 OnCreateDeformedShape()
636 CreatePrs3d<VISU::DeformedShape_i,VisuGUI_DeformedShapeDlg,1>(this);
643 CreatePrs3d<VISU::Vectors_i,VisuGUI_VectorsDlg,1>(this);
648 OnCreateIsoSurfaces()
650 CreatePrs3d<VISU::IsoSurfaces_i,VisuGUI_IsoSurfacesDlg,1>(this);
657 CreatePrs3d<VISU::CutPlanes_i,VisuGUI_CutPlanesDlg,1>(this);
664 CreatePrs3d<VISU::CutLines_i,VisuGUI_CutLinesDlg,1>(this);
669 OnCreateStreamLines()
671 CreatePrs3d<VISU::StreamLines_i,VisuGUI_StreamLinesDlg,1>(this);
678 CreatePrs3d<VISU::Plot3D_i,VisuGUI_Plot3DDlg,1>(this);
685 CheckLock(GetCStudy(GetAppStudy(this)));
686 GetVisuGen( this )->CreateContainer();
687 UpdateObjBrowser(this);
694 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs");
696 QApplication::setOverrideCursor(Qt::waitCursor);
698 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
699 mgr->selectedObjects(aList);
701 Handle(SALOME_InteractiveObject) anIO;
702 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
704 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
705 if ( !CORBA::is_nil( anObject ) ) {
706 // is it Prs3d object ?
707 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
709 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object");
710 UpdateViewer( this, aPrsObject );
711 if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
712 vw->highlight(anIO, 1);
717 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
719 if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Curve object");
720 PlotCurve( this, aCurve, VISU::eDisplay );
724 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
726 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
727 PlotContainer( this, aContainer, VISU::eDisplay );
731 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
733 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
734 PlotTable( this, aTable, VISU::eDisplay );
739 if (SVTK_ViewWindow* vw = GetViewWindow( this )) {
740 vw->getRenderer()->ResetCameraClippingRange();
743 QApplication::restoreOverrideCursor();
758 if(MYDEBUG) MESSAGE("OnErasePrs");
760 QApplication::setOverrideCursor(Qt::waitCursor);
762 SVTK_ViewWindow* vw = GetViewWindow(this);
763 if (vw) vw->unHighlightAll();
766 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
767 mgr->selectedObjects(aList);
769 Handle(SALOME_InteractiveObject) anIO;
770 for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) {
772 CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() );
773 ErasePrs(this, anObject, false);
776 if (vw) vw->Repaint();
778 QApplication::restoreOverrideCursor();
781 template<class TPrs3d_i, class TDlg>
783 EditPrs3d (SalomeApp_Module* theModule, VISU::Prs3d_i* thePrs3d)
785 TPrs3d_i* aPrsObject = dynamic_cast<TPrs3d_i*>(thePrs3d);
787 TDlg* aDlg = new TDlg (theModule);
788 aDlg->initFromPrsObject(aPrsObject);
790 if (!(aDlg->storeToPrsObject(aPrsObject))) {
794 RecreateActor(theModule, aPrsObject);
795 if (SVTK_ViewWindow* vw = GetViewWindow(theModule)) {
796 vw->getRenderer()->ResetCameraClippingRange();
799 // Optionally, create table and curves for cut lines
800 QApplication::setOverrideCursor(Qt::waitCursor);
801 CreateCurves( theModule,
802 dynamic_cast<VISU::CutLines_i*>( aPrsObject ),
804 false ); // in edition mode
805 QApplication::restoreOverrideCursor();
815 if (CheckLock(GetCStudy(GetAppStudy(this))))
818 Handle(SALOME_InteractiveObject) anIO;
819 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
820 if (CORBA::is_nil(anObject)) return;
821 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
822 if (!aServant.in()) return;
824 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
827 switch (aPrs3d->GetType()) {
830 case VISU::TSCALARMAP:
831 EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg>(this, aPrs3d);
833 case VISU::TDEFORMEDSHAPE:
834 EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg>(this, aPrs3d);
836 case VISU::TCUTPLANES:
837 EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg>(this, aPrs3d);
839 case VISU::TCUTLINES:
840 EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg>(this, aPrs3d);
842 case VISU::TISOSURFACE:
843 EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg>(this, aPrs3d);
846 EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg>(this, aPrs3d);
848 case VISU::TSTREAMLINES:
849 EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg>(this, aPrs3d);
852 EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg>(this, aPrs3d);
858 if (SVTK_ViewWindow* vw = GetViewWindow())
859 vw->highlight(anIO, 1);
866 if (SVTK_ViewWindow* vw = GetViewWindow()) {
867 vw->unHighlightAll();
868 if (vtkRenderer *aRen = vw->getRenderer()) {
870 vtkActorCollection *anActColl = aRen->GetActors();
871 for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) {
872 if (anActor->GetVisibility() > 0)
873 if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) {
874 anVISUActor = anVISUActor->GetParent();
875 anVISUActor->VisibilityOff();
880 } else if (SPlot2d_Viewer* aPlot2d = GetPlot2dViewer(this, false)) {
889 ChangeRepresentation(this, VISU::SURFACEFRAME);
896 ChangeRepresentation(this, VISU::INSIDEFRAME);
903 ChangeRepresentation(this, VISU::WIREFRAME);
910 ChangeRepresentation(this, VISU::SHADED);
917 ChangeRepresentation(this, VISU::POINT);
924 ChangeRepresentation(this, VISU::SHRINK);
931 Handle(SALOME_InteractiveObject) anIO;
932 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
933 if (CORBA::is_nil(anObject)) return;
934 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
935 if (!aServant.in()) return;
937 VISU::Prs3d_i* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
940 SVTK_ViewWindow* vw = GetViewWindow();
943 VISU_Actor* anActor = GetActor(aPrs3d, vw);
944 if (!anActor) return;
946 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
947 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
948 SALOMEDS::Color anOldColor, aNewColor;
949 int aRepresent = anActor->GetRepresentation();
951 switch (aRepresent) {
953 anOldColor = aMesh->GetNodeColor();
955 case VISU::WIREFRAME :
956 case VISU::INSIDEFRAME :
957 anOldColor = aMesh->GetLinkColor();
960 case VISU::SURFACEFRAME :
961 anOldColor = aMesh->GetCellColor();
964 } else if (aDeformedShape) {
965 anOldColor = aDeformedShape->GetColor();
970 QColor aColor (int(255*anOldColor.R),
971 int(255*anOldColor.G),
972 int(255*anOldColor.B));
973 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
974 if (aColorNew.isValid()) {
975 aNewColor.R = aColorNew.red()/255.;
976 aNewColor.G = aColorNew.green()/255.;
977 aNewColor.B = aColorNew.blue()/255.;
979 switch (aRepresent) {
981 aMesh->SetNodeColor(aNewColor);
983 case VISU::WIREFRAME :
984 case VISU::INSIDEFRAME :
985 aMesh->SetLinkColor(aNewColor);
988 case VISU::SURFACEFRAME :
989 aMesh->SetCellColor(aNewColor);
993 aDeformedShape->SetColor(aNewColor);
995 RecreateActor(this, aPrs3d);
1001 OnChangeWireframeColor()
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* aPrs3d = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1010 if (!aPrs3d) return;
1012 SVTK_ViewWindow* vw = GetViewWindow();
1015 VISU_Actor* anActor = GetActor(aPrs3d, vw);
1016 if (!anActor) return;
1018 if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
1019 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
1020 QColor aColor (int(255*anOldColor.R),
1021 int(255*anOldColor.G),
1022 int(255*anOldColor.B));
1023 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop(this));
1024 if (aColorNew.isValid()) {
1025 aNewColor.R = aColorNew.red()/255.;
1026 aNewColor.G = aColorNew.green()/255.;
1027 aNewColor.B = aColorNew.blue()/255.;
1028 aMesh->SetLinkColor(aNewColor);
1029 RecreateActor(this, aMesh);
1038 Handle(SALOME_InteractiveObject) anIO;
1039 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1040 if (CORBA::is_nil(anObject)) return;
1041 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1042 if (!aServant.in()) return;
1044 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1045 if (!aPrsObject) return;
1047 SVTK_ViewWindow* vw = GetViewWindow();
1050 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1051 if (!anActor) return;
1053 VisuGUI_CursorDlg* CursorDlg =
1054 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_OPACITY_TITLE"), TRUE);
1056 CursorDlg->Comment1->setText(tr("DLG_OPACITY_CMT1"));
1057 CursorDlg->Comment2->setText(tr("DLG_OPACITY_CMT2"));
1058 CursorDlg->SpinBox1->setMinValue(0);
1059 CursorDlg->SpinBox1->setMaxValue(100);
1061 float oldopac = anActor->GetOpacity();
1062 int intopac = int(oldopac*100. + 0.5);
1063 CursorDlg->SpinBox1->setValue(intopac);
1065 int ret = CursorDlg->exec();
1067 intopac = CursorDlg->SpinBox1->value();
1068 float newopac = intopac/100.;
1069 anActor->SetOpacity(newopac);
1078 Handle(SALOME_InteractiveObject) anIO;
1079 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1080 if (CORBA::is_nil(anObject)) return;
1081 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1082 if (!aServant.in()) return;
1084 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1085 if (!aPrsObject) return;
1087 SVTK_ViewWindow* vw = GetViewWindow();
1090 VISU_Actor* anActor = GetActor(aPrsObject, vw);
1091 if (!anActor) return;
1093 VisuGUI_CursorDlg* CursorDlg =
1094 new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
1096 CursorDlg->Comment1->setText(tr("DLG_LINEWIDTH_CMT1"));
1097 CursorDlg->Comment2->setText(tr("DLG_LINEWIDTH_CMT2"));
1098 CursorDlg->SpinBox1->setMinValue(1);
1099 CursorDlg->SpinBox1->setMaxValue(10);
1101 float oldlwid = anActor->GetLineWidth();
1102 int intlwid = int(oldlwid);
1103 CursorDlg->SpinBox1->setValue(intlwid);
1105 int ret = CursorDlg->exec();
1107 intlwid = CursorDlg->SpinBox1->value();
1108 float newlwid = intlwid;
1109 anActor->SetLineWidth(newlwid);
1118 Handle(SALOME_InteractiveObject) anIO;
1119 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1121 if ( !CORBA::is_nil( anObject ) ) {
1122 VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
1123 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1124 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1125 if( !CORBA::is_nil( aTable ) ) {
1126 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
1128 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
1133 // possibly this is Table SObject
1134 SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
1137 if( !IsSObjectTable( SO ) )
1140 VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
1143 //SAL2670 Orientation of show tables
1144 VisuGUI_TableDlg::ttAuto,
1153 Handle(SALOME_InteractiveObject) anIO;
1154 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1155 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1156 _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
1157 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1158 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1159 GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
1160 UpdateObjBrowser(this);
1168 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1169 if (CheckLock(aCStudy))
1172 SALOME_ListIO aList;
1173 SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this);
1174 mgr->selectedObjects(aList);
1175 int i = 0, nbSelected = aList.Extent();
1176 if (nbSelected < 1) return;
1178 const char* entries [nbSelected];
1179 Handle(SALOME_InteractiveObject) anIO;
1180 for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
1182 if (anIO->hasEntry())
1183 entries[i++] = anIO->getEntry();
1186 if (nbSelected < 1) return;
1188 // There is a transaction
1189 _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
1190 aStudyBuilder->NewCommand();
1192 for (i = 0; i < nbSelected; i++) {
1193 _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
1195 DeleteSObject(this, aCStudy, aSObject);
1199 // Finish transaction
1200 aStudyBuilder->CommitCommand();
1202 //GetActiveStudy()->unHighlightAll();
1203 UpdateObjBrowser(this, true);
1210 Handle(SALOME_InteractiveObject) anIO;
1211 CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
1213 _PTR(GenericAttribute) anAttr;
1214 _PTR(AttributeName) aName;
1216 _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
1218 if ( !CORBA::is_nil( anObject ) ) {
1219 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1220 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1221 // Table (VISU object) is selected
1222 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1223 if( !CORBA::is_nil( aTbl ) ) {
1224 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1226 _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
1227 if ( IsSObjectTable(SO) ) {
1228 // get name of SObject
1229 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1231 SOName = QString( aName->Value().c_str() );
1233 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1234 if ( dlg->exec() == QDialog::Accepted ) {
1235 if ( !IsStudyLocked( aStudy ) ) {
1236 // if study is not locked - create new container, create curves and insert them
1237 // into container, then plot container if current viewer is of VIEW_PLOT2D type
1239 QValueList<int> verIndices;
1240 dlg->getCurvesSource( horIndex, verIndices );
1241 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1242 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1243 if( !CORBA::is_nil( aContainer ) ) {
1244 VISU::Container_i* pContainer =
1245 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1247 for ( int i = 0; i < verIndices.count(); i++ ) {
1248 CORBA::Object_var aNewCurve =
1249 GetVisuGen(this)->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1250 if( !CORBA::is_nil( aNewCurve ) ) {
1251 VISU::Curve_i* pCrv =
1252 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1255 int marker, line, lineWidth;
1257 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1258 line, lineWidth, color) && !isAuto ) {
1260 c.R = color.red() /255.;
1261 c.G = color.green()/255.;
1262 c.B = color.blue() /255.;
1263 pCrv->SetColor( c );
1264 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1265 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1267 pContainer->AddCurve( pCrv->_this() );
1271 UpdateObjBrowser(this);
1272 PlotContainer( this, pContainer, VISU::eDisplay );
1278 // if study is locked just get curves info and plot them
1279 // if current viewer is of VIEW_PLOT2D type
1280 QPtrList<Plot2d_Curve> container;
1281 dlg->getCurves( container );
1282 if ( !container.isEmpty() ) {
1283 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1284 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1294 else if ( !anIO.IsNull() ) {
1295 // check if Table SObject is selected
1296 SO = aStudy->FindObjectID( anIO->getEntry() );
1297 if ( IsSObjectTable(SO) ) {
1298 // get name of SObject
1299 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1301 SOName = QString( aName->Value().c_str() );
1303 SPlot2d_SetupPlot2dDlg* dlg = new SPlot2d_SetupPlot2dDlg( SO, GetDesktop( this ) );
1304 if ( dlg->exec() == QDialog::Accepted ) {
1305 if ( !IsStudyLocked( aStudy ) ) {
1306 // if study is not locked - create new table and container objects, create curves
1307 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1309 QValueList<int> verIndices;
1310 dlg->getCurvesSource( horIndex, verIndices );
1311 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1312 CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
1313 CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
1314 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1315 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1316 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1318 if ( pContainer && pTable ) {
1319 for ( int i = 0; i < verIndices.count(); i++ ) {
1320 CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurve
1321 ( pTable->_this(), horIndex+1, verIndices[i]+1 );
1322 if( !CORBA::is_nil( aNewCurve ) ) {
1323 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1326 int marker, line, lineWidth;
1328 if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
1329 line, lineWidth, color) && !isAuto ) {
1331 c.R = color.red()/255.;
1332 c.G = color.green()/255.;
1333 c.B = color.blue()/255.;
1334 pCrv->SetColor( c );
1335 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1336 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1338 pContainer->AddCurve( pCrv->_this() );
1342 UpdateObjBrowser(this);
1343 PlotContainer( this, pContainer, VISU::eDisplay );
1348 // if study is locked just get curves info and plot them
1349 QPtrList<Plot2d_Curve> container;
1350 dlg->getCurves( container );
1351 if ( !container.isEmpty() ) {
1352 GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
1353 GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
1366 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1367 SALOME_ListIO aListIO;
1368 aSelectionMgr->selectedObjects(aListIO);
1369 if (aListIO.Extent() != 1) return;
1371 SalomeApp_Study* aAppStudy = GetAppStudy(this);
1372 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1373 CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
1374 if (CORBA::is_nil( anObject )) return;
1376 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1377 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1379 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1380 if( !CORBA::is_nil( aCurve ) ) {
1381 VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1382 if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
1383 Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
1385 aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
1386 aDlg.setMarker( (int)aDSCurve->GetMarker() );
1387 SALOMEDS::Color aColor = aDSCurve->GetColor();
1388 aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
1389 if( aDlg.exec() == QDialog::Accepted ) {
1390 aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
1391 aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
1392 SALOMEDS::Color newColor;
1393 newColor.R = aDlg.getColor().red()/255.;
1394 newColor.G = aDlg.getColor().green()/255.;
1395 newColor.B = aDlg.getColor().blue()/255.;
1396 aDSCurve->SetColor( newColor );
1397 PlotCurve(this, aDSCurve, VISU::eDisplay);
1408 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1409 if (CheckLock(aCStudy))
1411 Handle(SALOME_InteractiveObject) anIO;
1412 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1413 if (anIO.IsNull() || CORBA::is_nil(anObject))
1416 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1417 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
1419 CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
1420 if (!CORBA::is_nil(aCnt)) {
1421 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
1422 if (container && container->GetNbCurves() > 0) {
1424 UpdateObjBrowser(this);
1434 Handle(SALOME_InteractiveObject) anIO;
1435 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1436 if (CORBA::is_nil(anObject)) return;
1438 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1439 if (!aServant.in()) return;
1440 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
1441 if (!aContainer) return;
1443 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
1444 aDlg->initFromPrsObject(aContainer);
1446 aDlg->storeToPrsObject(aContainer);
1447 UpdateObjBrowser(this, true);
1456 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1457 if (CheckLock(aCStudy))
1460 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1461 if (aViewMgr->getType() != SVTK_Viewer::Type())
1464 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1465 SALOME_ListIO aListIO;
1466 aSelectionMgr->selectedObjects(aListIO);
1467 if (aListIO.Extent() > 1)
1470 if (aListIO.Extent() == 0) {
1471 VISU::View3D_i::SaveViewParams(aViewMgr, VISU::View3D_i::GenerateViewParamsName().latin1());
1473 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1474 VISU::View3D_i::SaveViewParams(aViewMgr, anIO->getName());
1476 UpdateObjBrowser(this);
1481 OnRestoreViewParams()
1483 SUIT_ViewManager* aViewMgr = getApp()->activeViewManager();
1484 if (aViewMgr->getType() != SVTK_Viewer::Type())
1487 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1488 SALOME_ListIO aListIO;
1489 aSelectionMgr->selectedObjects(aListIO);
1490 if (aListIO.Extent() != 1)
1493 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1494 //jfa tmp:VISU::View3D_i::RestoreViewParams(aViewMgr, anIO->getName());
1495 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));//jfa tmp
1496 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());//jfa tmp
1497 VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
1504 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1505 if (CheckLock(aCStudy))
1508 Handle(SALOME_InteractiveObject) anIO;
1509 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1511 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1514 //TEST DU PARENT == VISU
1515 _PTR(GenericAttribute) anAttr;
1516 if (aSObj->FindAttribute(anAttr, "AttributeName")) {
1517 _PTR(AttributeName) aName (anAttr);
1518 QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
1519 if (!Name.isEmpty()) {
1520 QApplication::setOverrideCursor(Qt::waitCursor);
1522 // rename specific objects
1523 if (!CORBA::is_nil(anObject)) {
1524 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1525 if (!CORBA::is_nil(aVisuObj)) {
1526 switch (aVisuObj->GetType()) {
1527 case VISU::TCURVE: // Curve object
1529 CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
1530 if (!CORBA::is_nil(aCurve)) {
1531 VISU::Curve_i* curve =
1532 dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1534 curve->SetName(Name.latin1());
1538 case VISU::TTABLE: // Table object
1540 CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
1541 if (!CORBA::is_nil(aTable)) {
1542 VISU::Table_i* table =
1543 dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1545 table->SetName(Name.latin1());
1549 case VISU::TCONTAINER: // Container object
1551 CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
1552 if (!CORBA::is_nil(aContainer)) {
1553 VISU::Container_i* container =
1554 dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1556 container->SetName(Name.latin1());
1567 // rename the study object
1568 aName->SetValue(Name.latin1()); // rename the SObject
1569 anIO->setName(Name.latin1()); // rename the InteractiveObject
1570 UpdateObjBrowser(this, false);
1572 QApplication::restoreOverrideCursor();
1581 new VisuGUI_ClippingDlg (this, "", false);
1589 Handle(SALOME_InteractiveObject) anIO;
1590 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1591 if (CORBA::is_nil(anObject)) return;
1592 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1593 if (!aServant.in()) return;
1595 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aServant.in());
1596 if (!aPrsObject) return;
1598 SVTK_ViewWindow* vw = GetViewWindow();
1601 VISU_Actor* aActor = GetActor(aPrsObject, vw);
1602 if (!aActor) return;
1604 if (!aActor->GetVisibility()) {
1605 aActor->VisibilityOn();
1608 // Get sweep parameters
1609 SUIT_ResourceMgr* aResourceMgr = GetResourceMgr();
1611 double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1);
1612 int aTemp = int(1.E6 * aTempoDbl);
1614 int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1);
1615 int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40);
1618 QApplication::setOverrideCursor(Qt::waitCursor);
1620 for (int j = 0; j < aCycles; j++) {
1621 for (int i = 0; i <= aSteps; i++) {
1622 float aPercents = float(i)/aSteps;
1623 aPrsObject->SetMapScale(aPercents);
1624 aPrsObject->UpdateActor(aActor);
1625 vw->getRenderWindow()->getRenderWindow()->Render();
1629 } catch (std::exception& exc) {
1630 INFOS("Follow exception was occured :\n" << exc.what());
1632 INFOS("Unknown exception was occured!");
1634 QApplication::restoreOverrideCursor();
1641 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1642 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1643 // new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy);
1644 new VisuGUI_TimeAnimationDlg (this, aCStudy);
1646 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1647 SALOME_ListIO aListIO;
1648 aSelectionMgr->selectedObjects(aListIO);
1650 bool isDefined = false;
1652 SALOME_ListIteratorOfListIO It (aListIO);
1653 for (; It.More(); It.Next()) {
1654 _PTR(SObject) aSObject = aCStudy->FindObjectID(It.Value()->getEntry());
1655 if (!aSObject) continue;
1656 if (getValue(aSObject, "myComment") == QString("FIELD")) {
1657 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
1661 aAnimationDlg->addField(aSObject);
1663 } else if (aNbTimes == aNumber) {
1664 aAnimationDlg->addField(aSObject);
1669 if (isDefined) aAnimationDlg->show();
1670 else delete aAnimationDlg;
1673 //************************************************************************
1678 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1679 SALOME_ListIO aListIO;
1680 aSelectionMgr->selectedObjects(aListIO);
1682 if (aListIO.Extent() != 1)
1685 const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
1687 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1689 _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
1692 VISU::Storable::TRestoringMap aMap;
1693 _PTR(GenericAttribute) anAttr;
1694 if (!aSObj->FindAttribute(anAttr, "AttributeComment")) return;
1696 _PTR(AttributeComment) aComment (anAttr);
1697 string aComm = aComment->Value();
1698 QString strIn (aComm.c_str());
1699 VISU::Storable::StrToMap(strIn, aMap);
1701 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
1702 if (aType != VISU::TANIMATION) return;
1704 VisuGUI_TimeAnimationDlg* aAnimationDlg =
1705 new VisuGUI_TimeAnimationDlg(this, aCStudy);
1706 aAnimationDlg->restoreFromStudy(aSObj);
1707 aAnimationDlg->show();
1712 OnCopyPresentation()
1714 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1715 if (CheckLock(aCStudy))
1718 Handle(SALOME_InteractiveObject) anIO;
1719 CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
1720 if (CORBA::is_nil(anObject)) return;
1721 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1722 if (!aServant.in()) return;
1724 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1725 if (!aPrsObject) return;
1727 switch (aPrsObject->GetType()) {
1730 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
1731 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
1732 aSameMesh->SameAs(aMeshPrs);
1733 UpdateViewer(this, aSameMesh);
1736 case VISU::TSCALARMAP:
1738 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1739 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult(),true);
1740 aSameScalar->SameAs(aScalarPrs);
1741 UpdateViewer(this, aSameScalar);
1744 case VISU::TDEFORMEDSHAPE:
1746 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
1747 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult(),true);
1748 aSameDeformed->SameAs(aDefPrs);
1749 UpdateViewer(this, aSameDeformed);
1752 case VISU::TCUTPLANES:
1754 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
1755 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult(),true);
1756 aSameCut->SameAs(aCutPrs);
1757 UpdateViewer(this, aSameCut);
1760 case VISU::TCUTLINES:
1762 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
1763 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult(),true);
1764 aSameCut->SameAs(aCutPrs);
1765 UpdateViewer(this, aSameCut);
1768 case VISU::TISOSURFACE:
1770 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
1771 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult(),true);
1772 aSameIso->SameAs(aIsoPrs);
1773 UpdateViewer(this, aSameIso);
1776 case VISU::TSTREAMLINES:
1778 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
1779 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult(),true);
1780 aSameLines->SameAs(aLinesPrs);
1781 UpdateViewer(this, aSameLines);
1784 case VISU::TVECTORS:
1786 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
1787 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult(),true);
1788 aSameVectors->SameAs(aVectorsPrs);
1789 UpdateViewer(this, aSameVectors);
1794 VISU::Plot3D_i* aPlot3DPrs = dynamic_cast<VISU::Plot3D_i*>(aPrsObject);
1795 VISU::Plot3D_i* aSamePlot3D = new VISU::Plot3D_i(aPlot3DPrs->GetResult());
1796 aSamePlot3D->SameAs(aPlot3DPrs);
1797 UpdateViewer(this, aSamePlot3D);
1801 UpdateObjBrowser(this);
1808 if (GetViewWindow())
1809 (new VisuGUI_SelectionDlg(GetDesktop(this)))->show();
1811 SUIT_MessageBox::warn1(GetDesktop(this),
1813 tr("ERR_ACTIVATE_VIEW3D"),
1821 VisuGUI_NonIsometricDlg* m_NonIsoDlg =
1822 new VisuGUI_NonIsometricDlg (GetDesktop(this), "m_NonIsoDlg",
1823 false, Qt::WDestructiveClose);
1824 m_NonIsoDlg->show();
1831 //Show dialog that allows to select scale function and corresponding scale factor
1832 VisuGUI_CubeAxesDlg* aDlg = new VisuGUI_CubeAxesDlg (GetDesktop(this));
1840 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1841 SALOME_ListIO aListIO;
1842 aSelectionMgr->selectedObjects(aListIO);
1844 SALOME_ListIteratorOfListIO It (aListIO);
1846 // first find the bounds
1847 double aMin, aMax; bool first = true;
1848 for (; It.More(); It.Next()) {
1849 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1850 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1851 if (!aPrsList.empty()) {
1852 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1853 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1855 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1859 aMin = aScalar->GetMin(); aMax = aScalar->GetMax();
1861 if (aScalar->GetMin() < aMin) aMin = aScalar->GetMin();
1862 if (aScalar->GetMax() > aMax) aMax = aScalar->GetMax();
1870 // set the computed range to every selected ScalarMap
1871 bool update = false;
1872 for (It.Initialize(aListIO); It.More(); It.Next() ) {
1873 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1874 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1875 if (!aPrsList.empty()) {
1876 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1877 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1879 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1881 aScalar->SetRange(aMin, aMax);
1882 RecreateActor(this, aScalar);
1890 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1891 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1892 vw->getRenderer()->ResetCameraClippingRange();
1903 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1904 SALOME_ListIO aListIO;
1905 aSelectionMgr->selectedObjects(aListIO);
1907 SALOME_ListIteratorOfListIO It (aListIO);
1909 // restore the source range for every ScalarMap
1910 bool update = false;
1911 for (; It.More(); It.Next()) {
1912 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1913 std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
1914 if (!aPrsList.empty()) {
1915 for (int i = 0, n = aPrsList.size(); i < n; i++) {
1916 VISU::Prs3d_i* aPrsObject = aPrsList[i];
1918 VISU::ScalarMap_i* aScalar = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
1920 aScalar->SetSourceRange();
1921 RecreateActor(this, aScalar);
1929 if (SVTK_ViewWindow* vw = GetViewWindow(this)) {
1930 //if (vw->getRenderer()->GetActors()->GetNumberOfItems() > 0) {
1931 vw->getRenderer()->ResetCameraClippingRange();
1942 if(MYDEBUG) MESSAGE("VisuGUI::OnTranslatePrs");
1943 VisuGUI_OffsetDlg* aDlg = new VisuGUI_OffsetDlg (this);
1945 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
1947 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
1948 SALOME_ListIO aListIO;
1949 aSelectionMgr->selectedObjects(aListIO);
1951 SALOME_ListIteratorOfListIO It (aListIO);
1952 for (; It.More(); It.Next()) {
1953 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1954 if (anIO->hasEntry()) {
1955 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
1957 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
1958 if (!CORBA::is_nil(aCORBAObject)) {
1959 PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
1960 if (VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())) {
1961 aDlg->addPresentation(aPrsObject);
1967 if (aDlg->getPrsCount() > 0)
1977 SVTK_ViewWindow* vw = GetViewWindow();
1979 ArrangeDlg* aDlg = new ArrangeDlg (GetDesktop(this), vw);
1988 initialize( CAM_Application* theApp )
1990 SalomeApp_Module::initialize( theApp );
2003 QWidget* aParent = application()->desktop();
2004 SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
2007 createAction( VISU_IMPORT_FROM_FILE, "", QIconSet(),
2008 tr("MEN_IMPORT_FROM_FILE"), "", (CTRL + Key_I), aParent, false,
2009 this, SLOT(OnImportFromFile()));
2011 createAction( VISU_EXPLORE_MED, "", QIconSet(),
2012 tr("MEN_EXPLORE_MED_FILE"), "", (CTRL + Key_M), aParent, false,
2013 this, SLOT(OnExploreMEDFile()));
2015 createAction( VISU_IMPORT_TABLE, "", QIconSet(),
2016 tr("MEN_IMPORT_TABLE"), "", 0, aParent, false,
2017 this, SLOT(OnImportTableFromFile()));
2019 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALAR_MAP"));
2020 createAction( VISU_SCALAR_MAP, tr("MEN_SCALAR_MAP"), QIconSet(aPixmap),
2021 tr("MEN_SCALAR_MAP"), "", 0, aParent, false,
2022 this, SLOT(OnCreateScalarMap()));
2024 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_DEFORMED_SHAPE"));
2025 createAction( VISU_DEFORMED_SHAPE, tr("MEN_DEFORMED_SHAPE"), QIconSet(aPixmap),
2026 tr("MEN_DEFORMED_SHAPE"), "", 0, aParent, false,
2027 this, SLOT(OnCreateDeformedShape()));
2029 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_VECTORS"));
2030 createAction( VISU_VECTORS, tr("MEN_VECTORS"), QIconSet(aPixmap),
2031 tr("MEN_VECTORS"), "", 0, aParent, false,
2032 this, SLOT(OnCreateVectors()));
2034 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ISO_SURFACES"));
2035 createAction( VISU_ISO_SURFACES, tr("MEN_ISO_SURFACES"), QIconSet(aPixmap),
2036 tr("MEN_ISO_SURFACES"), "", 0, aParent, false,
2037 this, SLOT(OnCreateIsoSurfaces()));
2039 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_PLANES"));
2040 createAction( VISU_CUT_PLANES, tr("MEN_CUT_PLANES"), QIconSet(aPixmap),
2041 tr("MEN_CUT_PLANES"), "", 0, aParent, false,
2042 this, SLOT(OnCreateCutPlanes()));
2044 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_STREAM_LINES"));
2045 createAction( VISU_STREAM_LINES, tr("MEN_STREAM_LINES"), QIconSet(aPixmap),
2046 tr("MEN_STREAM_LINES"), "", 0, aParent, false,
2047 this, SLOT(OnCreateStreamLines()));
2049 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUT_LINES"));
2050 createAction( VISU_CUT_LINES, tr("MEN_CUT_LINES"), QIconSet(aPixmap),
2051 tr("MEN_CUT_LINES"), "", 0, aParent, false,
2052 this, SLOT(OnCreateCutLines()));
2054 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT_3D"));
2055 createAction( VISU_PLOT_3D, tr("MEN_PLOT_3D"), QIconSet(aPixmap),
2056 tr("MEN_PLOT_3D"), "", 0, aParent, false,
2057 this, SLOT(OnCreatePlot3D()));
2059 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PLOT2D"));
2060 createAction( VISU_PLOT2D, tr("MEN_CREATE_PLOT2D"), QIconSet(aPixmap),
2061 tr("MEN_CREATE_PLOT2D"), "", 0, aParent, false,
2062 this, SLOT(OnCreatePlot2dView()));
2064 createAction( VISU_DELETE_OBJS, tr("MEN_DELETE_OBJS"), QIconSet(),
2065 tr("MEN_DELETE_OBJS"), "", 0, aParent, false,
2066 this, SLOT(OnDeleteObjects()));
2068 createAction( VISU_SHOW_TABLE, tr("MEN_SHOW_TABLE"), QIconSet(),
2069 tr("MEN_SHOW_TABLE"), "", 0, aParent, false,
2070 this, SLOT(OnShowTable()));
2072 createAction( VISU_CREATE_CURVES, tr("MEN_CREATE_CURVES"), QIconSet(),
2073 tr("MEN_CREATE_CURVES"), "", 0, aParent, false,
2074 this, SLOT(OnPlotData()));
2076 createAction( VISU_EXPORT_TABLE, tr("MEN_EXPORT_TABLE"), QIconSet(),
2077 tr("MEN_EXPORT_TABLE"), "", 0, aParent, false,
2078 this, SLOT(OnExportTableToFile()));
2080 createAction( VISU_IMPORT_MED_STRUCTURE, tr("MEN_IMPORT_MED_STRUCTURE"), QIconSet(),
2081 tr("MEN_IMPORT_MED_STRUCTURE"), "", 0, aParent, false,
2082 this, SLOT(OnImportMedField()));
2084 createAction( VISU_IMPORT_MED_TIMESTAMP, tr("MEN_IMPORT_MED_TIMESTAMP"), QIconSet(),
2085 tr("MEN_IMPORT_MED_TIMESTAMP"), "", 0, aParent, false,
2086 this, SLOT(OnImportMedField()));
2088 createAction( VISU_IMPORT_MED_FIELD, tr("MEN_IMPORT_MED_FIELD"), QIconSet(),
2089 tr("MEN_IMPORT_MED_FIELD"), "", 0, aParent, false,
2090 this, SLOT(OnImportMedField()));
2092 createAction( VISU_CREATE_PRS, tr("MEN_CREATE_PRS"), QIconSet(),
2093 tr("MEN_CREATE_PRS"), "", 0, aParent, false,
2094 this, SLOT(OnCreateMesh()));
2096 createAction( VISU_CREATE_MANY_PRS, tr("MEN_CREATE_MANY_PRS"), QIconSet(),
2097 tr("MEN_CREATE_MANY_PRS"), "", 0, aParent, false,
2098 this, SLOT(OnCreateManyMesh()));
2100 createAction( VISU_TRANSLATE_PRS, tr("MEN_TRANSLATE_PRS"), QIconSet(),
2101 tr("MEN_TRANSLATE_PRS"), "", 0, aParent, false,
2102 this, SLOT(OnTranslatePrs()));
2104 createAction( VISU_MERGE_SCALAR_BARS, tr("MEN_MERGE_SCALAR_BARS"), QIconSet(),
2105 tr("MEN_MERGE_SCALAR_BARS"), "", 0, aParent, false,
2106 this, SLOT(OnMergeScalarBars()));
2108 createAction( VISU_FREE_SCALAR_BARS, tr("MEN_FREE_SCALAR_BARS"), QIconSet(),
2109 tr("MEN_FREE_SCALAR_BARS"), "", 0, aParent, false,
2110 this, SLOT(OnFreeScalarBars()));
2112 createAction( VISU_ERASE, tr("MEN_ERASE"), QIconSet(),
2113 tr("MEN_ERASE"), "", 0, aParent, false,
2114 this, SLOT(OnErasePrs()));
2116 createAction( VISU_DISPLAY, tr("MEN_DISPLAY"), QIconSet(),
2117 tr("MEN_DISPLAY"), "", 0, aParent, false,
2118 this, SLOT(OnDisplayPrs()));
2120 createAction( VISU_DISPLAY_ONLY, tr("MEN_DISPLAY_ONLY"), QIconSet(),
2121 tr("MEN_DISPLAY_ONLY"), "", 0, aParent, false,
2122 this, SLOT(OnDisplayOnlyPrs()));
2124 createAction( VISU_COPY_PRS, tr("MEN_COPY_PRS"), QIconSet(),
2125 tr("MEN_COPY_PRS"), "", 0, aParent, false,
2126 this, SLOT(OnCopyPresentation()));
2128 createAction( VISU_CURVE_PROPS, tr("MEN_CURVE_PROPS"), QIconSet(),
2129 tr("MEN_CURVE_PROPS"), "", 0, aParent, false,
2130 this, SLOT(OnCurveProperties()));
2132 createAction( VISU_RENAME, tr("MEN_RENAME"), QIconSet(), tr("MEN_RENAME"), "", 0, aParent, false,
2133 this, SLOT(OnRename()));
2135 createAction( VISU_EDIT_CONTAINER, tr("MEN_EDIT_CONTAINER"), QIconSet(),
2136 tr("MEN_EDIT_CONTAINER"), "", 0, aParent, false,
2137 this, SLOT(OnEditContainer()));
2139 createAction( VISU_CLEAR_CONTAINER, tr("MEN_CLEAR_CONTAINER"), QIconSet(),
2140 tr("MEN_CLEAR_CONTAINER"), "", 0, aParent, false,
2141 this, SLOT(OnClearContainer()));
2143 createAction( VISU_SAVE_VIEW_PARAMS, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2144 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2145 this, SLOT(OnSaveViewParams()));
2146 createAction( VISU_SAVE_VIEW_PARAMS_1, tr("MEN_SAVE_VIEWPARAMS"), QIconSet(),
2147 tr("MEN_SAVE_VIEWPARAMS"), "", 0, aParent, false,
2148 this, SLOT(OnSaveViewParams()));
2150 createAction( VISU_RESTORE_VIEW_PARAMS, tr("MEN_RESTORE_VIEWPARAMS"), QIconSet(),
2151 tr("MEN_RESTORE_VIEWPARAMS"), "", 0, aParent, false,
2152 this, SLOT(OnRestoreViewParams()));
2154 //createAction( VISU_DELETE_VIEW_PARAMS, tr("MEN_DELETE_VIEWPARAMS"), QIconSet(),
2155 // tr("MEN_DELETE_VIEWPARAMS"), "", 0, aParent, false,
2156 // this, SLOT(OnDeleteObjects()));
2158 createAction( VISU_ARRANGE_ACTORS, tr("MEN_ARRANGE_ACTORS"), QIconSet(),
2159 tr("MEN_ARRANGE_ACTORS"), "", 0, aParent, false,
2160 this, SLOT(OnArrangeActors()));
2162 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_POINTS"));
2163 createAction( VISU_POINTS, tr("MEN_POINTS"), QIconSet(aPixmap),
2164 tr("MEN_POINTS"), "", 0, aParent, false,
2165 this, SLOT(OnMakePoints()));
2167 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_WIREFRAME"));
2168 createAction( VISU_WIREFRAME, tr("MEN_WIREFRAME"), QIconSet(aPixmap),
2169 tr("MEN_WIREFRAME"), "", 0, aParent, false,
2170 this, SLOT(OnMakeWireframe()));
2172 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SURFACE"));
2173 createAction( VISU_SURFACE, tr("MEN_SURFACE"), QIconSet(aPixmap),
2174 tr("MEN_SURFACE"), "", 0, aParent, false,
2175 this, SLOT(OnMakeSurface()));
2177 createAction( VISU_INSIDEFRAME, tr("MEN_INSIDEFRAME"), QIconSet(),
2178 tr("MEN_INSIDEFRAME"), "", 0, aParent, false,
2179 this, SLOT(OnMakeInsideframe()));
2181 createAction( VISU_SURFACEFRAME, tr("MEN_SURFACEFRAME"), QIconSet(),
2182 tr("MEN_SURFACEFRAME"), "", 0, aParent, false,
2183 this, SLOT(OnMakeSurfaceframe()));
2185 createAction( VISU_SHRINK, tr("MEN_SHRINK"), QIconSet(),
2186 tr("MEN_SHRINK"), "", 0, aParent, false,
2187 this, SLOT(OnMakeShrink()));
2189 createAction( VISU_UNSHRINK, tr("MEN_UNSHRINK"), QIconSet(),
2190 tr("MEN_UNSHRINK"), "", 0, aParent, false,
2191 this, SLOT(OnMakeShrink()));
2193 createAction( VISU_CELL_COLOR, tr("MEN_CELL_COLOR"), QIconSet(),
2194 tr("MEN_CELL_COLOR"), "", 0, aParent, false,
2195 this, SLOT(OnChangeColor()));
2197 createAction( VISU_COLOR, tr("MEN_COLOR"), QIconSet(),
2198 tr("MEN_COLOR"), "", 0, aParent, false,
2199 this, SLOT(OnChangeColor()));
2201 createAction( VISU_EDGE_COLOR, tr("MEN_EDGE_COLOR"), QIconSet(),
2202 tr("MEN_EDGE_COLOR"), "", 0, aParent, false,
2203 this, SLOT(OnChangeWireframeColor()));
2205 createAction( VISU_OPACITY, tr("MEN_OPACITY"), QIconSet(),
2206 tr("MEN_OPACITY"), "", 0, aParent, false,
2207 this, SLOT(OnChangeOpacity()));
2209 createAction( VISU_LINE_WIDTH, tr("MEN_LINE_WIDTH"), QIconSet(),
2210 tr("MEN_LINE_WIDTH"), "", 0, aParent, false,
2211 this, SLOT(OnChangeLines()));
2213 createAction( VISU_EDIT_PRS, tr("MEN_EDIT_PRS"), QIconSet(),
2214 tr("MEN_EDIT_PRS"), "", 0, aParent, false,
2215 this, SLOT(OnEditPrs()));
2217 createAction( VISU_CREATE_TABLE, tr("MEN_CREATE_TABLE"), QIconSet(),
2218 tr("MEN_CREATE_TABLE"), "", 0, aParent, false,
2219 this, SLOT(OnCreateTable()));
2221 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SWEEP"));
2222 createAction( VISU_SWEEP, tr("MEN_SWEEP"), QIconSet(aPixmap),
2223 tr("MEN_SWEEP"), "", 0, aParent, false,
2224 this, SLOT(OnSweep()));
2226 createAction( VISU_CLIPPING, tr("MEN_CLIPPING"), QIconSet(),
2227 tr("MEN_CLIPPING"), "", 0, aParent, false,
2228 this, SLOT(OnClippingPlanes()));
2230 createAction( VISU_SELECTION_INFO, tr("MEN_SELECTION_INFO"), QIconSet(),
2231 tr("MEN_SELECTION_INFO"), "", 0, aParent, false,
2232 this, SLOT(OnSelectionInfo()));
2234 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_TIMEANIMATION"));
2235 createAction( VISU_ANIMATION, tr("MEN_ANIMATION"), QIconSet(aPixmap),
2236 tr("MEN_ANIMATION"), "", 0, aParent, false,
2237 this, SLOT(OnTimeAnimation()));
2239 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_ERASE_ALL"));
2240 createAction( VISU_ERASE_ALL, tr("MEN_ERASE_ALL"), QIconSet(aPixmap),
2241 tr("MEN_ERASE_ALL"), "", 0, aParent, false,
2242 this, SLOT(OnEraseAll()));
2244 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_GLOBAL_SELECTION"));
2245 createAction( VISU_GLOBAL_SELECTION, tr("MEN_GLOBAL_SELECTION"), QIconSet(aPixmap),
2246 tr("MEN_GLOBAL_SELECTION"), "", 0, aParent, false,
2247 //this, SLOT(OnEraseAll()));
2250 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_PARTIAL_SELECTION"));
2251 createAction( VISU_PARTIAL_SELECTION, tr("MEN_PARTIAL_SELECTION"), QIconSet(aPixmap),
2252 tr("MEN_PARTIAL_SELECTION"), "", 0, aParent, false,
2253 //this, SLOT(OnEraseAll()));
2256 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_SCALING"));
2257 createAction( VISU_SCALING, tr("MEN_SCALING"), QIconSet(aPixmap),
2258 tr("MEN_SCALING"), "", 0, aParent, false,
2259 this, SLOT(OnScaling()));
2261 aPixmap = aResourceMgr->loadPixmap("VISU",tr("ICON_CUBE_AXES"));
2262 createAction( VISU_CUBE_AXES, tr("MEN_CUBE_AXES"), QIconSet(aPixmap),
2263 tr("MEN_CUBE_AXES"), "", 0, aParent, false,
2264 this, SLOT(OnCubeAxes()));
2266 createAction( VISU_SHOW_ANIMATION, tr("MEN_SHOW_ANIMATION"), QIconSet(),
2267 tr("MEN_SHOW_ANIMATION"), "", 0, aParent, false,
2268 this, SLOT(OnShowAnimation()));
2275 // Add actions to menus
2277 aMenuId = createMenu( tr( "MEN_DESK_FILE" ), -1 );
2278 createMenu( separator(), aMenuId, -1, 10 );
2279 createMenu( VISU_IMPORT_FROM_FILE, aMenuId, 10 ); // import from file
2280 createMenu( VISU_EXPLORE_MED, aMenuId, 10 ); // explore MED file
2281 createMenu( VISU_IMPORT_TABLE, aMenuId, 10 ); // import table
2283 aMenuId = createMenu( tr( "MEN_VISUALIZATION" ), -1, -1, 30 );
2284 createMenu( VISU_SCALAR_MAP, aMenuId, 10 ); // scalar map
2285 createMenu( VISU_DEFORMED_SHAPE, aMenuId, 10 ); // deformed shape
2286 createMenu( VISU_VECTORS, aMenuId, 10 ); // vectors
2287 createMenu( VISU_ISO_SURFACES, aMenuId, 10 ); // iso surfaces
2288 createMenu( VISU_CUT_PLANES, aMenuId, 10 ); // cut planes
2289 createMenu( VISU_CUT_LINES, aMenuId, 10 ); // cut lines
2290 createMenu( VISU_STREAM_LINES, aMenuId, 10 ); // stream lines
2291 createMenu( VISU_PLOT_3D, aMenuId, 10 ); // Plot3d
2293 aMenuId = createMenu( tr( "MEN_SELECTION" ), -1, -1, 30 );
2294 createMenu( VISU_SELECTION_INFO, aMenuId, 10 ); // selection info
2296 aMenuId = createMenu( tr( "MEN_REPRESENTATION" ), -1, -1, 30 );
2298 createMenu( tr( "MEN_DISPLAY_SELECTION" ), aMenuId, 10 ); // display selection
2299 createMenu( VISU_POINTS, parentId, 10 ); // points
2300 createMenu( VISU_WIREFRAME, parentId, 10 ); // wireframe
2301 createMenu( VISU_SURFACE, parentId, 10 ); // surface
2302 createMenu( VISU_ERASE_ALL, aMenuId, 10 ); // erase all
2303 createMenu( VISU_GLOBAL_SELECTION, aMenuId, 10 ); // global selection
2304 createMenu( VISU_PARTIAL_SELECTION, aMenuId, 10 ); // partial selection
2305 createMenu( VISU_SCALING, aMenuId, 10 ); // scaling
2306 createMenu( VISU_CUBE_AXES, aMenuId, 10 ); // scaling
2313 int aToolId = createTool(tr("TOOL_VISUALISATION"));
2314 createTool( VISU_SCALAR_MAP, aToolId );
2315 createTool( VISU_DEFORMED_SHAPE, aToolId );
2316 createTool( VISU_VECTORS, aToolId );
2317 createTool( VISU_ISO_SURFACES, aToolId );
2318 createTool( VISU_CUT_PLANES, aToolId );
2319 createTool( VISU_CUT_LINES, aToolId );
2320 createTool( VISU_STREAM_LINES, aToolId );
2321 createTool( VISU_PLOT_3D, aToolId );
2323 aToolId = createTool(tr("TOOL_REPRESENTATION"));
2324 createTool( VISU_POINTS, aToolId );
2325 createTool( VISU_WIREFRAME, aToolId );
2326 createTool( VISU_SURFACE, aToolId );
2327 createTool( VISU_ERASE_ALL, aToolId );
2328 createTool( VISU_GLOBAL_SELECTION, aToolId );
2329 createTool( VISU_PARTIAL_SELECTION, aToolId );
2330 createTool( VISU_SCALING, aToolId );
2331 createTool( VISU_CUBE_AXES, aToolId );
2338 // Prepare popup menus
2339 QtxPopupMgr* mgr = popupMgr();
2341 // VISU root commands
2342 mgr->insert( action( VISU_IMPORT_FROM_FILE ), -1, -1, -1 ); // import MED file
2343 mgr->insert( action( VISU_IMPORT_TABLE ), -1, -1, -1 ); // import tables from file
2344 mgr->insert( action( VISU_PLOT2D ), -1, -1, -1 ); // create Plot2d View
2346 //mgr->insert( action( VISU_IMPORT_MED ), -1, -1, -1 ); // import MED structure from MED module
2349 mgr->insert( action( VISU_SCALAR_MAP ), -1, -1, -1 ); // scalar bar
2350 mgr->insert( action( VISU_ISO_SURFACES ), -1, -1, -1 ); // iso surface
2351 mgr->insert( action( VISU_CUT_PLANES ), -1, -1, -1 ); // cut planes
2352 mgr->insert( action( VISU_CUT_LINES ), -1, -1, -1 ); // cut lines
2353 mgr->insert( action( VISU_DEFORMED_SHAPE ), -1, -1, -1 ); // deformed shape
2354 mgr->insert( action( VISU_VECTORS ), -1, -1, -1 ); // vectors
2355 mgr->insert( action( VISU_STREAM_LINES ), -1, -1, -1 ); // stream lines
2356 mgr->insert( action( VISU_PLOT_3D ), -1, -1, -1 ); // Plot3d
2358 mgr->insert( action( VISU_CREATE_PRS ), -1, -1, -1 ); // create presentation
2359 mgr->insert( action( VISU_CREATE_MANY_PRS ), -1, -1, -1 ); // create presentations
2361 mgr->insert( action( VISU_CREATE_TABLE ), -1, -1, -1 ); // create table
2364 mgr->insert( action( VISU_EDIT_PRS ), -1, -1, -1 );
2365 mgr->insert( action( VISU_EDIT_CONTAINER ), -1, -1, -1 );
2368 mgr->insert( action( VISU_RENAME ), -1, -1, -1 );
2371 mgr->insert( action( VISU_COPY_PRS ), -1, -1, -1 );
2374 mgr->insert( action( VISU_CLEAR_CONTAINER ), -1, -1, -1 );
2377 //mgr->insert( action( VISU_SHOW_TABLE ), -1, -1, -1 ); // show table
2378 //mgr->insert( action( VISU_CREATE_CURVES ), -1, -1, -1 ); // create curves
2379 //mgr->insert( action( VISU_EXPORT_TABLE ), -1, -1, -1 ); // export table
2381 mgr->insert( separator(), -1, -1, -1 );
2383 mgr->insert( action( VISU_ERASE ), -1, -1, -1 ); // erase
2384 mgr->insert( action( VISU_DISPLAY ), -1, -1, -1 ); // display
2385 mgr->insert( action( VISU_DISPLAY_ONLY ), -1, -1, -1 ); // display only
2387 // "Representation" submenu
2388 int parentId = mgr->insert( tr( "MEN_REPRESENTATION" ), -1, -1 );
2389 mgr->insert( action( VISU_POINTS ) , parentId, -1, -1 ); // points
2390 mgr->insert( action( VISU_WIREFRAME ) , parentId, -1, -1 ); // wireframe
2391 mgr->insert( action( VISU_SURFACE ) , parentId, -1, -1 ); // surface
2392 mgr->insert( action( VISU_INSIDEFRAME ) , parentId, -1, -1 ); // insideframe
2393 mgr->insert( action( VISU_SURFACEFRAME ), parentId, -1, -1 ); // surfaceframe
2394 mgr->insert( action( VISU_SHRINK ) , parentId, -1, -1 ); // shrink
2395 mgr->insert( action( VISU_UNSHRINK ) , parentId, -1, -1 ); // unshrink
2397 // "Properties" submenu
2398 parentId = mgr->insert( tr( "MEN_PROPERTIES" ), -1, -1 );
2399 mgr->insert( action( VISU_CELL_COLOR ), parentId, -1, -1 ); // cell color
2400 mgr->insert( action( VISU_EDGE_COLOR ), parentId, -1, -1 ); // edge color
2401 mgr->insert( action( VISU_COLOR ) , parentId, -1, -1 ); // color
2402 mgr->insert( action( VISU_OPACITY ) , parentId, -1, -1 ); // opacity
2403 mgr->insert( action( VISU_LINE_WIDTH ), parentId, -1, -1 ); // line width
2405 mgr->insert( separator(), -1, -1, -1 );
2407 // Other presentations management
2408 mgr->insert( action( VISU_TRANSLATE_PRS ), -1, -1, -1 );
2409 mgr->insert( action( VISU_CLIPPING ), -1, -1, -1 );
2411 mgr->insert( action( VISU_MERGE_SCALAR_BARS ), -1, -1, -1 );
2412 mgr->insert( action( VISU_FREE_SCALAR_BARS ), -1, -1, -1 );
2414 mgr->insert( action( VISU_SWEEP ), -1, -1, -1 );
2415 mgr->insert( action( VISU_ANIMATION ), -1, -1, -1 );
2417 mgr->insert( separator(), -1, -1, -1 );
2419 // view parameters commands
2420 mgr->insert( action( VISU_SAVE_VIEW_PARAMS ), -1, -1, -1 ); // save view params
2421 mgr->insert( action( VISU_SAVE_VIEW_PARAMS_1 ), -1, -1, -1 ); // save view params
2422 mgr->insert( action( VISU_RESTORE_VIEW_PARAMS ), -1, -1, -1 ); // restore view params
2423 //mgr->insert( action( VISU_DELETE_VIEW_PARAMS ), -1, -1, -1 ); // delete view params
2425 mgr->insert( action( VISU_ARRANGE_ACTORS ), -1, -1, -1 ); // arrange actors
2427 mgr->insert( action( VISU_CURVE_PROPS ), -1, -1, -1 ); // curve properties
2429 mgr->insert( action( VISU_SELECTION_INFO ), -1, -1, -1 ); // Selection info
2433 QString aSel_One_ObjBr ("client='ObjectBrowser' and selcount=1");
2434 QString aSel_Some_ObjBr ("client='ObjectBrowser' and selcount>0");
2435 QString aSel_Many_ObjBr ("client='ObjectBrowser' and selcount>1");
2437 QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' "
2438 "'VISU::TCUTLINES' 'VISU::TVECTORS' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'");
2440 QString aCurveAll = "'VISU::TTABLE' 'VISU::TCURVE' 'VISU::TCONTAINER'";
2442 // VISU root commands
2443 QString aRule = aSel_One_ObjBr + " and type='VISU::TVISUGEN'";
2444 mgr->setRule( action( VISU_IMPORT_FROM_FILE ), aRule, true );
2445 mgr->setRule( action( VISU_IMPORT_TABLE ), aRule, true );
2446 mgr->setRule( action( VISU_PLOT2D ), aRule, true );
2448 // timestamp commands
2449 aRule = aSel_One_ObjBr + " and type='VISU::TTIMESTAMP'";
2450 mgr->setRule( action( VISU_SCALAR_MAP ), aRule, true );
2451 mgr->setRule( action( VISU_ISO_SURFACES ), aRule, true );
2452 mgr->setRule( action( VISU_CUT_PLANES ), aRule, true );
2453 mgr->setRule( action( VISU_CUT_LINES ), aRule, true );
2454 mgr->setRule( action( VISU_PLOT_3D ), aRule, true );
2455 aRule += " and nbComponents>1";
2456 mgr->setRule( action( VISU_DEFORMED_SHAPE ), aRule, true );
2457 mgr->setRule( action( VISU_VECTORS ), aRule, true );
2458 mgr->setRule( action( VISU_STREAM_LINES ), aRule, true );
2461 //aRule = aSel_One_ObjBr + " and type='VISU::TTABLE'";
2462 //mgr->setRule( action( VISU_SHOW_TABLE ), aRule, true );
2463 //mgr->setRule( action( VISU_CREATE_CURVES ), aRule, true );
2464 //mgr->setRule( action( VISU_EXPORT_TABLE ), aRule, true );
2466 aRule = "(" + aSel_Some_ObjBr + " and ((type='VISU::TTABLE' and nbChildren>0) or"
2467 " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))"
2468 ") or (selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "})";
2470 mgr->setRule( action( VISU_ERASE ), aRule + "and (isVisible=true)", true );// TODO: aRule.arg(" and isVisible=1"), true );
2471 mgr->setRule( action( VISU_DISPLAY ), aRule + "and (isVisible=false)", true );// TODO: aRule.arg(" and isVisible=0"), true );
2472 mgr->setRule( action( VISU_DISPLAY_ONLY ), aRule, true );
2474 aRule = "selcount>0 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2475 mgr->setRule( action( VISU_TRANSLATE_PRS ), aRule, true );
2477 aRule = "selcount>1 and $type in {'VISU::TMESH' " + aPrsAll + "}";
2478 mgr->setRule( action( VISU_MERGE_SCALAR_BARS ), aRule, true );
2479 mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
2482 aRule = "selcount=1 and type='VISU::TVIEW3D'";
2483 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
2484 mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
2485 mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2486 //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
2488 mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
2490 // 3D presentations commands
2491 QString aPrsType = " and $type in {'VISU::TMESH' " + aPrsAll + "}";
2492 QString aInsideType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TDEFORMEDSHAPE'}";
2493 QString aSurfType = " and $type in {'VISU::TMESH'}";
2494 QString aShrinkType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' "
2495 "'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TPLOT3D'}";
2496 QString aLineType = " and $type in {'VISU::TMESH' 'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' "
2497 "'VISU::TCUTPLANES' 'VISU::TCUTLINES' 'VISU::TSTREAMLINES' 'VISU::TPLOT3D'}";
2499 aRule = "selcount=1";
2500 mgr->setRule( action( VISU_CLIPPING ), aRule + aPrsType, true );
2502 // "Representation" submenu
2503 QString aNotPoints = " and $representation in {'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2504 QString aNotWirefr = " and $representation in {'VISU::POINT' 'VISU::SHADED' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2505 QString aNotSurfac = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::INSIDEFRAME' 'VISU::SURFACEFRAME'}";
2506 QString aNotInside = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::SURFACEFRAME'}";
2507 QString aNotSurffr = " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}";
2509 mgr->setRule( action( VISU_POINTS ) , aRule + aPrsType + aNotPoints, true );
2510 mgr->setRule( action( VISU_WIREFRAME ) , aRule + aPrsType + aNotWirefr, true );
2511 mgr->setRule( action( VISU_SURFACE ) , aRule + aPrsType + aNotSurfac, true );
2512 mgr->setRule( action( VISU_INSIDEFRAME ) , aRule + aInsideType + aNotInside, true );
2513 mgr->setRule( action( VISU_SURFACEFRAME ), aRule + aSurfType + aNotSurffr, true );
2515 mgr->setRule( action( VISU_SHRINK ) , aRule + aShrinkType + " and isShrunk=0", true );
2516 mgr->setRule( action( VISU_UNSHRINK ), aRule + aShrinkType + " and isShrunk=1", true );
2518 // "Properties" submenu
2519 mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2520 mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'", true );
2521 mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
2522 " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
2523 "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))", true );
2524 mgr->setRule( action( VISU_OPACITY ), aRule + aShrinkType + " and hasActor=1", true );
2525 mgr->setRule( action( VISU_LINE_WIDTH ), aRule + aLineType + " and hasActor=1", true );
2528 aRule = "selcount=1 and ($type in {'VISU::TVIEW3D' 'VISU::TMESH' " + aCurveAll + " " + aPrsAll + "})";
2529 mgr->setRule( action( VISU_RENAME ), aRule, true );
2531 // copy presentation command
2532 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2533 mgr->setRule( action( VISU_COPY_PRS ), aRule, true );
2536 aRule = "selcount=1 and type='VISU::TCURVE'";
2537 mgr->setRule( action( VISU_CURVE_PROPS ), aRule, true );
2539 // curve container commands
2540 aRule = aSel_One_ObjBr + " and type='VISU::TCONTAINER'";
2541 mgr->setRule( action( VISU_EDIT_CONTAINER ), aRule, true );
2542 mgr->setRule( action( VISU_CLEAR_CONTAINER ), aRule, true );
2544 aRule = "selcount=1 and $type in {" + aPrsAll + "}";
2545 mgr->setRule( action( VISU_EDIT_PRS ), aRule, true );
2547 aRule = "selcount=1 and type='VISU::TCUTLINES' and nbNamedChildren=0";
2548 mgr->setRule( action( VISU_CREATE_TABLE ), aRule, true );
2550 aRule = "selcount=1 and ($type in {" + aPrsAll + "})";
2551 mgr->setRule( action( VISU_SWEEP ), aRule, true );
2553 // Selection info popup item
2554 aRule = "client='VTKViewer' and selcount=1" + aInsideType;
2555 mgr->setRule( action( VISU_SELECTION_INFO ), aRule, true );
2557 aRule = "client='ObjectBrowser' and selcount>0 and $type in {'VISU::TFIELD'} and nbTimeStamps>1";
2558 mgr->setRule( action( VISU_ANIMATION ), aRule, true );
2560 aRule = "client='ObjectBrowser' and $type in {'VISU::TENTITY' 'VISU::TFAMILY' 'VISU::TGROUP'}";
2561 mgr->setRule( action( VISU_CREATE_PRS ), aRule + " and selcount=1", true );
2562 mgr->setRule( action( VISU_CREATE_MANY_PRS ), aRule + " and selcount>1", true );
2564 //aRule = "client='ObjectBrowser' and type='MEDFIELD'";
2565 //mgr->setRule( action( VISU_IMPORT_MED ), aRule, true );
2568 //***************************************************************************
2569 void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle )
2571 SalomeApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
2573 SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
2574 SALOME_ListIO aListIO;
2575 aSelectionMgr->selectedObjects(aListIO);
2577 if (aListIO.Extent() < 1) return;
2579 _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
2581 // Check if "Merge Scalar Range" can be applied
2583 SALOME_ListIteratorOfListIO It (aListIO);
2584 for (; It.More(); It.Next()) {
2585 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2586 /*std::vector<VISU::Prs3d_i*> aPrsList = GetPrs3dList(this, anIO);
2587 nbPrs += aPrsList.size();*/
2589 if (!anIO.IsNull() && anIO->hasEntry()) {
2590 _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
2591 CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(aSObject);
2592 if (CORBA::is_nil(aCORBAObject)) {
2593 _PTR(GenericAttribute) anAttr;
2594 if (aSObject->FindAttribute(anAttr, "AttributeComment")) {
2595 _PTR(AttributeComment) aComment (anAttr);
2596 string aComm = aComment->Value();
2597 QString strIn (aComm.c_str());
2598 VISU::Storable::TRestoringMap pMap;
2599 VISU::Storable::StrToMap(strIn, pMap);
2601 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2602 if (isExist && aType == VISU::TTIMESTAMP) {
2603 _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(aSObject);
2605 for (; anIter->More(); anIter->Next()) {
2606 aPrs = anIter->Value();
2607 if (!aPrs) continue;
2608 std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(this, aPrs);
2609 nbPrs += aSubList.size();
2618 theMenu->insertSeparator();
2619 action( VISU_MERGE_SCALAR_BARS )->addTo(theMenu);
2620 action( VISU_FREE_SCALAR_BARS )->addTo(theMenu);
2623 theMenu->insertSeparator();
2625 // Check if some (nb > 0) removable objects selected
2626 if (IsRemovableSelected(this)) {
2627 action( VISU_DELETE_OBJS )->addTo(theMenu);
2630 // Check single selection
2631 if (aListIO.Extent() != 1) return;
2633 Handle(SALOME_InteractiveObject) anIO;
2634 VISU::Storable::TRestoringMap aMap;
2635 CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
2637 _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
2639 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2641 if (aType == VISU::TANIMATION) {
2642 action( VISU_SHOW_ANIMATION )->addTo(theMenu);
2644 } else if (IsSObjectTable(SO)) {
2645 action( VISU_SHOW_TABLE )->addTo(theMenu);
2646 action( VISU_CREATE_CURVES )->addTo(theMenu);
2647 action( VISU_EXPORT_TABLE )->addTo(theMenu);
2648 theMenu->insertSeparator();
2651 if (!CORBA::is_nil(anObject)) {
2652 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow(anObject);
2653 if (!CORBA::is_nil(aMED.in())) {
2654 action( VISU_IMPORT_MED_STRUCTURE )->addTo(theMenu);
2657 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(anObject); // "Import Structure"
2658 if (!CORBA::is_nil(aField)) {
2659 action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
2662 _PTR(SObject) aSFather = SO->GetFather();
2664 _PTR(GenericAttribute) anAttr;
2665 aSFather->FindAttribute(anAttr, "AttributeName");
2667 _PTR(AttributeName) aName (anAttr);
2668 std::string aValue = aName->Value();
2669 if (strcmp(aValue.c_str(), "MEDFIELD") == 0) {
2670 action( VISU_IMPORT_MED_FIELD )->addTo(theMenu); // "Import Field"
2679 //***************************************************************************
2682 windows( QMap<int, int>& theMap ) const
2685 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::DockLeft );
2686 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::DockBottom );
2692 viewManagers( QStringList& theList ) const
2695 theList.append( SVTK_Viewer::Type() );
2703 CORBA::String_var anIOR = GetVisuGen(this)->GetID();
2704 return QString(anIOR.in());
2710 activateModule( SUIT_Study* theStudy )
2712 SalomeApp_Module::activateModule( theStudy );
2714 setMenuShown( true );
2715 setToolShown( true );
2722 deactivateModule( SUIT_Study* theStudy )
2724 setMenuShown( false );
2725 setToolShown( false );
2727 SalomeApp_Module::deactivateModule( theStudy );
2731 SalomeApp_Selection*
2733 createSelection() const
2735 return new VisuGUI_Selection( (SalomeApp_Module*)this );
2738 //******************************************************************
2739 void VisuGUI::studyActivated()
2741 GetVisuGen(this)->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(this))));
2749 return new VisuGUI();
2753 void VisuGUI::createPreferences()
2755 int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) );
2757 int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab );
2758 int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_title_font" );
2759 addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_title_color" );
2760 int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_label_font" );
2761 addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_label_color" );
2764 fam.append( tr( "VISU_FONT_ARIAL" ) );
2765 fam.append( tr( "VISU_FONT_COURIER" ) );
2766 fam.append( tr( "VISU_FONT_TIMES" ) );
2767 int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) );
2769 setPreferenceProperty( tfont, "families", fam );
2770 setPreferenceProperty( tfont, "system", false );
2771 setPreferenceProperty( tfont, "widget_flags", wflag );
2772 setPreferenceProperty( lfont, "families", fam );
2773 setPreferenceProperty( lfont, "system", false );
2774 setPreferenceProperty( lfont, "widget_flags", wflag );
2776 int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab );
2778 int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" );
2779 setPreferenceProperty( numcol, "min", 2 );
2780 setPreferenceProperty( numcol, "max", 64 );
2782 int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" );
2783 setPreferenceProperty( numlab, "min", 2 );
2784 setPreferenceProperty( numlab, "max", 65 );
2786 int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab );
2787 int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_orientation" );
2788 QStringList orients;
2789 orients.append( tr( "VISU_VERTICAL" ) );
2790 orients.append( tr( "VISU_HORIZONTAL" ) );
2791 QValueList<QVariant> indices;
2792 indices.append( 0 );
2793 indices.append( 1 );
2794 setPreferenceProperty( orient, "strings", orients );
2795 setPreferenceProperty( orient, "indexes", indices );
2797 int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab );
2798 int xv = addPreference( tr( "VISU_X" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" );
2799 int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" );
2800 int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" );
2801 int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" );
2802 setPreferenceProperty( xv, "step", 0.1 );
2803 setPreferenceProperty( yv, "step", 0.1 );
2804 setPreferenceProperty( wv, "step", 0.1 );
2805 setPreferenceProperty( hv, "step", 0.1 );
2806 setPreferenceProperty( xv, "min", 0.0 );
2807 setPreferenceProperty( yv, "min", 0.0 );
2808 setPreferenceProperty( wv, "min", 0.0 );
2809 setPreferenceProperty( hv, "min", 0.0 );
2810 setPreferenceProperty( xv, "max", 1.0 );
2811 setPreferenceProperty( yv, "max", 1.0 );
2812 setPreferenceProperty( wv, "max", 1.0 );
2813 setPreferenceProperty( hv, "max", 1.0 );
2815 int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab );
2816 int xh = addPreference( tr( "VISU_X" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" );
2817 int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" );
2818 int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" );
2819 int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" );
2820 setPreferenceProperty( xh, "step", 0.1 );
2821 setPreferenceProperty( yh, "step", 0.1 );
2822 setPreferenceProperty( wh, "step", 0.1 );
2823 setPreferenceProperty( hh, "step", 0.1 );
2824 setPreferenceProperty( xh, "min", 0.0 );
2825 setPreferenceProperty( yh, "min", 0.0 );
2826 setPreferenceProperty( wh, "min", 0.0 );
2827 setPreferenceProperty( hh, "min", 0.0 );
2828 setPreferenceProperty( xh, "max", 1.0 );
2829 setPreferenceProperty( yh, "max", 1.0 );
2830 setPreferenceProperty( wh, "max", 1.0 );
2831 setPreferenceProperty( hh, "max", 1.0 );
2833 int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) );
2835 int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab );
2836 setPreferenceProperty( rangeGr, "columns", 1 );
2838 int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_mode" );
2840 modes.append( tr( "VISU_MODULUS" ) );
2841 modes.append( tr( "VISU_COMPONENT" ) + tr("1") );
2842 modes.append( tr( "VISU_COMPONENT" ) + tr("2") );
2843 modes.append( tr( "VISU_COMPONENT" ) + tr("3") );
2845 indices.append( 0 );
2846 indices.append( 1 );
2847 indices.append( 2 );
2848 indices.append( 3 );
2849 setPreferenceProperty( mode, "strings", modes );
2850 setPreferenceProperty( mode, "indexes", indices );
2852 addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" );
2854 int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" );
2856 types.append( tr( "VISU_FIELD_RANGE" ) );
2857 types.append( tr( "VISU_IMPOSED_RANGE" ) );
2859 indices.append( 0 );
2860 indices.append( 1 );
2861 setPreferenceProperty( rangetype, "strings", types );
2862 setPreferenceProperty( rangetype, "indexes", indices );
2864 int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab );
2866 int min = addPreference( tr( "VISU_MIN" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_min" );
2867 int max = addPreference( tr( "VISU_MAX" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_max" );
2868 setPreferenceProperty( min, "step", 0.1 );
2869 setPreferenceProperty( max, "step", 0.1 );
2871 int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab );
2872 setPreferenceProperty( sweepGr, "columns", 1 );
2874 int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, SalomeApp_Preferences::DblSpin, "VISU", "sweeping_time_step" );
2875 int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" );
2876 int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" );
2877 setPreferenceProperty( timestep, "min", 0.1 );
2878 setPreferenceProperty( timestep, "step", 0.1 );
2879 setPreferenceProperty( timestep, "max", 1000 );
2880 setPreferenceProperty( nbcycles, "max", 100 );
2881 setPreferenceProperty( nbsteps, "max", 200 );
2883 int importGr = addPreference( tr( "MED files import" ), srangeTab );
2884 addPreference( tr( "Full MED loading" ), importGr, SalomeApp_Preferences::Bool, "VISU", "full_med_loading" );
2887 void VisuGUI::preferencesChanged( const QString&, const QString& )