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
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_PrsObject_i.hh"
34 #include "VISU_ViewManager_i.hh"
36 #include "VISU_PipeLine.hxx"
38 #include "VISU_Prs3d_i.hh"
39 #include "VISU_Mesh_i.hh"
40 #include "VISU_ScalarMap_i.hh"
41 #include "VISU_IsoSurfaces_i.hh"
42 #include "VISU_DeformedShape_i.hh"
43 #include "VISU_CutPlanes_i.hh"
44 #include "VISU_CutLines_i.hh"
45 #include "VISU_Vectors_i.hh"
46 #include "VISU_StreamLines_i.hh"
47 #include "VISU_Table_i.hh"
49 #include "VISU_Actor.h"
50 #include "VISU_MeshAct.h"
52 #include "VisuGUI_MagnitudeDlg.h"
53 #include "VisuGUI_CursorDlg.h"
54 #include "VisuGUI_ScalarBarDlg.h"
55 #include "VisuGUI_SweepPrefDlg.h"
56 #include "VisuGUI_CutPlanesDlg.h"
57 #include "VisuGUI_CutLinesDlg.h"
58 #include "VisuGUI_VectorsDlg.h"
59 #include "VisuGUI_IsoSurfacesDlg.h"
60 #include "VisuGUI_StreamLinesDlg.h"
61 #include "VisuGUI_EditContainerDlg.h"
62 #include "VisuGUI_TimeAnimation.h"
64 #include "VisuGUI_Selection.h"
65 #include "VisuGUI_NonIsometricDlg.h"
67 #include "SALOMEGUI_ImportOperation.h"
68 #include "SALOMEGUI_QtCatchCorbaException.hxx"
69 #include "utilities.h"
71 #include "QAD_Config.h"
73 #include "QAD_Settings.h"
74 #include "QAD_Tools.h"
75 #include "QAD_LeftFrame.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_ObjectBrowser.h"
79 #include "QAD_ObjectBrowserItem.h"
80 #include "QAD_Menus.h"
81 #include "QAD_Resource.h"
82 #include "QAD_ResourceMgr.h"
83 #include "QAD_FileDlg.h"
84 #include "QAD_WaitCursor.h"
85 #include "SALOME_Selection.h"
86 #include "SALOMEGUI_NameDlg.h"
87 #include "SALOMEGUI_TableDlg.h"
88 #include "SALOMEGUI_SetupCurveDlg.h"
89 #include "SALOMEGUI_SetValueDlg.h"
90 #include "SALOMEGUI_Desktop.h"
91 #include "Plot2d_SetupPlot2dDlg.h"
92 #include "Plot2d_ViewFrame.h"
93 #include "VTKViewer_ViewFrame.h"
94 #include "VTKViewer_RenderWindow.h"
95 #include "VTKViewer_InteractorStyleSALOME.h"
96 #include "VTKViewer_RenderWindowInteractor.h"
97 #include "VisuGUI_FileDlg.h"
100 #define INCLUDE_MENUITEM_DEF
101 #include <qpopupmenu.h>
103 #include <qpainter.h>
105 #include <qapplication.h>
106 #include <qinputdialog.h>
107 #include <qcolordialog.h>
109 #include <qspinbox.h>
110 #include <qradiobutton.h>
112 #include <qlistbox.h>
113 #include <qcombobox.h>
116 //VRV: porting on Qt 3.0.5
117 #if QT_VERSION >= 0x030005
118 #include <qlistview.h>
120 //VRV: porting on Qt 3.0.5
121 #include <qmessagebox.h>
123 #include CORBA_CLIENT_HEADER(MED_Gen)
125 #include <vtkActor.h>
126 #include <vtkRenderer.h>
127 #include <vtkDataSetMapper.h>
128 #include <vtkActorCollection.h>
130 // Open CASCADE Include
131 #include <TCollection_AsciiString.hxx>
135 static int MYCHECKTIME = 1;
137 static int MYCHECKTIME = 0;
139 #include <Utils_Timer.hxx>
144 static int MYDEBUG = 0;
146 static int MYDEBUG = 0;
149 class CustomItem : public QCustomMenuItem
152 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
155 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
158 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
159 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
160 p->setFont( myFont );
161 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
167 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
170 bool fullSpan() const
180 inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
181 if(!theSObject->_is_nil()) {
182 SALOMEDS::GenericAttribute_var anAttr;
183 if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
185 if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
192 static VisuGUI MYVISUGUI;
193 VisuGUI *visuGUI = &MYVISUGUI;
195 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
196 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
197 return VISU::VISU_Gen_i::GetVisuGenImpl();
200 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
201 const char* theActorClassName = "VISU_Actor")
203 vtkRenderer *aRen = theViewFrame->getRenderer();
204 vtkActorCollection *anActColl = aRen->GetActors();
207 int nothingVisible=1;
209 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
210 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
211 // loop through all props
212 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
213 // if it's invisible, or has no geometry, we can skip the rest
214 if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
215 bounds = prop->GetBounds();
216 // make sure we haven't got bogus bounds
217 if ( bounds != NULL &&
218 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
219 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
220 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
223 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
224 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
225 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
226 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
227 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
228 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
232 return nothingVisible;
235 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
236 static float PRECISION = 0.000001;
237 static float DEVIATION = 600;
239 if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
241 float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
243 float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
245 float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
247 CameraOrient aCameraOrient = e3D;
248 if(absX <= PRECISION) aCameraOrient = eFront;
249 else {if(absY <= PRECISION) aCameraOrient = eLeft;
250 else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
252 float dev_abs_XY = absX / absY;
253 float dev_abs_YZ = absY / absZ;
254 float dev_abs_XZ = absX / absZ;
255 if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
256 else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
257 else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
259 switch(aCameraOrient){
260 case eFront: theViewFrame->onViewFront(); break;
261 case eLeft: theViewFrame->onViewLeft(); break;
262 case eTop: theViewFrame->onViewTop(); break;
263 case e3D: theViewFrame->onViewReset(); break;
265 theViewFrame->getRenderer()->ResetCameraClippingRange();
266 theViewFrame->onViewFitAll();
267 return aCameraOrient;
270 QAD_Desktop* VisuGUI::GetDesktop(){
271 return QAD_Application::getDesktop() ;
274 QAD_Study* VisuGUI::GetActiveStudy(){
275 return GetDesktop()->getActiveStudy() ;
278 vtkRenderer* VisuGUI::GetRenderer(){
279 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
280 return aViewFrame->getRenderer();
284 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
285 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
286 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
289 static void UpdateViewFrame() {
290 QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
292 for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
293 if (aStudyFrame->getTypeView() == VIEW_VTK) {
294 QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
295 VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
296 if (!aVtkViewFrame) continue;
297 VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
299 anInteractor->SetSelectionProp();
300 anInteractor->SetSelectionTolerance();
301 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
303 aStyle->setPreselectionProp();
310 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
311 return GetActiveStudy()->getStudyDocument();
314 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
315 return GetStudyDocument()->NewBuilder();
320 * Finds value by given key
323 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
324 VISU::Storable::TRestoringMap aMap;
325 if(!theSObject->_is_nil()){
326 SALOMEDS::GenericAttribute_var anAttr;
327 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
328 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
329 CORBA::String_var aString = aComment->Value();
330 QString strIn(aString.in());
331 VISU::Storable::StrToMap(strIn,aMap);
337 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
339 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
341 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
346 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
347 VISU::Storable::TRestoringMap* pMap = NULL)
349 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
350 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
351 if(aSel->IObjectCount() > 0){
352 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
353 if(pIO != NULL) *pIO = anIO;
354 if(anIO->hasEntry()){
355 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
356 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
357 if(!aSObject->_is_nil()){
358 SALOMEDS::GenericAttribute_var anAttr;
359 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
360 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
361 string aComm = aComment->Value();
362 QString strIn(aComm.c_str());
363 VISU::Storable::StrToMap(strIn,*pMap);
365 return VISU::SObjectToObject(aSObject);
369 return CORBA::Object::_nil();
373 int IsTrihedronDisplayed(){
374 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
375 return aVTKViewFrame->isTrihedronDisplayed();
380 void RepaintCurrentView(){
381 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
385 VisuGUI::VisuGUI( const QString& theName, QObject* theParent ):
386 SALOMEGUI( theName, theParent )
391 /* ==================================================================================== */
392 /* ==================================================================================== */
394 /* ==================================================================================== */
395 /* ==================================================================================== */
397 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
398 return theStudy->GetProperties()->IsLocked();
401 static int checkLock(const SALOMEDS::Study_var& theStudy) {
402 if (isStudyLocked(theStudy)) {
403 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
404 QObject::tr("WRN_WARNING"),
405 QObject::tr("WRN_STUDY_LOCKED"),
406 QObject::tr("BUT_OK") );
414 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
417 QString VisuInputDir = getVisuInputDir();
418 QString VisuOutputDir = getVisuOutputDir();
420 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
421 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
422 SALOMEDS::GenericAttribute_var anAttr;
423 SALOMEDS::AttributeName_var aName;
424 SALOMEDS::AttributeIOR_var anIOR;
426 switch (theCommandID){
427 /* ======================================================================================== */
428 /* Import Table from file */
429 /* ======================================================================================== */
432 if(checkLock(aStudy)) break;
433 visuGUI->ImportTablesFromFile();
437 /* ======================================================================================== */
438 /* Import Mesh from MED, DAT file */
439 /* ======================================================================================== */
443 visuGUI->CopyAndImportFile();
448 visuGUI->ImportFile();
452 /* ======================================================================================== */
453 /* Export results and mesh into a file format */
454 /* ======================================================================================== */
458 //visuGUI->ExportToFile();
462 /* ========================================================================== */
463 /* Visualization of Results : */
464 /* 4011 : Scalar Map */
465 /* 4012 : Deformed Shape */
467 /* 4014 : Iso-Surfaces */
468 /* 4015 : Cut Planes */
469 /* 4016 : Stream Lines */
470 /* ========================================================================== */
473 visuGUI->CreateScalarMap();
476 visuGUI->CreateDeformedShape();
479 visuGUI->CreateVectors();
482 visuGUI->CreateIsoSurfaces();
485 visuGUI->CreateCutPlanes();
488 visuGUI->CreateCutLines();
491 visuGUI->CreateStreamLines();
495 visuGUI->SelectionInfo();
498 /* ========================================================================================================================= */
499 /* Visualization - Wireframe */
500 /* ========================================================================================================================= */
506 /* ========================================================================================================================= */
507 /* Visualization - Surface */
508 /* ========================================================================================================================= */
514 /* ========================================================================================================================= */
515 /* Visualization - Points */
516 /* ========================================================================================================================= */
522 /* ========================================================================================================================= */
523 /* Visualization - Erase */
524 /* ========================================================================================================================= */
530 /* ========================================================================================================================= */
531 /* Visualization - Global */
532 /* ========================================================================================================================= */
536 /* ========================================================================================================================= */
537 /* Visualization - Partial */
538 /* ========================================================================================================================= */
544 //Show dialog that allows to select scale function and corresponding scale factor
545 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
546 FALSE, Qt::WDestructiveClose );
551 /* ============================ */
552 /* POP-UP OBJECTS BROWSER */
553 /* ============================ */
555 case 900 : // Rename object
559 // ---------------- For Popup in Viewer
565 case 803 : // Display only
566 case 903 : // Display only
567 visuGUI->DisplayOnlyPrs();
570 case 901 : // Display
571 visuGUI->DisplayPrs();
574 case 8041 : // Object representation : Wireframe
575 case 9041 : // Object representation : Wireframe
576 visuGUI->ChangeRepresentation(VISU::WIREFRAME);
579 case 8042 : // Object representation : Surface
580 case 9042 : // Object representation : Surface
581 visuGUI->ChangeRepresentation(VISU::SHADED);
584 case 8043 : // Object representation : Points
585 case 9043 : // Object representation : Points
586 visuGUI->ChangeRepresentation(VISU::POINT);
589 case 8044 : // Object representation : Shrink/Unshrink
590 case 9044 : // Object representation : Shrink/Unshrink
591 visuGUI->ChangeRepresentation(VISU::SHRINK);
594 case 8051 : // Change object color
595 case 9051 : // Change object color
596 visuGUI->ChageColor();
599 case 8052 : // Change object opacity
600 case 9052 : // Change object opacity
601 visuGUI->ChangeOpacity();
604 case 8053 : // Change object line width
605 case 9053 : // Change object line width
606 visuGUI->ChangeLines();
609 case 808 : // Sweep IsoSurfaces or Cutplanes
610 case 908 : // Sweep IsoSurfaces or Cutplanes
614 /* ======================================================================================== */
615 /* Preferences for Scalar Bar */
616 /* ======================================================================================== */
623 /* ======================================================================================== */
624 /* Preferences for Sweeping */
625 /* ======================================================================================== */
628 SetSweepingPreferences();
632 /* ======================================================================================== */
633 /* Preferences for Full loading */
634 /* ======================================================================================== */
639 bool check = !pp->isItemChecked(theCommandID);
640 pp->setItemChecked(theCommandID,check);
641 switch(theCommandID){
643 QAD_CONFIG->addSetting( "Visu:BuildResult", check );
646 QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
652 case 113: // Load MED using MED component
654 if (checkLock(GetStudyDocument())) break;
656 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
657 if (CORBA::is_nil(aMedComp)) return false;
658 SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
659 if (CORBA::is_nil(aMedGen)) return false;
661 QStringList filtersList ;
663 filtersList.append( tr("MED_MEN_IMPORT_MED") );
664 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
665 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
668 tr("MED_MEN_IMPORT"),
670 if (!aFileName.isEmpty()) {
671 QApplication::setOverrideCursor( Qt::waitCursor );
672 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
673 GetActiveStudy()->updateObjBrowser();
674 QApplication::restoreOverrideCursor();
680 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
681 tr ("MSG_NOT_IMPLEMENTED"),
682 tr ("VISU_BUT_OK") );
685 } catch (const std::bad_alloc& e ) {
686 INFOS("bad_alloc exception is caught "<<e.what());
687 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
688 tr("ERR_NO_MEMORY") + " " + tr(e.what()),
692 catch (std::exception& e){
694 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
697 }catch (const SALOME::SALOME_Exception& S_ex) {
698 INFOS("const SALOME::SALOME_Exception& S_ex");
699 QtCatchCorbaException(S_ex);
703 INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
704 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
705 tr("ERR_UNKNOWN_EXCEPTION"),
712 void VisuGUI::SelectionInfo() {
713 mySelectionDlg = new VisuGUI_SelectionDlg();
714 mySelectionDlg->show();
720 /* ********************************************************************************** */
721 /* Function ShowTrihedron */
722 /* ********************************************************************************** */
724 void VisuGUI::ShowTrihedron(bool ShowThd){
725 bool ThdIsVisible = true;
726 if( ShowThd && !ThdIsVisible)
727 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
728 if( !ShowThd && ThdIsVisible)
729 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
732 /* ********************************************************************************** */
734 /* Clear all tmp files used in VISU */
735 /* ********************************************************************************** */
738 if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
741 /* ********************************************************************************** */
742 /* Function ChangeViewer */
743 /* Change representation of all actors */
744 /* ********************************************************************************** */
746 void VisuGUI::ChangeViewer(int theType){
748 GetActiveStudy()->unHighlightAll();
749 if(vtkRenderer *aRen = GetRenderer()){
751 vtkActorCollection *anActColl = aRen->GetActors();
752 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
753 if(anActor->GetVisibility() > 0)
754 if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){
755 anVISUActor = anVISUActor->GetParent();
757 anVISUActor->SetRepresentation(theType);
759 anVISUActor->VisibilityOff();
762 RepaintCurrentView();
766 // -----------------------------------------------------------------------------------------
768 // -----------------------------------------------------------------------------------------
770 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
775 // ====================================================================================================================
777 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
782 // ===================================================================================================================
784 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
786 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
789 if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
795 if(MYDEBUG) MESSAGE("--> Key : Escape")
807 //=====================================================================================
808 // Slot-functions for presentations creation
809 //=====================================================================================
811 #define CREATEPRESENTATION(FunctionName) \
812 void FunctionName() { \
813 if (checkLock(GetStudyDocument())) return; \
814 SALOMEDS::SObject_var objVisu; \
815 if (!TestObjectBrowser(objVisu)) return; \
816 if(!FunctionName(objVisu)) return; \
817 GetActiveStudy()->updateObjBrowser(); \
818 GetDesktop()->putInfo("Ready"); \
819 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
821 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
822 vf->onViewFitAll(); \
827 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
828 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
829 CREATEPRESENTATION(VisuGUI::CreateVectors);
830 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
831 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
832 CREATEPRESENTATION(VisuGUI::CreateCutLines);
833 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
837 //=====================================================================================
838 // function : SetSettings()
840 //=====================================================================================
841 bool VisuGUI::SetSettings(QAD_Desktop* parent)
845 QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
846 QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
848 if(aValue.isEmpty()? 0 : aValue.toInt())
849 pp->setItemChecked(anId, true);
852 item = parent->menuBar()->findItem(anId,&pp);
853 aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
855 if(aValue.isEmpty()? 0 : aValue.toInt())
856 pp->setItemChecked(anId, true);
859 parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
866 //=====================================================================================
867 // function : DisplayPrs()
869 //=====================================================================================
870 void VisuGUI::DisplayPrs() {
871 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
872 Handle(SALOME_InteractiveObject) anIO;
873 CORBA::Object_var anObject = GetSelectedObj(&anIO);
874 if ( !CORBA::is_nil( anObject ) ) {
875 // is it Prs3d object ?
876 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
878 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
879 UpdateViewer(aPrsObject);
880 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
881 vf->getRenderer()->ResetCameraClippingRange();
883 vf->highlight(anIO, 1);
888 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
890 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
891 PlotCurve(aCurve, VISU::eDisplay );
895 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
897 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
898 PlotContainer(aContainer, VISU::eDisplay );
902 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
904 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
905 PlotTable(aTable, VISU::eDisplay );
911 //=====================================================================================
912 // function : DisplayOnlyPrs()
914 //=====================================================================================
915 void VisuGUI::DisplayOnlyPrs() {
916 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
917 CORBA::Object_var anObject = GetSelectedObj();
918 if ( !CORBA::is_nil( anObject ) ) {
919 // is it Prs3d object ?
920 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
921 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
922 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
923 UpdateViewer(aPrsObject, true);
924 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
926 vf->getRenderer()->ResetCameraClippingRange();
929 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
930 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
931 PlotCurve(aCurve, VISU::eDisplayOnly );
932 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
933 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
934 PlotContainer(aContainer, VISU::eDisplayOnly );
935 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
936 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
937 PlotTable(aTable, VISU::eDisplayOnly );
942 //=====================================================================================
943 // function : ErasePrs()
945 //=====================================================================================
946 static void ErasePrs(CORBA::Object_ptr theObject) {
947 if(MYDEBUG) MESSAGE("ErasePrs");
948 if ( !CORBA::is_nil( theObject ) ) {
949 VISU::Base_var aBase = VISU::Base::_narrow(theObject);
950 if ( CORBA::is_nil( aBase ) ) return;
951 VISU::VISUType aType = aBase->GetType();
954 if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
955 VisuGUI::PlotCurve(aCurve, VISU::eErase );
958 case VISU::TCONTAINER:{
959 if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
960 VisuGUI::PlotContainer(aContainer, VISU::eErase );
964 if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
965 VisuGUI::PlotTable(aTable, VISU::eErase );
969 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
970 VisuGUI::ErasePrs(aPrsObject);
971 if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame())
978 void VisuGUI::ErasePrs() {
979 ::ErasePrs(GetSelectedObj());
983 //=====================================================================================
984 // function : DisplayManyPrs()
986 //=====================================================================================
987 void VisuGUI::DisplayManyPrs()
989 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
990 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
991 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
992 for ( ; It.More(); It.Next() ) {
993 Handle(SALOME_InteractiveObject)& anIO = It.Value();
994 if ( anIO->hasEntry() ) {
995 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
996 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
997 VISU::Storable::TRestoringMap pMap;
998 if( !aSObject->_is_nil() ) {
999 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1000 if ( !CORBA::is_nil( aCORBAObject ) ) {
1001 // is it Prs3d object ?
1002 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1004 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
1005 UpdateViewer(aPrsObject);
1006 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1008 vf->getRenderer()->ResetCameraClippingRange();
1010 vf->highlight(anIO, 1);
1015 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1017 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
1018 PlotCurve(aCurve, VISU::eDisplay );
1021 // is it Container ?
1022 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1024 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
1025 PlotContainer(aContainer, VISU::eDisplay );
1029 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1031 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
1032 PlotTable(aTable, VISU::eDisplay );
1041 //=====================================================================================
1042 // function : DisplayOnlyManyPrs()
1044 //=====================================================================================
1045 void VisuGUI::DisplayOnlyManyPrs() {
1046 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
1047 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1048 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1049 bool aFirstElem = true;
1050 for ( ; It.More(); It.Next() ) {
1051 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1052 if ( anIO->hasEntry() ) {
1053 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1054 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1055 VISU::Storable::TRestoringMap pMap;
1056 if( !aSObject->_is_nil() ) {
1057 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1058 if ( !CORBA::is_nil( aCORBAObject ) ) {
1059 // is it Prs3d object ?
1060 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1062 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1063 UpdateViewer(aPrsObject, aFirstElem);
1064 if (aFirstElem) aFirstElem = false;
1065 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1067 vf->getRenderer()->ResetCameraClippingRange();
1069 vf->highlight(anIO, 1);
1074 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1076 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1078 PlotCurve(aCurve, VISU::eDisplayOnly );
1081 else PlotCurve(aCurve, VISU::eDisplay );
1084 // is it Container ?
1085 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1087 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1089 PlotContainer(aContainer, VISU::eDisplayOnly );
1092 else PlotContainer(aContainer, VISU::eDisplay );
1096 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1098 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1100 PlotTable(aTable, VISU::eDisplayOnly );
1103 else PlotTable(aTable, VISU::eDisplay );
1113 //=====================================================================================
1114 // function : EraseManyPrs()
1116 //=====================================================================================
1117 void VisuGUI::EraseManyPrs()
1119 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1120 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1121 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1122 SALOME_ListIteratorOfListIO It( LIO );
1123 for ( ; It.More(); It.Next() ) {
1124 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1125 if ( anIO->hasEntry() ) {
1126 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1127 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1128 VISU::Storable::TRestoringMap pMap;
1129 if( !aSObject->_is_nil() ) {
1130 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1131 if ( !CORBA::is_nil( aCORBAObject ) ) {
1132 // is it Prs3d object ?
1133 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1135 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1136 ErasePrs(aPrsObject);
1137 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1144 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1146 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1147 PlotCurve(aCurve, VISU::eErase );
1150 // is it Container ?
1151 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1153 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1154 PlotContainer(aContainer, VISU::eErase );
1158 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1160 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1161 PlotTable(aTable, VISU::eErase );
1170 //=====================================================================================
1171 // function : RecreateActor()
1173 //=====================================================================================
1174 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1175 QApplication::setOverrideCursor(Qt::waitCursor);
1178 //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
1179 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1180 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1181 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1182 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1183 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1184 thePrs->UpdateActor(anActor);
1186 }catch(std::runtime_error& ex){
1188 QApplication::restoreOverrideCursor();
1189 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1190 tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()),
1191 tr ("VISU_BUT_OK") );
1192 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1193 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1194 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1195 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
1196 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
1197 aViewFrame->RemoveActor(anActor);
1204 QApplication::restoreOverrideCursor();
1208 //=====================================================================================
1209 // function : EditPrs()
1211 //=====================================================================================
1212 #define EDITPRS(PrsName, DlgName) \
1214 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1216 DlgName* aDlg = new DlgName(); \
1217 aDlg->initFromPrsObject(aPrsObject); \
1218 if ( aDlg->exec() ) { \
1219 if(!(aDlg->storeToPrsObject(aPrsObject))){ \
1223 RecreateActor(aPrsObject); \
1224 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1225 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1226 vf->getRenderer()->ResetCameraClippingRange(); \
1235 void VisuGUI::EditPrs() {
1236 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1238 switch (aPrs3d->GetType()) {
1239 case VISU::TMESH: // Mesh 13
1242 case VISU::TSCALARMAP: // ScalarMap 18
1243 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1246 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1247 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1250 case VISU::TCUTPLANES: // Cut planes 42
1251 //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1253 VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
1255 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
1256 aDlg->initFromPrsObject(aPrsObject);
1258 myActiveDialogBox = aDlg;
1259 // if ( aDlg->exec() ) {
1260 // if(!(aDlg->storeToPrsObject(aPrsObject))){
1264 // RecreateActor(aPrsObject);
1265 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1266 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1267 // vf->getRenderer()->ResetCameraClippingRange();
1277 case VISU::TCUTLINES: // Cut planes 42
1278 //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1280 VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
1282 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false);
1283 aDlg->initFromPrsObject(aPrsObject);
1285 myActiveDialogBox = aDlg;
1286 // if ( aDlg->exec() ) {
1287 // aDlg->storeToPrsObject(aPrsObject);
1288 // RecreateActor(aPrsObject);
1289 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1290 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1291 // vf->getRenderer()->ResetCameraClippingRange();
1295 // // Remove old Table
1296 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1297 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
1298 // if(!aSObject->_is_nil()) {
1299 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1300 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1301 // for ( ;aIter->More(); aIter->Next()) {
1302 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1303 // if (!aTblObj->_is_nil()) {
1304 // SALOMEDS::GenericAttribute_var anAttr;
1305 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1306 // aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
1311 // if (aDlg->isGenerateTable()) {
1312 // GetVisuGen()->CreateTable(aSObject->GetID());
1313 // if (aDlg->isGenerateCurves()) {
1314 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1315 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1316 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1317 // for ( ;aIter->More(); aIter->Next()) {
1318 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1319 // if (!aTblObj->_is_nil()) {
1320 // SALOMEDS::GenericAttribute_var anAttr;
1321 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1322 // CreatePlot(aTblObj);
1329 // GetActiveStudy()->updateObjBrowser();
1337 case VISU::TISOSURFACE: // Iso surfaces
1338 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1340 case VISU::TVECTORS: // Vectors 64
1341 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1344 case VISU::TSTREAMLINES:
1345 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1351 Handle(SALOME_InteractiveObject) anIO;
1352 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1353 if ( !CORBA::is_nil( anObject ) )
1354 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1355 vf->highlight(anIO, 1);
1359 //=====================================================================================
1360 // function : CreateMesh()
1362 //=====================================================================================
1363 void VisuGUI::CreateMesh() {
1364 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1365 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1367 if (checkLock(GetStudyDocument())) return;
1369 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1370 aSObj = aSObj->GetFather();
1371 aSObj = aSObj->GetFather();
1372 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1373 if(CORBA::is_nil(anObject)) {
1374 aSObj = aSObj->GetFather();
1375 anObject = VISU::SObjectToObject(aSObj);
1377 VISU::Result_var aResult;
1378 if (!CORBA::is_nil(anObject)) {
1379 aResult = VISU::Result::_narrow(anObject);
1381 if(CORBA::is_nil(aResult)) {
1382 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1383 tr ("WRN_NO_AVAILABLE_DATA"),
1384 tr ("VISU_BUT_OK"));
1387 VISU::Storable::TRestoringMap aMap;
1388 SALOMEDS::GenericAttribute_var anAttr;
1389 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1390 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1391 string aComm = aComment->Value();
1392 QString strIn(aComm.c_str());
1393 VISU::Storable::StrToMap(strIn,aMap);
1396 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1397 if(!isExist) return;
1398 CORBA::Object_var aMesh;
1399 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1404 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
1405 if(aComment == "ENTITY"){
1406 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1407 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1408 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1409 }else if(aComment == "FAMILY"){
1410 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1411 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1412 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1413 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1414 }else if(aComment == "GROUP"){
1415 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1416 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1417 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1421 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1425 QApplication::restoreOverrideCursor();
1426 VISU::Mesh_i* pPresent = NULL;
1427 if(!CORBA::is_nil(aMesh))
1428 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1429 if (pPresent == NULL) {
1430 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1431 tr ("ERR_CANT_BUILD_PRESENTATION"),
1432 tr ("VISU_BUT_OK") );
1436 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1438 VISU_Actor *anActor = pPresent->CreateActor();
1443 vf->AddActor(anActor);
1447 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1450 //GetActiveStudy()->updateObjBrowser(); //not necessary
1451 GetDesktop()->putInfo("Ready");
1452 }catch(std::runtime_error& exc){
1454 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1455 tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
1456 tr ("VISU_BUT_OK") );
1461 //=====================================================================================
1462 // function : CreateManyMesh()
1464 //=====================================================================================
1465 void VisuGUI::CreateManyMesh(){
1466 if (checkLock(GetStudyDocument())) return;
1468 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1469 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1470 for ( ; It.More(); It.Next() ) {
1471 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1472 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1473 aSObj = aSObj->GetFather();
1474 aSObj = aSObj->GetFather();
1475 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1476 if(CORBA::is_nil(anObject)) {
1477 aSObj = aSObj->GetFather();
1478 anObject = VISU::SObjectToObject(aSObj);
1479 if(CORBA::is_nil(anObject)) return;
1481 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1482 if(CORBA::is_nil(aResult)) return;
1484 VISU::Storable::TRestoringMap aMap;
1485 SALOMEDS::GenericAttribute_var anAttr;
1486 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1487 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1488 string aComm = aComment->Value();
1489 QString strIn(aComm.c_str());
1490 VISU::Storable::StrToMap(strIn,aMap);
1493 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1494 if(!isExist) return;
1495 CORBA::Object_var aMesh;
1496 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1497 if(aComment == "ENTITY"){
1498 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1499 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1500 }else if(aComment == "FAMILY"){
1501 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1502 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1503 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1504 }else if(aComment == "GROUP"){
1505 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1506 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1508 QApplication::restoreOverrideCursor();
1509 if(CORBA::is_nil(aMesh)) return;
1511 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1513 VISU_Actor *anActor = pPresent->CreateActor();
1514 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1515 vf->AddActor(anActor);
1518 GetDesktop()->putInfo("Ready");
1519 }catch(std::runtime_error& exc){
1525 //=====================================================================================
1526 // function : ChangeRepresentation()
1528 //=====================================================================================
1530 static void ShrinkMesh(VISU_Actor *theActor){
1531 if(theActor->IsShrunk())
1532 theActor->UnShrink();
1534 theActor->SetShrink();
1537 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1538 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1539 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1542 ShrinkMesh(anActor);
1545 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1546 aMesh->SetPresentationType(theType);
1547 RecreateActor(aMesh);
1549 anActor->SetRepresentation(theType);
1551 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1557 void VisuGUI::MakeSurfaceframe() {
1558 ChangeRepresentation(VISU::SURFACEFRAME);
1561 void VisuGUI::MakeInsideframe() {
1562 ChangeRepresentation(VISU::INSIDEFRAME);
1565 void VisuGUI::MakeWireframe() {
1566 ChangeRepresentation(VISU::WIREFRAME);
1569 void VisuGUI::MakeSurface() {
1570 ChangeRepresentation(VISU::SHADED);
1573 void VisuGUI::MakePoints() {
1574 ChangeRepresentation(VISU::POINT);
1577 void VisuGUI::MakeShrink() {
1578 ChangeRepresentation(VISU::SHRINK);
1583 //=====================================================================================
1584 // functions : Change Propertise
1586 //=====================================================================================
1587 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1588 CORBA::Object_var anObject = GetSelectedObj(theIO);
1589 if(CORBA::is_nil(anObject)) return NULL;
1590 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1591 if(!aServant.in()) return NULL;
1592 return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1595 void VisuGUI::ChageColor() {
1596 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1597 if(!aPrsObject) return;
1599 VISU_Actor* anActor = GetActor(aPrsObject);
1600 if (!anActor) return;
1604 void VisuGUI::ChangeWireframeColor() {
1605 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1606 if(!aPrsObject) return;
1608 VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1609 if (!anActor) return;
1610 NewWireframeColor(anActor);
1614 void VisuGUI::ChangeOpacity() {
1615 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1616 if(!aPrsObject) return;
1618 VISU_Actor* anActor = GetActor(aPrsObject);
1619 if (!anActor) return;
1620 NewOpacity(anActor);
1624 void VisuGUI::ChangeLines() {
1625 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1626 if(!aPrsObject) return;
1628 VISU_Actor* anActor = GetActor(aPrsObject);
1629 if (!anActor) return;
1630 NewLinewidth(anActor);
1632 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1634 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1635 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1636 if ( theDisplaying == VISU::eDisplayOnly )
1638 QList<Plot2d_Curve> clist;
1639 aPlot->getCurves( clist );
1640 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1641 if ( !TableSO->_is_nil() ) {
1642 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1643 for ( ; Iter->More(); Iter->Next() ) {
1644 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1645 if( !CORBA::is_nil( childObject ) ) {
1646 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1647 if( !CORBA::is_nil( aCurve ) ) {
1648 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1649 Plot2d_Curve* plotCurve = 0;
1650 for ( int i = 0; i < clist.count(); i++ ) {
1651 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1652 plotCurve = clist.at( i );
1656 if ( theDisplaying == VISU::eErase ) {
1658 aPlot->eraseCurve( plotCurve, false );
1659 clist.remove( plotCurve );
1662 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1664 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1665 //plotCurve->setVerTitle( theCurve->GetVerTitle().c_str() );
1666 plotCurve->setVerTitle( theCurve->GetName() );
1667 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1668 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1669 /* - DATA NOT UPDATED */
1672 int nbPoints = theCurve->GetData( xList, yList );
1673 if ( nbPoints > 0 && xList && yList ) {
1674 plotCurve->setData( xList, yList, nbPoints );
1676 if ( !theCurve->IsAuto() ) {
1677 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1678 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1679 SALOMEDS::Color color = theCurve->GetColor();
1680 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1682 plotCurve->setAutoAssign( theCurve->IsAuto() );
1683 aPlot->displayCurve( plotCurve, false );
1686 Plot2d_Curve* crv = theCurve->CreatePresentation();
1688 aPlot->displayCurve( crv, false );
1689 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1690 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1691 SALOMEDS::Color newColor;
1692 newColor.R = crv->getColor().red()/255.;
1693 newColor.G = crv->getColor().green()/255.;
1694 newColor.B = crv->getColor().blue()/255.;
1695 theCurve->SetColor( newColor );
1696 crv->setAutoAssign( theCurve->IsAuto() );
1707 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1709 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1710 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1711 // if ( theDisplaying == VISU::eDisplayOnly )
1712 // aPlot->EraseAll();
1713 QList<Plot2d_Curve> clist;
1714 aPlot->getCurves( clist );
1715 Plot2d_Curve* plotCurve = 0;
1716 for ( int i = 0; i < clist.count(); i++ ) {
1717 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1718 plotCurve = clist.at( i );
1720 else if ( theDisplaying == VISU::eDisplayOnly ) {
1721 aPlot->eraseCurve( clist.at( i ) );
1724 if ( theDisplaying == VISU::eErase ) {
1726 aPlot->eraseCurve( plotCurve, false );
1728 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1730 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1731 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1732 plotCurve->setVerTitle( theCurve->GetName() );
1733 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1734 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1737 int nbPoints = theCurve->GetData( xList, yList );
1738 if ( nbPoints > 0 && xList && yList ) {
1739 plotCurve->setData( xList, yList, nbPoints );
1741 if ( !theCurve->IsAuto() ) {
1742 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1743 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1744 SALOMEDS::Color color = theCurve->GetColor();
1745 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1747 plotCurve->setAutoAssign( theCurve->IsAuto() );
1748 aPlot->displayCurve( plotCurve, false );
1751 Plot2d_Curve* crv = theCurve->CreatePresentation();
1753 aPlot->displayCurve( crv, false );
1754 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1755 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1756 SALOMEDS::Color newColor;
1757 newColor.R = crv->getColor().red()/255.;
1758 newColor.G = crv->getColor().green()/255.;
1759 newColor.B = crv->getColor().blue()/255.;
1760 theCurve->SetColor( newColor );
1761 crv->setAutoAssign( theCurve->IsAuto() );
1768 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1770 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1771 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1772 if ( theDisplaying == VISU::eDisplayOnly )
1774 QList<Plot2d_Curve> clist;
1775 aPlot->getCurves( clist );
1776 if ( container->GetNbCurves() > 0 ) {
1777 int nbCurves = container->GetNbCurves();
1778 for ( int k = 1; k <= nbCurves; k++ ) {
1779 VISU::Curve_i* theCurve = container->GetCurve( k );
1780 if ( theCurve && theCurve->IsValid() ) {
1781 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) );
1782 // for ( int i = 0; i < clist.count(); i++ ) {
1783 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1784 // plotCurve = clist.at( i );
1788 if ( theDisplaying == VISU::eErase ) {
1790 aPlot->eraseCurve( plotCurve, false );
1791 clist.remove( plotCurve );
1794 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1796 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1797 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1798 plotCurve->setVerTitle( theCurve->GetName() );
1799 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1800 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1803 int nbPoints = theCurve->GetData( xList, yList );
1804 if ( nbPoints > 0 && xList && yList ) {
1805 plotCurve->setData( xList, yList, nbPoints );
1807 if ( !theCurve->IsAuto() ) {
1808 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1809 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1810 SALOMEDS::Color color = theCurve->GetColor();
1811 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1813 plotCurve->setAutoAssign( theCurve->IsAuto() );
1814 aPlot->displayCurve( plotCurve, false );
1817 Plot2d_Curve* crv = theCurve->CreatePresentation();
1819 aPlot->displayCurve( crv, false );
1820 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1821 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1822 SALOMEDS::Color newColor;
1823 newColor.R = crv->getColor().red()/255.;
1824 newColor.G = crv->getColor().green()/255.;
1825 newColor.B = crv->getColor().blue()/255.;
1826 theCurve->SetColor( newColor );
1827 crv->setAutoAssign( theCurve->IsAuto() );
1839 Slot : opens Table view : for Table object or SObject with table attribute selected
1841 void VisuGUI::ShowTable() {
1842 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1843 if( Sel->IObjectCount() !=1 )
1845 Handle(SALOME_InteractiveObject) anIO;
1846 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1847 SALOMEDS::SObject_var SO;
1848 if ( !CORBA::is_nil( anObject ) ) {
1849 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1850 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1851 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1852 if( !CORBA::is_nil( aTable ) ) {
1853 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1855 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1860 // possibly this is Table SObject
1861 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1864 if(!IsSObjectTable(SO))
1867 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1870 //SAL2670 Orientation of show tables
1871 SALOMEGUI_TableDlg::ttAuto,
1878 Slot : opens Table view : for Table object or SObject with table attribute selected
1880 void VisuGUI::CreateTable() {
1881 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1882 if( aSel->IObjectCount() !=1 )
1885 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1886 if (anIO->hasEntry()){
1887 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1888 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1889 if(!aSObject->_is_nil()) {
1890 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1891 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1892 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1893 GetVisuGen()->CreateTable(aSObject->GetID());
1894 GetActiveStudy()->updateObjBrowser();
1902 Slot : deletes SObject with all subobjects
1904 void VisuGUI::DeleteObject() {
1905 SALOMEDS::Study_var aStudy = GetStudyDocument();
1906 if (checkLock(aStudy)) return;
1908 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1909 if( aSel->IObjectCount() !=1 )
1911 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1912 if (anIO->hasEntry()){
1913 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1914 if(!aSObject->_is_nil()){
1915 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1916 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1917 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1918 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1919 ::ErasePrs(aChildObj);
1921 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
1922 // There is a transaction
1923 aStudyBuilder->NewCommand();
1924 CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1925 if(!CORBA::is_nil(anObj)){
1926 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1927 if(!CORBA::is_nil(aBase)){
1928 VISU::VISUType aType = aBase->GetType();
1932 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1933 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1934 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1935 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1936 if(CORBA::is_nil(aChildObj)) continue;
1937 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1938 if(CORBA::is_nil(aPrs3d)) continue;
1939 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1940 DeletePresentation(pPrs3d);
1946 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1947 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1948 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1949 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1950 if(CORBA::is_nil(aChildObj)) continue;
1951 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( aChildObj );
1952 if(CORBA::is_nil(aCurve)) continue;
1953 VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1954 DeletePresentation(pCurve);
1961 aStudyBuilder->RemoveObjectWithChildren(aSObject);
1962 aStudyBuilder->CommitCommand();
1963 GetActiveStudy()->unHighlightAll();
1964 GetActiveStudy()->updateObjBrowser(true);
1971 Slot : deletes empty container
1973 void VisuGUI::CreatePlot2dView() {
1974 if (checkLock(GetStudyDocument())) return;
1975 GetVisuGen()->CreateContainer();
1976 GetActiveStudy()->updateObjBrowser( true );
1982 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1984 void VisuGUI::PlotData() {
1985 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1986 if( Sel->IObjectCount() !=1 )
1988 CORBA::Object_var anObject = GetSelectedObj();
1989 SALOMEDS::SObject_var SO;
1990 if ( !CORBA::is_nil( anObject ) ) {
1991 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1992 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1993 // Table (VISU object) is selected
1994 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1995 if( !CORBA::is_nil( aTbl ) ) {
1996 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1998 SALOMEDS::GenericAttribute_var anAttr;
1999 SALOMEDS::AttributeName_var aName;
2001 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
2002 if ( IsSObjectTable(SO) ) {
2003 // get name of SObject
2004 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2005 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2006 SOName = aName->Value();
2008 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2009 if ( dlg->exec() == QDialog::Accepted ) {
2010 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2011 // if study is not locked - create new container, create curves
2012 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2014 QValueList<int> verIndices;
2015 dlg->getCurvesSource( horIndex, verIndices );
2016 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2017 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2018 if( !CORBA::is_nil( aContainer ) ) {
2019 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2021 for ( int i = 0; i < verIndices.count(); i++ ) {
2022 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
2023 if( !CORBA::is_nil( aNewCurve ) ) {
2024 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2027 int marker, line, lineWidth;
2029 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2030 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2031 pCrv->SetColor( c );
2032 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2033 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2035 pContainer->AddCurve( pCrv->_this() );
2039 GetActiveStudy()->updateObjBrowser( true );
2040 PlotContainer( pContainer, VISU::eDisplay );
2046 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2047 Plot2d_CurveContainer container;
2048 dlg->getCurves( container );
2049 if ( !container.isEmpty() ) {
2050 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2051 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2052 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2053 getRightFrame()->getViewFrame()))->setTitle( SOName );
2064 // possibly this is Table SObject
2065 SALOMEDS::GenericAttribute_var anAttr;
2066 SALOMEDS::AttributeName_var aName;
2069 // check if Table SObject is selected
2070 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2071 if ( IsSObjectTable(SO) ) {
2072 // get name of SObject
2073 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2074 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2075 SOName = aName->Value();
2077 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2078 if ( dlg->exec() == QDialog::Accepted ) {
2079 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2080 // if study is not locked - create new table and container objects, create curves
2081 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2083 QValueList<int> verIndices;
2084 dlg->getCurvesSource( horIndex, verIndices );
2085 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2086 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
2087 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2088 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2089 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2090 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2092 if ( pContainer && pTable ) {
2093 for ( int i = 0; i < verIndices.count(); i++ ) {
2094 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2095 if( !CORBA::is_nil( aNewCurve ) ) {
2096 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2099 int marker, line, lineWidth;
2101 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2102 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2103 pCrv->SetColor( c );
2104 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2105 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2107 pContainer->AddCurve( pCrv->_this() );
2111 GetActiveStudy()->updateObjBrowser( true );
2112 PlotContainer( pContainer, VISU::eDisplay );
2117 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2118 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2119 Plot2d_CurveContainer container;
2120 dlg->getCurves( container );
2121 if ( !container.isEmpty() ) {
2122 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2123 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2124 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2125 getRightFrame()->getViewFrame()))->setTitle( SOName );
2136 void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
2137 SALOMEDS::GenericAttribute_var anAttr;
2138 SALOMEDS::AttributeName_var aName;
2140 if ( IsSObjectTable(theTableSO) ) {
2141 CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
2142 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2143 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2144 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
2145 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
2147 if ( pContainer && pTable ) {
2148 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
2149 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
2150 if( !CORBA::is_nil( aNewCurve ) ) {
2151 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
2153 pContainer->AddCurve( pCrv->_this() );
2157 GetActiveStudy()->updateObjBrowser( true );
2158 PlotContainer( pContainer, VISU::eDisplay );
2166 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2168 void VisuGUI::CurveProperties() {
2169 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2170 if( Sel->IObjectCount() !=1 )
2172 CORBA::Object_var anObject = GetSelectedObj();
2173 SALOMEDS::SObject_var SO;
2174 if (CORBA::is_nil( anObject )) return;
2176 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2177 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2179 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2180 if( !CORBA::is_nil( aCurve ) ) {
2181 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2182 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2183 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
2184 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2185 dlg->setMarker( (int)curve->GetMarker() );
2186 SALOMEDS::Color color = curve->GetColor();
2187 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2188 if( dlg->exec() == QDialog::Accepted ) {
2189 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2190 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2191 SALOMEDS::Color newColor;
2192 newColor.R = dlg->getColor().red()/255.;
2193 newColor.G = dlg->getColor().green()/255.;
2194 newColor.B = dlg->getColor().blue()/255.;
2195 curve->SetColor( newColor );
2196 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2197 if ( sfList.count() > 0 ) {
2198 QListIterator<QAD_StudyFrame> it( sfList );
2199 for ( ; it.current(); ++it ) {
2200 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2201 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2202 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2205 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2207 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2208 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2209 plotCurve->setColor( dlg->getColor() );
2210 aPlot->updateCurve( plotCurve, true );
2223 Slot : Clears container contents : for Container object selected
2225 void VisuGUI::ClearContainer() {
2226 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2227 if( Sel->IObjectCount() !=1 )
2230 CORBA::Object_var anObject = GetSelectedObj();
2231 SALOMEDS::SObject_var SO;
2232 if (CORBA::is_nil( anObject )) return;
2234 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2235 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2237 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2238 if( !CORBA::is_nil( aCnt ) ) {
2239 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2240 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2242 GetActiveStudy()->updateObjBrowser();
2249 Slot : Edit container contents : for Container object selected
2251 void VisuGUI::EditContainer() {
2252 CORBA::Object_var anObject = GetSelectedObj();
2253 if(CORBA::is_nil(anObject)) return;
2254 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
2255 if(!aServant.in()) return;
2256 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
2257 if(!aContainer) return;
2259 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
2260 aDlg->initFromPrsObject(aContainer);
2262 aDlg->storeToPrsObject(aContainer);
2263 GetActiveStudy()->updateObjBrowser( true );
2269 void VisuGUI::DeletePrs() {
2270 SALOMEDS::Study_var aStudy = GetStudyDocument();
2271 if (checkLock(aStudy)) return;
2273 // There is a transaction
2274 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
2275 aStudyBuilder->NewCommand();
2277 CORBA::Object_var anObject = GetSelectedObj();
2278 if ( !CORBA::is_nil( anObject ) ) {
2279 // is it Prs3d object ?
2280 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2282 DeletePresentation(aPrsObject);
2283 // is it Curve object ?
2284 VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
2286 DeletePresentation(aCurveObject);
2288 aStudyBuilder->CommitCommand();
2292 void VisuGUI::SaveViewParams()
2294 if (checkLock(GetStudyDocument())) return;
2295 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2296 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2297 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2299 if ( aSel->IObjectCount() == 0 ) {
2300 VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
2302 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2303 VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
2305 GetActiveStudy()->updateObjBrowser( true );
2309 void VisuGUI::RestoreViewParams()
2311 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2312 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2313 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2315 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2316 VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
2320 //=====================================================================================
2321 // function : DeleteViewParams()
2323 //=====================================================================================
2324 void VisuGUI::DeleteViewParams() {
2326 VISU::Storable::TRestoringMap aMap;
2327 Handle(SALOME_InteractiveObject) anIO;
2328 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2329 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2330 if(isExist && aType == VISU::TVIEW3D){
2331 SALOMEDS::Study_var aStudy = GetStudyDocument();
2332 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2333 aStudy->NewBuilder()->RemoveObject(aSObject);
2335 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2336 aSel->RemoveIObject(anIO, 0);
2338 GetActiveStudy()->updateObjBrowser( true );
2343 //=====================================================================================
2344 // function : Sweep()
2346 //=====================================================================================
2347 void VisuGUI::Sweep() {
2348 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2349 if (!aPrsObject) return;
2351 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2355 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2356 if ( !aTempoStr.isEmpty() )
2357 aTemp = int(1.E6*(aTempoStr.toFloat()));
2360 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2361 if ( !aCyclesStr.isEmpty() )
2362 aCycles = aCyclesStr.toInt();
2365 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2366 if ( !aStepsStr.isEmpty() )
2367 aSteps = aStepsStr.toInt();
2369 VISU_Actor* aActor = GetActor(aPrsObject);
2370 if (!aActor) return;
2372 if (!aActor->GetVisibility()) {
2373 aActor->VisibilityOn();
2376 QApplication::setOverrideCursor( Qt::waitCursor );
2378 for (int j=0 ; j<aCycles; j++) {
2379 for (int i=0 ; i<=aSteps; i++) {
2380 float aPercents = float(i)/aSteps;
2381 aPrsObject->SetMapScale(aPercents);
2382 aPrsObject->UpdateActor(aActor);
2383 vf->getRW()->getRenderWindow()->Render();
2387 }catch(std::exception& exc){
2388 INFOS("Follow exception was occured :\n"<<exc.what());
2390 INFOS("Unknown exception was occured!");
2392 QApplication::restoreOverrideCursor();
2397 void VisuGUI::TimeAnimation() {
2398 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2399 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2401 bool isDefined = false;
2403 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2404 for (; It.More(); It.Next()) {
2405 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2406 if (aSObject->_is_nil()) continue;
2407 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2408 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2412 aAnimationDlg->addField(aSObject);
2414 } else if (aNbTimes == aNumber) {
2415 aAnimationDlg->addField(aSObject);
2420 if (isDefined) aAnimationDlg->show();
2421 else delete aAnimationDlg;
2425 void VisuGUI::ImportMedField() {
2426 if (checkLock(GetStudyDocument())) return;
2427 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2428 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2429 QApplication::setOverrideCursor( Qt::waitCursor );
2430 for(;It.More();It.Next()) {
2431 Handle(SALOME_InteractiveObject) anIO = It.Value();
2432 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2433 if(!aSObject->_is_nil()){
2434 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2435 if(!CORBA::is_nil(anObject)){
2436 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2437 if(!CORBA::is_nil(aMED.in()))
2438 GetVisuGen()->ImportMed( aSObject );
2439 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2440 if(!CORBA::is_nil(aField.in()))
2441 GetVisuGen()->ImportMedField( aField );
2443 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2444 SALOMEDS::GenericAttribute_var anAttr;
2445 aSFather->FindAttribute(anAttr, "AttributeName");
2446 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2447 CORBA::String_var aValue = aName->Value();
2448 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2449 GetVisuGen()->ImportMed(aSObject);
2450 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2451 // VisuGUI::myComponent->ImportMed(aSObject);
2455 GetActiveStudy()->updateObjBrowser( true );
2456 QApplication::restoreOverrideCursor();
2459 //=====================================================================================
2460 // functions : Rename()
2462 //=====================================================================================
2463 void VisuGUI::Rename() {
2464 if (checkLock(GetStudyDocument())) return;
2465 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2466 if ( Sel->IObjectCount() != 1 )
2468 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2469 if( aSObj->_is_nil() ) return;
2471 VISU::Curve_i* curve = 0;
2472 CORBA::Object_var anObject = GetSelectedObj();
2473 if ( !CORBA::is_nil( anObject )) {
2474 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2475 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2477 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2478 if( !CORBA::is_nil( aCurve ) ) {
2479 curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2484 //TEST DU PARENT == VISU
2485 SALOMEDS::GenericAttribute_var anAttr;
2486 SALOMEDS::AttributeName_var aName;
2487 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2488 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2489 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2490 if ( !Name.isEmpty() ) {
2491 QApplication::setOverrideCursor( Qt::waitCursor );
2493 curve->SetName( Name.latin1() );
2494 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2495 QApplication::restoreOverrideCursor();
2497 //int TypeMode; bool InViewer;
2498 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2499 //ActorTmp->setName((Standard_CString)Name.latin1());
2504 //=====================================================================================
2505 // functions : RenameTable()
2507 //=====================================================================================
2508 void VisuGUI::RenameTable() {
2509 if (checkLock(GetStudyDocument())) return;
2510 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2511 if ( Sel->IObjectCount() != 1 )
2513 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2514 if( aSObj->_is_nil() ) return;
2516 VISU::Table_i* table = 0;
2517 CORBA::Object_var anObject = GetSelectedObj();
2518 if ( !CORBA::is_nil( anObject )) {
2519 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2520 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2522 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2523 if( !CORBA::is_nil( aTable ) ) {
2524 table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2529 //TEST DU PARENT == VISU
2530 SALOMEDS::GenericAttribute_var anAttr;
2531 SALOMEDS::AttributeName_var aName;
2532 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2533 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2534 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2535 if ( !Name.isEmpty() ) {
2536 QApplication::setOverrideCursor( Qt::waitCursor );
2538 table->SetName( Name.latin1() );
2539 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2540 QApplication::restoreOverrideCursor();
2542 //int TypeMode; bool InViewer;
2543 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2544 //ActorTmp->setName((Standard_CString)Name.latin1());
2551 //=====================================================================================
2552 // functions : RenameContainer()
2554 //=====================================================================================
2555 void VisuGUI::RenameContainer() {
2556 if (checkLock(GetStudyDocument())) return;
2557 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2558 if ( Sel->IObjectCount() != 1 )
2560 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2561 if( aSObj->_is_nil() ) return;
2563 VISU::Container_i* container = 0;
2564 CORBA::Object_var anObject = GetSelectedObj();
2565 if ( !CORBA::is_nil( anObject )) {
2566 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2567 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2569 CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2570 if( !CORBA::is_nil( aContainer ) ) {
2571 container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2576 //TEST DU PARENT == VISU
2577 SALOMEDS::GenericAttribute_var anAttr;
2578 SALOMEDS::AttributeName_var aName;
2579 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2580 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2581 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2582 if ( !Name.isEmpty() ) {
2583 QApplication::setOverrideCursor( Qt::waitCursor );
2585 container->SetName( Name.latin1() );
2586 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2587 QApplication::restoreOverrideCursor();
2589 //int TypeMode; bool InViewer;
2590 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2591 //ActorTmp->setName((Standard_CString)Name.latin1());
2598 //=====================================================================================
2599 // function : CopyPresentation()
2601 //=====================================================================================
2602 void VisuGUI::CopyPresentation(){
2603 if (checkLock(GetStudyDocument())) return;
2604 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2605 if (!aPrsObject) return;
2606 switch (aPrsObject->GetType()) {
2609 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2610 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2611 aSameMesh->SameAs(aMeshPrs);
2612 UpdateViewer(aSameMesh);
2615 case VISU::TSCALARMAP:
2617 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2618 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2619 aSameScalar->SameAs(aScalarPrs);
2620 UpdateViewer(aSameScalar);
2623 case VISU::TDEFORMEDSHAPE:
2625 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2626 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2627 aSameDeformed->SameAs(aDefPrs);
2628 UpdateViewer(aSameDeformed);
2631 case VISU::TCUTPLANES:
2633 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2634 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2635 aSameCut->SameAs(aCutPrs);
2636 UpdateViewer(aSameCut);
2639 case VISU::TCUTLINES:
2641 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2642 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2643 aSameCut->SameAs(aCutPrs);
2644 UpdateViewer(aSameCut);
2647 case VISU::TISOSURFACE:
2649 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2650 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2651 aSameIso->SameAs(aIsoPrs);
2652 UpdateViewer(aSameIso);
2655 case VISU::TSTREAMLINES:
2657 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2658 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2659 aSameLines->SameAs(aLinesPrs);
2660 UpdateViewer(aSameLines);
2663 case VISU::TVECTORS:
2665 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2666 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2667 aSameVectors->SameAs(aVectorsPrs);
2668 UpdateViewer(aSameVectors);
2672 GetActiveStudy()->updateObjBrowser();
2677 //=====================================================================================
2678 // function : DefinePopup()
2680 //=====================================================================================
2681 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2688 //=====================================================================================
2689 // function : checkHomoSelection()
2691 //=====================================================================================
2692 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2693 int VisuGUI::checkHomoSelection()
2695 int selMode = homoNone;
2696 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2697 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2698 for ( ; It.More(); It.Next() ) {
2699 int selNext = homoOther;
2700 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2701 if ( anIO->hasEntry() ) {
2702 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2703 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2704 VISU::Storable::TRestoringMap pMap;
2705 if( !aSObject->_is_nil() ) {
2706 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2707 if ( !CORBA::is_nil( aCORBAObject ) ) {
2708 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2709 if ( !CORBA::is_nil( aVisuObj ) ) {
2710 VISU::VISUType aType = aVisuObj->GetType();
2714 case VISU::TCONTAINER:
2715 selNext = homoCurves; break;
2717 case VISU::TSCALARMAP:
2718 case VISU::TISOSURFACE:
2719 case VISU::TDEFORMEDSHAPE:
2720 case VISU::TCUTPLANES:
2721 case VISU::TCUTLINES:
2722 case VISU::TVECTORS:
2723 case VISU::TSTREAMLINES:
2724 selNext = homoPresentations; break;
2726 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2727 selNext = homoAnimatable; break;
2729 selNext = homoOther; break;
2731 selNext = homoOther;
2736 SALOMEDS::GenericAttribute_var anAttr;
2737 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2738 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2739 string aComm = aComment->Value();
2740 QString strIn( aComm.c_str() );
2741 VISU::Storable::StrToMap( strIn, pMap );
2743 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2749 selNext = homoPresentable; break;
2751 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2752 selNext = homoAnimatable; break;
2754 selNext = homoOther; break;
2756 selNext = homoOther;
2763 if ( selMode == homoNone )
2766 if ( selMode != selNext )
2773 //=====================================================================================
2774 // function : GetNbChildren() [ static ]
2775 // purpose : get number of children
2776 //=====================================================================================
2777 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2779 if ( SO->_is_nil() )
2782 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2783 for ( ; Iter->More(); Iter->Next() ) {
2784 SALOMEDS::SObject_var refSO;
2785 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2791 //=====================================================================================
2792 // function : CustomPopup()
2794 //=====================================================================================
2795 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2796 const QString & theParent, const QString & theObject)
2798 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2800 bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
2802 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2803 SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2804 QString aParentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
2805 int nbSel = aSelection->IObjectCount();
2810 if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
2811 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2815 int selMode = checkHomoSelection();
2816 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2817 if ( selMode == homoCurves ) {
2818 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2819 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2820 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2821 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2824 else if ( selMode == homoPresentations ) {
2826 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2827 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2830 else if ( selMode == homoPresentable ) {
2831 if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2833 else if ( selMode == homoAnimatable ) {
2834 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2838 VISU::Storable::TRestoringMap aMap;
2839 Handle(SALOME_InteractiveObject) anIO;
2840 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2841 if (!CORBA::is_nil(anObject)) {
2842 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2843 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2844 if (!CORBA::is_nil(aVisuObj)) {
2845 VISU::VISUType aType = aVisuObj->GetType();
2846 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2848 case VISU::TVISUGEN:
2849 thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
2850 thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
2851 thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
2855 if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
2859 if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2860 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2861 if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2862 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
2863 thePopup->insertSeparator();
2864 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2865 if ( GetNbChildren( aSObject, false ) > 0 ) {
2866 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2867 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2868 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2871 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2876 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2877 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2879 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2880 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2881 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2883 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2884 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2886 if ( !aIsLocked ) thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2889 case VISU::TCONTAINER:
2890 // if( !CORBA::is_nil( anObject ) ) {
2891 // CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2892 // if( !CORBA::is_nil( aCnt ) ) {
2893 // VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2894 // if ( container ) {
2895 // if ( !aIsLocked ) {
2896 // thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2897 // thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2898 // if (container->GetNbCurves() > 0)
2899 // thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2901 // if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2902 // thePopup->insertSeparator();
2903 // thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2904 // thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2905 // thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2911 thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2912 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2913 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2915 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2916 thePopup->insertSeparator();
2917 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2918 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2919 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2921 if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2924 default: // Presentation
2926 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2929 // Add Presentation menu
2930 if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2931 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2932 int aRepresent = anVISUActor->GetRepresentation();
2935 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2936 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2937 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2938 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2939 if (aType == VISU::TMESH)
2940 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2942 case VISU::WIREFRAME :
2943 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2944 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2945 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2946 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2947 if (aType == VISU::TMESH)
2948 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2951 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2952 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2953 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2954 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2955 if (aType == VISU::TMESH)
2956 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2958 case VISU::INSIDEFRAME :
2959 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2960 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2961 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2962 if (aType == VISU::TMESH)
2963 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2965 case VISU::SURFACEFRAME :
2966 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2967 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2968 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2969 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2972 if(anVISUActor->IsShrunkable())
2973 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2974 if (anVISUActor->IsShrunk())
2975 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2977 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2979 thePopup->insertItem("Representation", aPresMenu);
2982 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2983 if(aType == VISU::TMESH){
2984 if(aRepresent == VISU::SURFACEFRAME){
2985 aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2986 aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2988 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2989 }else if(aType == VISU::TDEFORMEDSHAPE)
2990 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2992 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2993 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2994 if (aType != VISU::TVECTORS){
2995 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2996 thePopup->insertItem("Properties", aPropMenu);
2998 thePopup->insertSeparator();
3001 if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
3002 if (aType != VISU::TMESH) {
3003 //if (aType != VISU::TSCALARMAP)
3004 if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
3006 if (aType == VISU::TCUTLINES) {
3007 // Check: Does it has living children (tables)
3008 SALOMEDS::ChildIterator_var aIter =
3009 GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
3010 bool isPresent = false;
3011 for ( ;aIter->More(); aIter->Next()) {
3012 SALOMEDS::SObject_var aTblObj = aIter->Value();
3013 isPresent = !aTblObj->_is_nil();
3015 SALOMEDS::GenericAttribute_var anAttr;
3016 isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
3017 if (isPresent) break; // We have at least a one child
3020 if ((!isPresent) && (!aIsLocked) )
3021 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
3023 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
3027 if ( theParent == "Viewer" &&
3028 ( aType == VISU::TMESH ||
3029 aType == VISU::TSCALARMAP ||
3030 aType == VISU::TDEFORMEDSHAPE ) ) {
3031 thePopup->insertSeparator();
3032 thePopup->insertItem("Selection info...", visuGUI, SLOT(SelectionInfo()));
3034 thePopup->insertSeparator();
3036 if (visuGUI->IsDisplayed(aPrsObject) ){
3037 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
3040 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
3042 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
3044 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
3045 if ((aType != VISU::TMESH) && (!aIsLocked)) {
3046 thePopup->insertSeparator();
3047 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
3056 // possibly this is the MED field/mesh and support objects
3057 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
3058 if(!CORBA::is_nil(aMED))
3059 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
3060 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
3061 if(!CORBA::is_nil(aField))
3062 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
3063 if ( aParentComponent != parent->getActiveComponent() ) {
3064 //insert pre-defined Display/Erase items
3065 if ( thePopup->count() > 0 ) {
3066 thePopup->insertSeparator();
3068 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3069 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3070 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3075 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
3076 if(!aSObject->_is_nil()){
3078 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
3084 if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3087 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3088 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3090 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3091 // Available only for VTK viewer
3092 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3094 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3095 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3099 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
3100 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3102 case VISU::TTIMESTAMP: {
3103 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3104 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
3105 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3106 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
3107 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3108 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
3109 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3110 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
3111 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
3112 if(aNunComponent > 1){
3113 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
3114 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3115 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
3116 "Vectors...", visuGUI, SLOT(CreateVectors()));
3117 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
3118 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3126 if(IsSObjectTable(aSObject)){
3127 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
3128 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
3129 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
3130 thePopup->insertSeparator();
3131 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3135 CORBA::Long aTag = 1;
3136 SALOMEDS::SObject_var aSubObject;
3137 if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) {
3138 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3142 aSObject = aSObject->GetFather();
3143 if(aSObject->_is_nil()) return false;
3144 SALOMEDS::GenericAttribute_var anAttr;
3145 aSObject->FindAttribute(anAttr, "AttributeName");
3146 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
3147 if(aName->_is_nil()) return false;
3148 CORBA::String_var aValue = aName->Value();
3149 //if(strcmp(aValue.in(),"MEDMESH") == 0)
3150 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
3151 if(strcmp(aValue.in(),"MEDFIELD") == 0)
3152 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
3153 if ( aParentComponent != parent->getActiveComponent() ) {
3154 //insert pre-defined Display/Erase items
3155 if ( thePopup->count() > 0 ) {
3156 thePopup->insertSeparator();
3158 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3159 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3160 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3169 //===========================================================================
3170 // BuildPresentation
3171 //===========================================================================
3172 void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
3175 BEGIN_OF("VisuGUI::BuildPresentation");
3177 if (theIO.IsNull()) {
3178 if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3182 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3183 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3185 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK &&
3186 GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_PLOT2D) return;
3188 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3190 if (aSObj -> _is_nil() ) {
3191 if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3195 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3196 if(!CORBA::is_nil(anObject)) {
3197 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
3199 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3200 if(!SelectedActor) {
3202 SelectedActor = aPrsObject -> CreateActor();
3203 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3204 vf->AddActor(SelectedActor);
3205 }catch(std::runtime_error& exc){
3211 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
3214 PlotTable(aTable, VISU::eDisplay );
3216 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
3219 PlotContainer(aContainer, VISU::eDisplay );
3221 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
3224 PlotCurve(aCurve, VISU::eDisplay );
3227 if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3228 END_OF("VisuGUI::BuildPresentation");
3232 //===========================================================================
3233 // SupportedViewType
3234 //===========================================================================
3235 void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
3237 if (!buffer || !bufferSize) return;
3238 buffer[0] = (int)VIEW_VTK;
3239 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3244 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
3246 visuGUI = new VisuGUI( "" );
3252 //////////////////////////////////////////////////////////////////////////////////
3253 //////////////// CHANGE ACTOR COLOR ////////////////////////
3254 //////////////////////////////////////////////////////////////////////////////////
3255 ///////////////// /////////////////////////////////////////////////////////////////
3256 // change actor color
3257 // In : Name of Actor
3261 void VisuGUI::NewColor(VISU_Actor *theActor){
3262 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3263 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3264 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3265 SALOMEDS::Color anOldColor, aNewColor;
3266 int aRepresent = theActor->GetRepresentation();
3270 anOldColor = aMesh->GetNodeColor();
3272 case VISU::WIREFRAME :
3273 case VISU::INSIDEFRAME :
3274 anOldColor = aMesh->GetLinkColor();
3277 case VISU::SURFACEFRAME :
3278 anOldColor = aMesh->GetCellColor();
3281 else if(aDeformedShape)
3282 anOldColor = aDeformedShape->GetColor();
3285 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3286 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3287 if(aColorNew.isValid()){
3288 aNewColor.R = aColorNew.red()/255.;
3289 aNewColor.G = aColorNew.green()/255.;
3290 aNewColor.B = aColorNew.blue()/255.;
3294 aMesh->SetNodeColor(aNewColor);
3296 case VISU::WIREFRAME :
3297 case VISU::INSIDEFRAME :
3298 aMesh->SetLinkColor(aNewColor);
3301 case VISU::SURFACEFRAME :
3302 aMesh->SetCellColor(aNewColor);
3306 aDeformedShape->SetColor(aNewColor);
3307 RecreateActor(aPrs3d);
3312 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3313 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3314 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3315 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3316 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3317 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3318 if(aColorNew.isValid()){
3319 aNewColor.R = aColorNew.red()/255.;
3320 aNewColor.G = aColorNew.green()/255.;
3321 aNewColor.B = aColorNew.blue()/255.;
3322 aMesh->SetLinkColor(aNewColor);
3323 VisuGUI::RecreateActor(aMesh);
3329 //////////////////////////////////////////////////////////////////////////////////
3330 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3331 //////////////////////////////////////////////////////////////////////////////////
3332 //////////////////////////////////////////////////////////////////////////////////
3333 // change actor opacity
3334 // In : Name of Actor
3336 // Use CursorDlg to select a value between 0 and 100
3339 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3342 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3344 float oldopac,newopac;
3346 CursorDlg->Comment1->setText( tr( "Set value between") );
3347 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3348 oldopac=Actor->GetOpacity();
3349 intopac=int(oldopac*100.+0.5);
3350 CursorDlg->SpinBox1->setMinValue(0);
3351 CursorDlg->SpinBox1->setMaxValue(100);
3352 CursorDlg->SpinBox1->setValue(intopac);
3354 int ret = CursorDlg->exec();
3357 intopac = CursorDlg->SpinBox1->value() ;
3358 newopac = intopac/100.;
3359 Actor->SetOpacity(newopac);
3364 //////////////////////////////////////////////////////////////////////////////////
3365 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3366 //////////////////////////////////////////////////////////////////////////////////
3367 //////////////////////////////////////////////////////////////////////////////////
3368 // change actor linewidth
3369 // In : Name of Actor
3371 // Use CursorDlg to select a value between 0 and 10
3374 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3377 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3379 float oldlwid,newlwid;
3381 CursorDlg->Comment1->setText("Set value between");
3382 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3383 oldlwid=Actor->GetLineWidth();
3384 intlwid=int(oldlwid);
3385 CursorDlg->SpinBox1->setMinValue(1);
3386 CursorDlg->SpinBox1->setMaxValue(10);
3387 CursorDlg->SpinBox1->setValue(intlwid);
3389 int ret = CursorDlg->exec();
3391 intlwid = CursorDlg->SpinBox1->value() ;
3393 Actor->SetLineWidth(newlwid);
3398 /* ======================================================================================== */
3399 /* Setting parameters for Scalar Bar */
3400 /* ======================================================================================== */
3401 void VisuGUI::ChangeScalarBar()
3403 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3404 Scbar->initFromResources();
3405 int ret = Scbar->exec();
3407 Scbar->storeToResources();
3412 /* ======================================================================================== */
3413 /* Setting parameters for Sweeping */
3414 /* ======================================================================================== */
3415 void VisuGUI::SetSweepingPreferences()
3421 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3422 if ( !Tempo.isEmpty() )
3423 tempo = Tempo.toFloat();
3425 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3426 if ( !Cycles.isEmpty() )
3427 cycles = Cycles.toInt();
3429 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3430 if ( !Steps.isEmpty() )
3431 steps = Steps.toInt();
3433 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3435 Sweep->setTimeStep( tempo );
3436 Sweep->setNbCycles( cycles );
3437 Sweep->setNbSteps ( steps );
3439 if ( Sweep->exec() )
3441 tempo = Sweep->getTimeStep();
3442 cycles = Sweep->getNbCycles();
3443 steps = Sweep->getNbSteps();
3445 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3446 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3447 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3452 /* ======================================================================================== */
3453 /* Returns Visu input files directory (default is CSF_PATHData) */
3454 /* ======================================================================================== */
3455 QString VisuGUI::getVisuInputDir()
3457 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3458 if ( Tmp.isEmpty() )
3459 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3460 Tmp = QAD_Tools::addSlash(Tmp);
3464 /* ======================================================================================== */
3465 /* Returns Visu output files directory (default is InputDir) */
3466 /* ======================================================================================== */
3467 QString VisuGUI::getVisuOutputDir()
3469 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3470 if ( Tmp.isEmpty() )
3472 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3473 if ( Tmp2.isEmpty() )
3474 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3478 Tmp = QAD_Tools::addSlash(Tmp);
3483 /* ======================================================================================== */
3484 /* Global Method for Scalar Map */
3485 /* ======================================================================================== */
3486 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3487 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3488 SALOMEDS::SObject_var aSObj = theField->GetFather();
3489 if (CORBA::is_nil(aSObj)) return NULL;
3490 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3491 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3492 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3493 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3494 if(CORBA::is_nil(anObject)) return NULL;
3495 theResult = VISU::Result::_narrow(anObject);
3496 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
3498 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3499 tr ("WRN_NO_AVAILABLE_DATA"),
3500 tr ("VISU_BUT_OK"));
3504 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3505 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3506 const char* theMeshName, VISU::Entity theEntity, \
3507 const char* theFieldName, int theTimeId) {\
3508 VISU::Result_var aResult; \
3509 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3510 if(pResult != NULL){ \
3511 QApplication::setOverrideCursor( Qt::waitCursor ); \
3512 CORBA::Object_var anObject = \
3513 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3514 QApplication::restoreOverrideCursor(); \
3515 if(!CORBA::is_nil(anObject)) \
3516 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
3518 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3519 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3520 tr ("VISU_BUT_OK") ); \
3524 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3525 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3526 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3527 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3528 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3529 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3530 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3533 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3534 bool FNAME(SALOMEDS::SObject_var theField) { \
3535 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3537 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3538 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3539 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3540 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3541 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3542 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3543 Utils_Timer timer; \
3544 if(MYCHECKTIME) timer.Start(); \
3545 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3548 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
3552 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3553 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3554 DLGNAME* aDlg = new DLGNAME(); \
3555 aDlg->initFromPrsObject(pPresent); \
3556 if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
3559 DeletePresentation(pPresent); \
3565 CreateActor(pPresent); \
3573 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3574 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3575 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3576 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3577 //BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3578 //BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3579 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3582 bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
3584 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3586 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3587 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3588 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3589 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3590 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3591 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3593 if(MYCHECKTIME) timer.Start();
3594 VISU::CutPlanes_i* pPresent =
3595 CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
3598 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT");
3602 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3603 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3604 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
3605 aDlg->initFromPrsObject(pPresent);
3607 myActiveDialogBox = aDlg;
3608 // if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
3611 // DeletePresentation(pPresent);
3616 // CreateActor(pPresent);
3620 }catch (...){return false;}
3624 bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
3626 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3628 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3629 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3630 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3631 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3632 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3633 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3635 if(MYCHECKTIME) timer.Start();
3636 VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
3637 (VISU::Entity)anEntity.toInt(),
3638 aFieldName,aTimeStampId.toInt());
3641 MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT");
3645 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3646 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3647 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true);
3648 aDlg->initFromPrsObject(pPresent);
3650 myActiveDialogBox = aDlg;
3652 // if (aDlg->exec()) {
3653 // aDlg->storeToPrsObject(pPresent);
3654 // if (aDlg->isGenerateTable()) {
3655 // GetVisuGen()->CreateTable(pPresent->GetEntry());
3656 // if (aDlg->isGenerateCurves()) {
3657 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3658 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
3659 // if(!aSObject->_is_nil()) {
3660 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
3661 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
3662 // for ( ;aIter->More(); aIter->Next()) {
3663 // SALOMEDS::SObject_var aTblObj = aIter->Value();
3664 // if (!aTblObj->_is_nil()) {
3665 // SALOMEDS::GenericAttribute_var anAttr;
3666 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
3667 // CreatePlot(aTblObj);
3673 // GetActiveStudy()->updateObjBrowser();
3676 // DeletePresentation(pPresent);
3682 // CreateActor(pPresent);
3686 }catch (...){return false; }
3692 /* ======================================================================================== */
3693 /* Global Method to import tables from file */
3694 /* ======================================================================================== */
3695 void VisuGUI::ImportTablesFromFile(){
3696 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3698 flt.append( "Files (*.xls *.txt *.tab)" );
3699 flt.append( "All Files (*.*)" );
3700 QString aDir = getVisuInputDir();
3701 QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3702 aDir,flt,tr("Import From File"),true);
3704 if(aFileInfo.exists()){
3705 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3706 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3707 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3710 CORBA::Object_var anObject;
3716 anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3720 MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE");
3724 if(CORBA::is_nil(anObject)) {
3726 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3727 tr ("ERR_ERROR_IN_THE_FILE"),
3728 tr ("VISU_BUT_OK") );
3732 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3734 GetActiveStudy()->updateObjBrowser(); //update Object browser
3738 void VisuGUI::ExportTableToFile()
3740 QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
3741 SALOME_Selection* aSel = SALOME_Selection::Selection ( aQADStudy -> getSelection() );
3743 if( aSel->IObjectCount() > 0 ) {
3744 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
3745 if(anIO->hasEntry()){
3746 SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
3747 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
3748 if(CORBA::is_nil(aSObj)) return;
3751 SALOMEDS::GenericAttribute_var anAttr;
3753 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3754 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
3755 aSObj = aSObj->GetFather(); //if the current SObject is a table title
3756 // we take a father contaning the table
3757 if (!CORBA::is_nil(aSObj)) {
3758 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3759 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
3764 if (CORBA::is_nil(anAttr)) return;
3766 SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
3767 if (!CORBA::is_nil(aTabAttr))
3768 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3770 SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
3771 if (!CORBA::is_nil(aTabAttr))
3772 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3775 aTitle.simplifyWhiteSpace();
3777 flt.append("Table Files (*.xls)");
3779 QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
3780 aDlg -> setCaption("Export Table To File");
3781 aDlg -> setDir( getVisuOutputDir() );
3782 aDlg -> setFilters(flt);
3783 aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
3785 QString aFile = aDlg -> selectedFile();
3788 if(!aFile.isEmpty()){
3789 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3790 QString aDir = QAD_Tools::getDirFromPath(aFile);
3791 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3794 GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
3795 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3796 } catch(std::exception& ex) {
3798 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3799 tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
3800 tr ("VISU_BUT_OK") );
3802 INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
3803 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3804 tr ("ERR_ERROR_DURING_EXPORT"),
3805 tr ("VISU_BUT_OK") );
3811 /* ======================================================================================== */
3812 /* Global Method to import mesh results in MED and DAT format */
3813 /* ======================================================================================== */
3814 void VisuGUI::ImportFile(){
3815 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
3817 void VisuGUI::CopyAndImportFile(){
3818 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
3820 void VisuGUI::ImportFromFile(TImportFun theImportFun){
3821 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3823 //flt.append( "Exportable Files (*.med *.dat)" );
3824 //flt.append( "Dat Files (*.dat)" );
3825 flt.append( "Med Files (*.med)" );
3826 QString aDir = getVisuInputDir();
3827 QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3828 aDir,flt,tr("Import From File"),true);
3830 if(aFileInfo.exists()){
3831 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3832 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3833 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3836 VISU::Result_var aResult;
3842 QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3843 bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3844 if (VisuGUI_FileDlg::IsBuild){
3845 aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3846 if(!CORBA::is_nil(aResult.in()))
3847 if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
3848 if(!pResult->IsPossible())
3849 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3850 tr ("ERR_CANT_BUILD_PRESENTATION"),
3851 tr ("VISU_BUT_OK") );
3853 aResult->BuildAll();
3856 QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3857 //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
3858 aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1
3859 QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3863 MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
3867 if(CORBA::is_nil(aResult.in())) {
3869 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3870 tr ("ERR_ERROR_IN_THE_FILE"),
3871 tr ("VISU_BUT_OK") );
3875 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3877 GetActiveStudy()->updateObjBrowser(); //update Object browser
3881 void VisuGUI::ExportToFile(){
3882 CORBA::Object_var anObject = GetSelectedObj();
3883 if(CORBA::is_nil(anObject)) return;
3884 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
3885 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3887 flt.append( "Dat Files (*.dat)" );
3888 flt.append( "Med Files (*.med)" );
3889 QString aDir = getVisuOutputDir();
3890 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3891 aDir,flt,tr("Export To File"),false);
3892 if(!aFile.isEmpty()){
3893 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3894 aDir = QAD_Tools::getDirFromPath(aFile);
3895 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3896 if(dynamic_cast<VISU::Result_i*>(aBase)){
3898 //APO - aResult->GetInput()->ToFile(aFile.latin1());
3899 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3900 }catch(std::exception& ex) {
3902 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3903 tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
3904 tr ("VISU_BUT_OK") );
3907 INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
3908 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3909 tr ("ERR_ERROR_DURING_EXPORT"),
3910 tr ("VISU_BUT_OK") );
3915 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3916 tr ("WRN_NO_AVAILABLE_DATA"),
3917 tr ("VISU_BUT_OK"));
3920 /* ======================================================================================== */
3921 /* Test and Read Object Browser before display */
3922 /* ======================================================================================== */
3923 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3924 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3925 Handle(SALOME_InteractiveObject) anIO;
3926 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3927 if(!anIO.IsNull() && anIO->hasEntry()){
3928 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3929 QString aValue = getValue(objVisu,"myType");
3930 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3932 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3933 tr("WRN_NO_AVAILABLE_DATA"),
3934 tr("VISU_BUT_OK") );
3939 * Returns Actor of presentation if it exists
3941 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3942 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3943 if (!vf) return NULL;
3945 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3946 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3947 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3948 if(thePrs == anVISUActor->GetPrs3d())
3949 return anVISUActor->GetParent();
3954 * Displays only actor of given presentation
3955 * Creates it if it is abcent
3957 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3958 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3959 if (!vf) return NULL;
3961 vtkRenderer *aRen = vf->getRenderer();
3962 vtkActorCollection *anActColl = aRen->GetActors();
3965 VISU_Actor* anVISUActor = NULL;
3966 VISU_Actor* aResActor = NULL;
3967 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3968 if(!SALOME_Actor::SafeDownCast(anActor))
3970 if(anActor->IsA("VISU_Actor")){
3971 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3972 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
3973 if(aPrs == NULL) continue;
3974 if (thePrs == aPrs) {
3975 aResActor = anVISUActor->GetParent();
3976 thePrs->UpdateActor(aResActor);
3977 aResActor->VisibilityOn();
3979 } else if (theDispOnly) {
3980 anVISUActor->GetParent()->VisibilityOff();
3983 } else if (theDispOnly && anActor->GetVisibility()) {
3984 anActor->VisibilityOff();
3988 if (aResActor) return aResActor;
3990 anVISUActor = thePrs->CreateActor();
3991 vf->AddActor(anVISUActor);
3992 } catch ( std::runtime_error& exc ){
3994 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3995 tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
3996 tr ("VISU_BUT_OK") );
4004 * Returns TRUE if Presentation is displayed
4006 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
4007 VISU_Actor* anVISUActor = GetActor(thePrs);
4008 return (anVISUActor)? anVISUActor->GetVisibility() : false;
4012 * Erases Presentation
4014 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
4015 GetActiveStudy()->unHighlightAll();
4016 VISU_Actor* anVISUActor = GetActor(thePrs);
4018 anVISUActor->VisibilityOff();
4023 * Deletes given presentation from Data structure
4025 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
4026 if(checkLock(GetStudyDocument()) || !thePrs) return;
4027 GetActiveStudy()->unHighlightAll();
4028 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
4029 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
4030 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
4031 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
4032 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
4033 aViewFrame->RemoveActor(anActor);
4036 aViewFrame->unHighlightAll();
4039 thePrs->RemoveFromStudy();
4040 GetActiveStudy()->updateObjBrowser(); //update Object browser
4044 * Deletes given curve presentation from Data structure
4046 void VisuGUI::DeletePresentation(VISU::Curve_i* theCurve) {
4047 if(checkLock(GetStudyDocument()) || !theCurve) return;
4048 GetActiveStudy()->unHighlightAll();
4049 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
4050 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
4051 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
4052 if(Plot2d_ViewFrame* aViewFrame = dynamic_cast<Plot2d_ViewFrame*>(aVFrame)){
4053 QList<Plot2d_Curve> clist;
4054 aViewFrame->getCurves( clist );
4055 for ( int i = 0; i < clist.count(); i++ ) {
4056 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) )
4057 aViewFrame->eraseCurve( clist.at( i ) );
4059 aViewFrame->Repaint();
4060 aViewFrame->unHighlightAll();
4063 theCurve->RemoveFromStudy();
4064 GetActiveStudy()->updateObjBrowser(); //update Object browser
4068 * Creates new actor of presentation
4070 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
4071 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
4072 if (!thePrs) return;
4073 QApplication::setOverrideCursor( Qt::waitCursor );
4074 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
4080 MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4081 VISU_Actor* aActor = thePrs->CreateActor();
4082 vf->AddActor(aActor);
4083 }catch(std::runtime_error& exc) {
4084 INFOS("std::runtime_error "<<exc.what());
4085 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4086 QApplication::restoreOverrideCursor();
4087 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4088 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
4089 tr ("VISU_BUT_OK") );
4092 MESSAGE(" Unknown exception");
4093 QApplication::restoreOverrideCursor();
4094 INFOS("Unknown exception is caught in VisuGUI::CreateActor");
4095 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4096 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4097 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
4098 tr ("VISU_BUT_OK") );
4103 MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
4107 QApplication::restoreOverrideCursor();
4112 /* ======================================================================================== */
4113 /* Functions to State of VisuGUI and Dialog Box */
4114 /* ======================================================================================== */
4116 void VisuGUI::SetState(int aState )
4118 this->myState = aState ;
4123 void VisuGUI::ResetState()
4125 this->myState = -1 ;
4129 void VisuGUI::EmitSignalDeactivateDialog()
4131 emit this->SignalDeactivateActiveDialog() ;
4135 void VisuGUI::EmitSignalCloseAllDialogs()
4137 emit this->SignalCloseAllDialogs() ;
4141 QDialog* VisuGUI::GetActiveDialogBox()
4143 return this->myActiveDialogBox ;
4146 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
4148 this->myActiveDialogBox = (QDialog*)aDlg ;