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>
124 #include CORBA_CLIENT_HEADER(MED_Gen)
126 #include <vtkActor.h>
127 #include <vtkRenderer.h>
128 #include <vtkDataSetMapper.h>
129 #include <vtkActorCollection.h>
131 // Open CASCADE Include
132 #include <TCollection_AsciiString.hxx>
136 static int MYCHECKTIME = 1;
138 static int MYCHECKTIME = 0;
140 #include <Utils_Timer.hxx>
145 static int MYDEBUG = 0;
146 static int MYDEBUGWITHFILES = 0;
148 static int MYDEBUG = 0;
149 static int MYDEBUGWITHFILES = 0;
152 class CustomItem : public QCustomMenuItem
155 CustomItem(const QString& s, const QFont& f) : myString(s), myFont(f) {}
158 void paint(QPainter* p, const QColorGroup& cg, bool act, bool /*enabled*/, int x, int y, int w, int h)
161 p->fillRect( x, y, w, h, act ? cg.highlight() : cg.mid() );
162 p->setPen( act ? cg.highlightedText() : cg.buttonText() );
163 p->setFont( myFont );
164 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
170 return QFontMetrics( myFont ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, myString );
173 bool fullSpan() const
183 inline bool IsSObjectTable(SALOMEDS::SObject_ptr theSObject){
184 if(!theSObject->_is_nil()) {
185 SALOMEDS::GenericAttribute_var anAttr;
186 if(theSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ))
188 if(theSObject->FindAttribute( anAttr, "AttributeTableOfReal" ))
195 static VisuGUI MYVISUGUI;
196 VisuGUI *visuGUI = &MYVISUGUI;
198 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
199 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
200 return VISU::VISU_Gen_i::GetVisuGenImpl();
203 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
204 const char* theActorClassName = "VISU_Actor")
206 vtkRenderer *aRen = theViewFrame->getRenderer();
207 vtkActorCollection *anActColl = aRen->GetActors();
210 int nothingVisible=1;
212 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
213 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
214 // loop through all props
215 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
216 // if it's invisible, or has no geometry, we can skip the rest
217 if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
218 bounds = prop->GetBounds();
219 // make sure we haven't got bogus bounds
220 if ( bounds != NULL &&
221 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
222 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
223 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
226 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
227 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
228 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
229 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
230 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
231 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
235 return nothingVisible;
238 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
239 static float PRECISION = 0.000001;
240 static float DEVIATION = 600;
242 if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
244 float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
246 float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
248 float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
250 CameraOrient aCameraOrient = e3D;
251 if(absX <= PRECISION) aCameraOrient = eFront;
252 else {if(absY <= PRECISION) aCameraOrient = eLeft;
253 else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
255 float dev_abs_XY = absX / absY;
256 float dev_abs_YZ = absY / absZ;
257 float dev_abs_XZ = absX / absZ;
258 if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
259 else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
260 else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
262 switch(aCameraOrient){
263 case eFront: theViewFrame->onViewFront(); break;
264 case eLeft: theViewFrame->onViewLeft(); break;
265 case eTop: theViewFrame->onViewTop(); break;
266 case e3D: theViewFrame->onViewReset(); break;
268 theViewFrame->getRenderer()->ResetCameraClippingRange();
269 theViewFrame->onViewFitAll();
270 return aCameraOrient;
273 QAD_Desktop* VisuGUI::GetDesktop(){
274 return QAD_Application::getDesktop() ;
277 QAD_Study* VisuGUI::GetActiveStudy(){
278 return GetDesktop()->getActiveStudy() ;
281 vtkRenderer* VisuGUI::GetRenderer(){
282 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
283 return aViewFrame->getRenderer();
287 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
288 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
289 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
292 static void UpdateViewFrame() {
293 QList<QAD_StudyFrame> aFrameList = VisuGUI::GetActiveStudy()->getStudyFrames();
295 for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) {
296 if (aStudyFrame->getTypeView() == VIEW_VTK) {
297 QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
298 VTKViewer_ViewFrame* aVtkViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
299 if (!aVtkViewFrame) continue;
300 VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor();
302 anInteractor->SetSelectionProp();
303 anInteractor->SetSelectionTolerance();
304 VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME();
306 aStyle->setPreselectionProp();
313 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
314 return GetActiveStudy()->getStudyDocument();
317 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
318 return GetStudyDocument()->NewBuilder();
323 * Finds value by given key
326 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
327 VISU::Storable::TRestoringMap aMap;
328 if(!theSObject->_is_nil()){
329 SALOMEDS::GenericAttribute_var anAttr;
330 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
331 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
332 CORBA::String_var aString = aComment->Value();
333 QString strIn(aString.in());
334 VISU::Storable::StrToMap(strIn,aMap);
340 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
342 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
344 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
349 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
350 VISU::Storable::TRestoringMap* pMap = NULL)
352 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
353 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
354 if(aSel->IObjectCount() > 0){
355 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
356 if(pIO != NULL) *pIO = anIO;
357 if(anIO->hasEntry()){
358 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
359 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
360 if(!aSObject->_is_nil()){
361 SALOMEDS::GenericAttribute_var anAttr;
362 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
363 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
364 string aComm = aComment->Value();
365 QString strIn(aComm.c_str());
366 VISU::Storable::StrToMap(strIn,*pMap);
368 return VISU::SObjectToObject(aSObject);
372 return CORBA::Object::_nil();
376 int IsTrihedronDisplayed(){
377 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
378 return aVTKViewFrame->isTrihedronDisplayed();
383 void RepaintCurrentView(){
384 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
388 VisuGUI::VisuGUI( const QString& theName, QObject* theParent ):
389 SALOMEGUI( theName, theParent )
394 /* ==================================================================================== */
395 /* ==================================================================================== */
397 /* ==================================================================================== */
398 /* ==================================================================================== */
400 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
401 return theStudy->GetProperties()->IsLocked();
404 static int checkLock(const SALOMEDS::Study_var& theStudy) {
405 if (isStudyLocked(theStudy)) {
406 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
407 QObject::tr("WRN_WARNING"),
408 QObject::tr("WRN_STUDY_LOCKED"),
409 QObject::tr("BUT_OK") );
417 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
420 QString VisuInputDir = getVisuInputDir();
421 QString VisuOutputDir = getVisuOutputDir();
422 vtkRenderer *theRenderer = GetRenderer();
424 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
425 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
426 SALOMEDS::GenericAttribute_var anAttr;
427 SALOMEDS::AttributeName_var aName;
428 SALOMEDS::AttributeIOR_var anIOR;
430 switch (theCommandID){
431 /* ======================================================================================== */
432 /* Import Table from file */
433 /* ======================================================================================== */
436 if(checkLock(aStudy)) break;
437 visuGUI->ImportTablesFromFile();
441 /* ======================================================================================== */
442 /* Import Mesh from MED, DAT file */
443 /* ======================================================================================== */
447 visuGUI->CopyAndImportFile();
452 visuGUI->ImportFile();
456 /* ======================================================================================== */
457 /* Export results and mesh into a file format */
458 /* ======================================================================================== */
462 //visuGUI->ExportToFile();
466 /* ========================================================================== */
467 /* Visualization of Results : */
468 /* 4011 : Scalar Map */
469 /* 4012 : Deformed Shape */
471 /* 4014 : Iso-Surfaces */
472 /* 4015 : Cut Planes */
473 /* 4016 : Stream Lines */
474 /* ========================================================================== */
477 visuGUI->CreateScalarMap();
480 visuGUI->CreateDeformedShape();
483 visuGUI->CreateVectors();
486 visuGUI->CreateIsoSurfaces();
489 visuGUI->CreateCutPlanes();
492 visuGUI->CreateCutLines();
495 visuGUI->CreateStreamLines();
499 visuGUI->SelectionInfo();
502 /* ========================================================================================================================= */
503 /* Visualization - Wireframe */
504 /* ========================================================================================================================= */
510 /* ========================================================================================================================= */
511 /* Visualization - Surface */
512 /* ========================================================================================================================= */
518 /* ========================================================================================================================= */
519 /* Visualization - Points */
520 /* ========================================================================================================================= */
526 /* ========================================================================================================================= */
527 /* Visualization - Erase */
528 /* ========================================================================================================================= */
534 /* ========================================================================================================================= */
535 /* Visualization - Global */
536 /* ========================================================================================================================= */
540 /* ========================================================================================================================= */
541 /* Visualization - Partial */
542 /* ========================================================================================================================= */
548 //Show dialog that allows to select scale function and corresponding scale factor
549 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
550 FALSE, Qt::WDestructiveClose );
555 /* ============================ */
556 /* POP-UP OBJECTS BROWSER */
557 /* ============================ */
559 case 900 : // Rename object
563 // ---------------- For Popup in Viewer
569 case 803 : // Display only
570 case 903 : // Display only
571 visuGUI->DisplayOnlyPrs();
574 case 901 : // Display
575 visuGUI->DisplayPrs();
578 case 8041 : // Object representation : Wireframe
579 case 9041 : // Object representation : Wireframe
580 visuGUI->ChangeRepresentation(VISU::WIREFRAME);
583 case 8042 : // Object representation : Surface
584 case 9042 : // Object representation : Surface
585 visuGUI->ChangeRepresentation(VISU::SHADED);
588 case 8043 : // Object representation : Points
589 case 9043 : // Object representation : Points
590 visuGUI->ChangeRepresentation(VISU::POINT);
593 case 8044 : // Object representation : Shrink/Unshrink
594 case 9044 : // Object representation : Shrink/Unshrink
595 visuGUI->ChangeRepresentation(VISU::SHRINK);
598 case 8051 : // Change object color
599 case 9051 : // Change object color
600 visuGUI->ChageColor();
603 case 8052 : // Change object opacity
604 case 9052 : // Change object opacity
605 visuGUI->ChangeOpacity();
608 case 8053 : // Change object line width
609 case 9053 : // Change object line width
610 visuGUI->ChangeLines();
613 case 808 : // Sweep IsoSurfaces or Cutplanes
614 case 908 : // Sweep IsoSurfaces or Cutplanes
618 /* ======================================================================================== */
619 /* Preferences for Scalar Bar */
620 /* ======================================================================================== */
627 /* ======================================================================================== */
628 /* Preferences for Sweeping */
629 /* ======================================================================================== */
632 SetSweepingPreferences();
636 /* ======================================================================================== */
637 /* Preferences for Full loading */
638 /* ======================================================================================== */
643 QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
644 bool check = !pp->isItemChecked(theCommandID);
645 pp->setItemChecked(theCommandID,check);
646 switch(theCommandID){
648 QAD_CONFIG->addSetting( "Visu:BuildResult", check );
651 QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
657 case 113: // Load MED using MED component
659 if (checkLock(GetStudyDocument())) break;
661 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
662 if (CORBA::is_nil(aMedComp)) return false;
663 SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
664 if (CORBA::is_nil(aMedGen)) return false;
666 QStringList filtersList ;
668 filtersList.append( tr("MED_MEN_IMPORT_MED") );
669 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
670 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
673 tr("MED_MEN_IMPORT"),
675 if (!aFileName.isEmpty()) {
676 QApplication::setOverrideCursor( Qt::waitCursor );
677 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
678 GetActiveStudy()->updateObjBrowser();
679 QApplication::restoreOverrideCursor();
685 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
686 tr ("MSG_NOT_IMPLEMENTED"),
687 tr ("VISU_BUT_OK") );
690 } catch (const std::bad_alloc& e ) {
691 INFOS("bad_alloc exception is caught "<<e.what());
692 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
693 tr("ERR_NO_MEMORY") + " " + tr(e.what()),
697 catch (std::exception& e){
699 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
702 }catch (const SALOME::SALOME_Exception& S_ex) {
703 INFOS("const SALOME::SALOME_Exception& S_ex");
704 QtCatchCorbaException(S_ex);
708 INFOS(tr("ERR_UNKNOWN_EXCEPTION").latin1());
709 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
710 tr("ERR_UNKNOWN_EXCEPTION"),
717 void VisuGUI::SelectionInfo() {
718 mySelectionDlg = new VisuGUI_SelectionDlg();
719 mySelectionDlg->show();
725 /* ********************************************************************************** */
726 /* Function ShowTrihedron */
727 /* ********************************************************************************** */
729 void VisuGUI::ShowTrihedron(bool ShowThd){
730 bool ThdIsVisible = true;
731 if( ShowThd && !ThdIsVisible)
732 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
733 if( !ShowThd && ThdIsVisible)
734 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
737 /* ********************************************************************************** */
739 /* Clear all tmp files used in VISU */
740 /* ********************************************************************************** */
743 if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
746 /* ********************************************************************************** */
747 /* Function ChangeViewer */
748 /* Change representation of all actors */
749 /* ********************************************************************************** */
751 void VisuGUI::ChangeViewer(int theType){
753 GetActiveStudy()->unHighlightAll();
754 if(vtkRenderer *aRen = GetRenderer()){
756 vtkActorCollection *anActColl = aRen->GetActors();
757 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
758 if(anActor->GetVisibility() > 0)
759 if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){
760 anVISUActor = anVISUActor->GetParent();
762 anVISUActor->SetRepresentation(theType);
764 anVISUActor->VisibilityOff();
767 RepaintCurrentView();
771 // -----------------------------------------------------------------------------------------
773 // -----------------------------------------------------------------------------------------
775 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
780 // ====================================================================================================================
782 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
787 // ===================================================================================================================
789 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
791 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
794 if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
800 if(MYDEBUG) MESSAGE("--> Key : Escape")
812 //=====================================================================================
813 // Slot-functions for presentations creation
814 //=====================================================================================
816 #define CREATEPRESENTATION(FunctionName) \
817 void FunctionName() { \
818 if (checkLock(GetStudyDocument())) return; \
819 SALOMEDS::SObject_var objVisu; \
820 if (!TestObjectBrowser(objVisu)) return; \
821 if(!FunctionName(objVisu)) return; \
822 GetActiveStudy()->updateObjBrowser(); \
823 GetDesktop()->putInfo("Ready"); \
824 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
826 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
827 vf->onViewFitAll(); \
832 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
833 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
834 CREATEPRESENTATION(VisuGUI::CreateVectors);
835 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
836 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
837 CREATEPRESENTATION(VisuGUI::CreateCutLines);
838 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
842 //=====================================================================================
843 // function : SetSettings()
845 //=====================================================================================
846 bool VisuGUI::SetSettings(QAD_Desktop* parent)
850 QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
851 QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
853 if(aValue.isEmpty()? 0 : aValue.toInt())
854 pp->setItemChecked(anId, true);
857 item = parent->menuBar()->findItem(anId,&pp);
858 aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
860 if(aValue.isEmpty()? 0 : aValue.toInt())
861 pp->setItemChecked(anId, true);
864 parent->menuBar()->changeItem(anId,parent->getComponentUserName("VISU"));
871 //=====================================================================================
872 // function : DisplayPrs()
874 //=====================================================================================
875 void VisuGUI::DisplayPrs() {
876 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
877 Handle(SALOME_InteractiveObject) anIO;
878 CORBA::Object_var anObject = GetSelectedObj(&anIO);
879 if ( !CORBA::is_nil( anObject ) ) {
880 // is it Prs3d object ?
881 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
883 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
884 UpdateViewer(aPrsObject);
885 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
886 vf->getRenderer()->ResetCameraClippingRange();
888 vf->highlight(anIO, 1);
893 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
895 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
896 PlotCurve(aCurve, VISU::eDisplay );
900 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
902 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
903 PlotContainer(aContainer, VISU::eDisplay );
907 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
909 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
910 PlotTable(aTable, VISU::eDisplay );
916 //=====================================================================================
917 // function : DisplayOnlyPrs()
919 //=====================================================================================
920 void VisuGUI::DisplayOnlyPrs() {
921 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
922 CORBA::Object_var anObject = GetSelectedObj();
923 if ( !CORBA::is_nil( anObject ) ) {
924 // is it Prs3d object ?
925 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
926 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
927 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
928 UpdateViewer(aPrsObject, true);
929 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
931 vf->getRenderer()->ResetCameraClippingRange();
934 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
935 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
936 PlotCurve(aCurve, VISU::eDisplayOnly );
937 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
938 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
939 PlotContainer(aContainer, VISU::eDisplayOnly );
940 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
941 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
942 PlotTable(aTable, VISU::eDisplayOnly );
947 //=====================================================================================
948 // function : ErasePrs()
950 //=====================================================================================
951 static void ErasePrs(CORBA::Object_ptr theObject) {
952 if(MYDEBUG) MESSAGE("ErasePrs");
953 if ( !CORBA::is_nil( theObject ) ) {
954 VISU::Base_var aBase = VISU::Base::_narrow(theObject);
955 if ( CORBA::is_nil( aBase ) ) return;
956 VISU::VISUType aType = aBase->GetType();
959 if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aBase).in()))
960 VisuGUI::PlotCurve(aCurve, VISU::eErase );
963 case VISU::TCONTAINER:{
964 if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aBase).in()))
965 VisuGUI::PlotContainer(aContainer, VISU::eErase );
969 if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aBase).in()))
970 VisuGUI::PlotTable(aTable, VISU::eErase );
974 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aBase).in())){
975 VisuGUI::ErasePrs(aPrsObject);
976 if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame())
983 void VisuGUI::ErasePrs() {
984 ::ErasePrs(GetSelectedObj());
988 //=====================================================================================
989 // function : DisplayManyPrs()
991 //=====================================================================================
992 void VisuGUI::DisplayManyPrs()
994 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
995 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
996 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
997 for ( ; It.More(); It.Next() ) {
998 Handle(SALOME_InteractiveObject)& anIO = It.Value();
999 if ( anIO->hasEntry() ) {
1000 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1001 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1002 VISU::Storable::TRestoringMap pMap;
1003 if( !aSObject->_is_nil() ) {
1004 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1005 if ( !CORBA::is_nil( aCORBAObject ) ) {
1006 // is it Prs3d object ?
1007 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1009 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
1010 UpdateViewer(aPrsObject);
1011 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1013 vf->getRenderer()->ResetCameraClippingRange();
1015 vf->highlight(anIO, 1);
1020 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1022 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
1023 PlotCurve(aCurve, VISU::eDisplay );
1026 // is it Container ?
1027 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1029 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
1030 PlotContainer(aContainer, VISU::eDisplay );
1034 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1036 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
1037 PlotTable(aTable, VISU::eDisplay );
1046 //=====================================================================================
1047 // function : DisplayOnlyManyPrs()
1049 //=====================================================================================
1050 void VisuGUI::DisplayOnlyManyPrs() {
1051 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
1052 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1053 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1054 bool aFirstElem = true;
1055 for ( ; It.More(); It.Next() ) {
1056 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1057 if ( anIO->hasEntry() ) {
1058 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1059 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1060 VISU::Storable::TRestoringMap pMap;
1061 if( !aSObject->_is_nil() ) {
1062 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1063 if ( !CORBA::is_nil( aCORBAObject ) ) {
1064 // is it Prs3d object ?
1065 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1067 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1068 UpdateViewer(aPrsObject, aFirstElem);
1069 if (aFirstElem) aFirstElem = false;
1070 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1072 vf->getRenderer()->ResetCameraClippingRange();
1074 vf->highlight(anIO, 1);
1079 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1081 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1083 PlotCurve(aCurve, VISU::eDisplayOnly );
1086 else PlotCurve(aCurve, VISU::eDisplay );
1089 // is it Container ?
1090 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1092 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1094 PlotContainer(aContainer, VISU::eDisplayOnly );
1097 else PlotContainer(aContainer, VISU::eDisplay );
1101 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1103 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1105 PlotTable(aTable, VISU::eDisplayOnly );
1108 else PlotTable(aTable, VISU::eDisplay );
1118 //=====================================================================================
1119 // function : EraseManyPrs()
1121 //=====================================================================================
1122 void VisuGUI::EraseManyPrs()
1124 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1125 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1126 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1127 SALOME_ListIteratorOfListIO It( LIO );
1128 for ( ; It.More(); It.Next() ) {
1129 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1130 if ( anIO->hasEntry() ) {
1131 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1132 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1133 VISU::Storable::TRestoringMap pMap;
1134 if( !aSObject->_is_nil() ) {
1135 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1136 if ( !CORBA::is_nil( aCORBAObject ) ) {
1137 // is it Prs3d object ?
1138 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1140 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1141 ErasePrs(aPrsObject);
1142 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1149 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1151 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1152 PlotCurve(aCurve, VISU::eErase );
1155 // is it Container ?
1156 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1158 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1159 PlotContainer(aContainer, VISU::eErase );
1163 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1165 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1166 PlotTable(aTable, VISU::eErase );
1175 //=====================================================================================
1176 // function : RecreateActor()
1178 //=====================================================================================
1179 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1180 QApplication::setOverrideCursor(Qt::waitCursor);
1183 //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
1184 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1185 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1186 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1187 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1188 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1189 thePrs->UpdateActor(anActor);
1191 }catch(std::runtime_error& ex){
1193 QApplication::restoreOverrideCursor();
1194 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1195 tr ("ERR_CANT_BUILD_PRESENTATION") + " " + tr(ex.what()),
1196 tr ("VISU_BUT_OK") );
1197 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1198 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1199 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1200 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
1201 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
1202 aViewFrame->RemoveActor(anActor);
1209 QApplication::restoreOverrideCursor();
1213 //=====================================================================================
1214 // function : EditPrs()
1216 //=====================================================================================
1217 #define EDITPRS(PrsName, DlgName) \
1219 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1221 DlgName* aDlg = new DlgName(); \
1222 aDlg->initFromPrsObject(aPrsObject); \
1223 if ( aDlg->exec() ) { \
1224 if(!(aDlg->storeToPrsObject(aPrsObject))){ \
1228 RecreateActor(aPrsObject); \
1229 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1230 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1231 vf->getRenderer()->ResetCameraClippingRange(); \
1240 void VisuGUI::EditPrs() {
1241 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1243 switch (aPrs3d->GetType()) {
1244 case VISU::TMESH: // Mesh 13
1247 case VISU::TSCALARMAP: // ScalarMap 18
1248 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1251 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1252 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1255 case VISU::TCUTPLANES: // Cut planes 42
1256 //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1258 VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
1260 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
1261 aDlg->initFromPrsObject(aPrsObject);
1263 myActiveDialogBox = aDlg;
1264 // if ( aDlg->exec() ) {
1265 // if(!(aDlg->storeToPrsObject(aPrsObject))){
1269 // RecreateActor(aPrsObject);
1270 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1271 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1272 // vf->getRenderer()->ResetCameraClippingRange();
1282 case VISU::TCUTLINES: // Cut planes 42
1283 //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1285 VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
1287 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false);
1288 aDlg->initFromPrsObject(aPrsObject);
1290 myActiveDialogBox = aDlg;
1291 // if ( aDlg->exec() ) {
1292 // aDlg->storeToPrsObject(aPrsObject);
1293 // RecreateActor(aPrsObject);
1294 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1295 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1296 // vf->getRenderer()->ResetCameraClippingRange();
1300 // // Remove old Table
1301 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1302 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
1303 // if(!aSObject->_is_nil()) {
1304 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1305 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1306 // for ( ;aIter->More(); aIter->Next()) {
1307 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1308 // if (!aTblObj->_is_nil()) {
1309 // SALOMEDS::GenericAttribute_var anAttr;
1310 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1311 // aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
1316 // if (aDlg->isGenerateTable()) {
1317 // GetVisuGen()->CreateTable(aSObject->GetID());
1318 // if (aDlg->isGenerateCurves()) {
1319 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1320 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1321 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1322 // for ( ;aIter->More(); aIter->Next()) {
1323 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1324 // if (!aTblObj->_is_nil()) {
1325 // SALOMEDS::GenericAttribute_var anAttr;
1326 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1327 // CreatePlot(aTblObj);
1334 // GetActiveStudy()->updateObjBrowser();
1342 case VISU::TISOSURFACE: // Iso surfaces
1343 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1345 case VISU::TVECTORS: // Vectors 64
1346 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1349 case VISU::TSTREAMLINES:
1350 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1356 Handle(SALOME_InteractiveObject) anIO;
1357 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1358 if ( !CORBA::is_nil( anObject ) )
1359 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1360 vf->highlight(anIO, 1);
1364 //=====================================================================================
1365 // function : CreateMesh()
1367 //=====================================================================================
1368 void VisuGUI::CreateMesh() {
1369 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1370 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1372 if (checkLock(GetStudyDocument())) return;
1374 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1375 aSObj = aSObj->GetFather();
1376 aSObj = aSObj->GetFather();
1377 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1378 if(CORBA::is_nil(anObject)) {
1379 aSObj = aSObj->GetFather();
1380 anObject = VISU::SObjectToObject(aSObj);
1382 VISU::Result_var aResult;
1383 if (!CORBA::is_nil(anObject)) {
1384 aResult = VISU::Result::_narrow(anObject);
1386 if(CORBA::is_nil(aResult)) {
1387 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1388 tr ("WRN_NO_AVAILABLE_DATA"),
1389 tr ("VISU_BUT_OK"));
1392 VISU::Storable::TRestoringMap aMap;
1393 SALOMEDS::GenericAttribute_var anAttr;
1394 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1395 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1396 string aComm = aComment->Value();
1397 QString strIn(aComm.c_str());
1398 VISU::Storable::StrToMap(strIn,aMap);
1401 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1402 if(!isExist) return;
1403 CORBA::Object_var aMesh;
1404 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1409 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
1410 if(aComment == "ENTITY"){
1411 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1412 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1413 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1414 }else if(aComment == "FAMILY"){
1415 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1416 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1417 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1418 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1419 }else if(aComment == "GROUP"){
1420 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1421 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1422 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1426 MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
1430 QApplication::restoreOverrideCursor();
1431 VISU::Mesh_i* pPresent = NULL;
1432 if(!CORBA::is_nil(aMesh))
1433 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1434 if (pPresent == NULL) {
1435 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1436 tr ("ERR_CANT_BUILD_PRESENTATION"),
1437 tr ("VISU_BUT_OK") );
1441 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1443 VISU_Actor *anActor = pPresent->CreateActor();
1448 vf->AddActor(anActor);
1452 MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
1455 //GetActiveStudy()->updateObjBrowser(); //not necessary
1456 GetDesktop()->putInfo("Ready");
1457 }catch(std::runtime_error& exc){
1459 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1460 tr ("ERR_CANT_CREATE_ACTOR") + " " + tr(exc.what()),
1461 tr ("VISU_BUT_OK") );
1466 //=====================================================================================
1467 // function : CreateManyMesh()
1469 //=====================================================================================
1470 void VisuGUI::CreateManyMesh(){
1471 if (checkLock(GetStudyDocument())) return;
1473 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1474 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1475 for ( ; It.More(); It.Next() ) {
1476 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1477 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1478 aSObj = aSObj->GetFather();
1479 aSObj = aSObj->GetFather();
1480 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1481 if(CORBA::is_nil(anObject)) {
1482 aSObj = aSObj->GetFather();
1483 anObject = VISU::SObjectToObject(aSObj);
1484 if(CORBA::is_nil(anObject)) return;
1486 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1487 if(CORBA::is_nil(aResult)) return;
1489 VISU::Storable::TRestoringMap aMap;
1490 SALOMEDS::GenericAttribute_var anAttr;
1491 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1492 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1493 string aComm = aComment->Value();
1494 QString strIn(aComm.c_str());
1495 VISU::Storable::StrToMap(strIn,aMap);
1498 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1499 if(!isExist) return;
1500 CORBA::Object_var aMesh;
1501 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1502 if(aComment == "ENTITY"){
1503 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1504 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1505 }else if(aComment == "FAMILY"){
1506 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1507 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1508 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1509 }else if(aComment == "GROUP"){
1510 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1511 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1513 QApplication::restoreOverrideCursor();
1514 if(CORBA::is_nil(aMesh)) return;
1516 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1518 VISU_Actor *anActor = pPresent->CreateActor();
1519 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1520 vf->AddActor(anActor);
1523 GetDesktop()->putInfo("Ready");
1524 }catch(std::runtime_error& exc){
1530 //=====================================================================================
1531 // function : ChangeRepresentation()
1533 //=====================================================================================
1535 static void ShrinkMesh(VISU_Actor *theActor){
1536 if(theActor->IsShrunk())
1537 theActor->UnShrink();
1539 theActor->SetShrink();
1542 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1543 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1544 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1547 ShrinkMesh(anActor);
1550 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1551 aMesh->SetPresentationType(theType);
1552 RecreateActor(aMesh);
1554 anActor->SetRepresentation(theType);
1556 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1562 void VisuGUI::MakeSurfaceframe() {
1563 ChangeRepresentation(VISU::SURFACEFRAME);
1566 void VisuGUI::MakeInsideframe() {
1567 ChangeRepresentation(VISU::INSIDEFRAME);
1570 void VisuGUI::MakeWireframe() {
1571 ChangeRepresentation(VISU::WIREFRAME);
1574 void VisuGUI::MakeSurface() {
1575 ChangeRepresentation(VISU::SHADED);
1578 void VisuGUI::MakePoints() {
1579 ChangeRepresentation(VISU::POINT);
1582 void VisuGUI::MakeShrink() {
1583 ChangeRepresentation(VISU::SHRINK);
1588 //=====================================================================================
1589 // functions : Change Propertise
1591 //=====================================================================================
1592 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1593 CORBA::Object_var anObject = GetSelectedObj(theIO);
1594 if(CORBA::is_nil(anObject)) return NULL;
1595 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1596 if(!aServant.in()) return NULL;
1597 return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1600 void VisuGUI::ChageColor() {
1601 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1602 if(!aPrsObject) return;
1604 VISU_Actor* anActor = GetActor(aPrsObject);
1605 if (!anActor) return;
1609 void VisuGUI::ChangeWireframeColor() {
1610 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1611 if(!aPrsObject) return;
1613 VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1614 if (!anActor) return;
1615 NewWireframeColor(anActor);
1619 void VisuGUI::ChangeOpacity() {
1620 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1621 if(!aPrsObject) return;
1623 VISU_Actor* anActor = GetActor(aPrsObject);
1624 if (!anActor) return;
1625 NewOpacity(anActor);
1629 void VisuGUI::ChangeLines() {
1630 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1631 if(!aPrsObject) return;
1633 VISU_Actor* anActor = GetActor(aPrsObject);
1634 if (!anActor) return;
1635 NewLinewidth(anActor);
1637 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1639 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1640 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1641 if ( theDisplaying == VISU::eDisplayOnly )
1643 QList<Plot2d_Curve> clist;
1644 aPlot->getCurves( clist );
1645 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1646 if ( !TableSO->_is_nil() ) {
1647 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1648 for ( ; Iter->More(); Iter->Next() ) {
1649 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1650 if( !CORBA::is_nil( childObject ) ) {
1651 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1652 if( !CORBA::is_nil( aCurve ) ) {
1653 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1654 Plot2d_Curve* plotCurve = 0;
1655 for ( int i = 0; i < clist.count(); i++ ) {
1656 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1657 plotCurve = clist.at( i );
1661 if ( theDisplaying == VISU::eErase ) {
1663 aPlot->eraseCurve( plotCurve, false );
1664 clist.remove( plotCurve );
1667 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1669 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1670 //plotCurve->setVerTitle( theCurve->GetVerTitle().c_str() );
1671 plotCurve->setVerTitle( theCurve->GetName() );
1672 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1673 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1674 /* - DATA NOT UPDATED */
1677 int nbPoints = theCurve->GetData( xList, yList );
1678 if ( nbPoints > 0 && xList && yList ) {
1679 plotCurve->setData( xList, yList, nbPoints );
1681 if ( !theCurve->IsAuto() ) {
1682 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1683 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1684 SALOMEDS::Color color = theCurve->GetColor();
1685 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1687 plotCurve->setAutoAssign( theCurve->IsAuto() );
1688 aPlot->displayCurve( plotCurve, false );
1691 Plot2d_Curve* crv = theCurve->CreatePresentation();
1693 aPlot->displayCurve( crv, false );
1694 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1695 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1696 SALOMEDS::Color newColor;
1697 newColor.R = crv->getColor().red()/255.;
1698 newColor.G = crv->getColor().green()/255.;
1699 newColor.B = crv->getColor().blue()/255.;
1700 theCurve->SetColor( newColor );
1701 crv->setAutoAssign( theCurve->IsAuto() );
1712 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1714 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1715 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1716 // if ( theDisplaying == VISU::eDisplayOnly )
1717 // aPlot->EraseAll();
1718 QList<Plot2d_Curve> clist;
1719 aPlot->getCurves( clist );
1720 Plot2d_Curve* plotCurve = 0;
1721 for ( int i = 0; i < clist.count(); i++ ) {
1722 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1723 plotCurve = clist.at( i );
1725 else if ( theDisplaying == VISU::eDisplayOnly ) {
1726 aPlot->eraseCurve( clist.at( i ) );
1729 if ( theDisplaying == VISU::eErase ) {
1731 aPlot->eraseCurve( plotCurve, false );
1733 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1735 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1736 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1737 plotCurve->setVerTitle( theCurve->GetName() );
1738 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1739 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1742 int nbPoints = theCurve->GetData( xList, yList );
1743 if ( nbPoints > 0 && xList && yList ) {
1744 plotCurve->setData( xList, yList, nbPoints );
1746 if ( !theCurve->IsAuto() ) {
1747 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1748 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1749 SALOMEDS::Color color = theCurve->GetColor();
1750 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1752 plotCurve->setAutoAssign( theCurve->IsAuto() );
1753 aPlot->displayCurve( plotCurve, false );
1756 Plot2d_Curve* crv = theCurve->CreatePresentation();
1758 aPlot->displayCurve( crv, false );
1759 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1760 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1761 SALOMEDS::Color newColor;
1762 newColor.R = crv->getColor().red()/255.;
1763 newColor.G = crv->getColor().green()/255.;
1764 newColor.B = crv->getColor().blue()/255.;
1765 theCurve->SetColor( newColor );
1766 crv->setAutoAssign( theCurve->IsAuto() );
1773 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1775 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1776 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1777 if ( theDisplaying == VISU::eDisplayOnly )
1779 QList<Plot2d_Curve> clist;
1780 aPlot->getCurves( clist );
1781 if ( container->GetNbCurves() > 0 ) {
1782 int nbCurves = container->GetNbCurves();
1783 for ( int k = 1; k <= nbCurves; k++ ) {
1784 VISU::Curve_i* theCurve = container->GetCurve( k );
1785 if ( theCurve && theCurve->IsValid() ) {
1786 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( theCurve->GetEntry(), "", "" ) );
1787 // for ( int i = 0; i < clist.count(); i++ ) {
1788 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1789 // plotCurve = clist.at( i );
1793 if ( theDisplaying == VISU::eErase ) {
1795 aPlot->eraseCurve( plotCurve, false );
1796 clist.remove( plotCurve );
1799 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1801 plotCurve->setHorTitle( theCurve->GetHorTitle().c_str() );
1802 //plotCurve->setVerTitle( ( theCurve->GetVerTitle().c_str() ) );
1803 plotCurve->setVerTitle( theCurve->GetName() );
1804 plotCurve->setHorUnits( theCurve->GetHorUnits().c_str() );
1805 plotCurve->setVerUnits( theCurve->GetVerUnits().c_str() );
1808 int nbPoints = theCurve->GetData( xList, yList );
1809 if ( nbPoints > 0 && xList && yList ) {
1810 plotCurve->setData( xList, yList, nbPoints );
1812 if ( !theCurve->IsAuto() ) {
1813 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1814 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1815 SALOMEDS::Color color = theCurve->GetColor();
1816 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1818 plotCurve->setAutoAssign( theCurve->IsAuto() );
1819 aPlot->displayCurve( plotCurve, false );
1822 Plot2d_Curve* crv = theCurve->CreatePresentation();
1824 aPlot->displayCurve( crv, false );
1825 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1826 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1827 SALOMEDS::Color newColor;
1828 newColor.R = crv->getColor().red()/255.;
1829 newColor.G = crv->getColor().green()/255.;
1830 newColor.B = crv->getColor().blue()/255.;
1831 theCurve->SetColor( newColor );
1832 crv->setAutoAssign( theCurve->IsAuto() );
1844 Slot : opens Table view : for Table object or SObject with table attribute selected
1846 void VisuGUI::ShowTable() {
1847 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1848 if( Sel->IObjectCount() !=1 )
1850 Handle(SALOME_InteractiveObject) anIO;
1851 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1852 SALOMEDS::SObject_var SO;
1853 if ( !CORBA::is_nil( anObject ) ) {
1854 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1855 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1856 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1857 if( !CORBA::is_nil( aTable ) ) {
1858 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1860 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1865 // possibly this is Table SObject
1866 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1869 if(!IsSObjectTable(SO))
1872 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1875 //SAL2670 Orientation of show tables
1876 SALOMEGUI_TableDlg::ttAuto,
1883 Slot : opens Table view : for Table object or SObject with table attribute selected
1885 void VisuGUI::CreateTable() {
1886 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1887 if( aSel->IObjectCount() !=1 )
1890 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1891 if (anIO->hasEntry()){
1892 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1893 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1894 if(!aSObject->_is_nil()) {
1895 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1896 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1897 if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
1898 GetVisuGen()->CreateTable(aSObject->GetID());
1899 GetActiveStudy()->updateObjBrowser();
1907 Slot : deletes SObject with all subobjects
1909 void VisuGUI::DeleteObject() {
1910 SALOMEDS::Study_var aStudy = GetStudyDocument();
1911 if (checkLock(aStudy)) return;
1913 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1914 if( aSel->IObjectCount() !=1 )
1916 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1917 if (anIO->hasEntry()){
1918 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1919 if(!aSObject->_is_nil()){
1920 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1921 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1922 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1923 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1924 ::ErasePrs(aChildObj);
1926 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
1927 // There is a transaction
1928 aStudyBuilder->NewCommand();
1929 CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1930 if(!CORBA::is_nil(anObj)){
1931 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1932 if(!CORBA::is_nil(aBase)){
1933 VISU::VISUType aType = aBase->GetType();
1937 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1938 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1939 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1940 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1941 if(CORBA::is_nil(aChildObj)) continue;
1942 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1943 if(CORBA::is_nil(aPrs3d)) continue;
1944 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1945 DeletePresentation(pPrs3d);
1951 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1952 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1953 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1954 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1955 if(CORBA::is_nil(aChildObj)) continue;
1956 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( aChildObj );
1957 if(CORBA::is_nil(aCurve)) continue;
1958 VISU::Curve_i* pCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1959 DeletePresentation(pCurve);
1966 aStudyBuilder->RemoveObjectWithChildren(aSObject);
1967 aStudyBuilder->CommitCommand();
1968 GetActiveStudy()->unHighlightAll();
1969 GetActiveStudy()->updateObjBrowser(true);
1976 Slot : deletes empty container
1978 void VisuGUI::CreatePlot2dView() {
1979 if (checkLock(GetStudyDocument())) return;
1980 GetVisuGen()->CreateContainer();
1981 GetActiveStudy()->updateObjBrowser( true );
1987 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1989 void VisuGUI::PlotData() {
1990 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1991 if( Sel->IObjectCount() !=1 )
1993 CORBA::Object_var anObject = GetSelectedObj();
1994 SALOMEDS::SObject_var SO;
1995 if ( !CORBA::is_nil( anObject ) ) {
1996 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1997 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1998 // Table (VISU object) is selected
1999 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
2000 if( !CORBA::is_nil( aTbl ) ) {
2001 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
2003 SALOMEDS::GenericAttribute_var anAttr;
2004 SALOMEDS::AttributeName_var aName;
2006 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
2007 if ( IsSObjectTable(SO) ) {
2008 // get name of SObject
2009 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2010 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2011 SOName = aName->Value();
2013 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2014 if ( dlg->exec() == QDialog::Accepted ) {
2015 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2016 // if study is not locked - create new container, create curves
2017 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2019 QValueList<int> verIndices;
2020 dlg->getCurvesSource( horIndex, verIndices );
2021 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2022 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2023 if( !CORBA::is_nil( aContainer ) ) {
2024 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2026 for ( int i = 0; i < verIndices.count(); i++ ) {
2027 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
2028 if( !CORBA::is_nil( aNewCurve ) ) {
2029 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2032 int marker, line, lineWidth;
2034 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2035 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2036 pCrv->SetColor( c );
2037 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2038 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2040 pContainer->AddCurve( pCrv->_this() );
2044 GetActiveStudy()->updateObjBrowser( true );
2045 PlotContainer( pContainer, VISU::eDisplay );
2051 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2052 Plot2d_CurveContainer container;
2053 dlg->getCurves( container );
2054 if ( !container.isEmpty() ) {
2055 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2056 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2057 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2058 getRightFrame()->getViewFrame()))->setTitle( SOName );
2069 // possibly this is Table SObject
2070 SALOMEDS::GenericAttribute_var anAttr;
2071 SALOMEDS::AttributeName_var aName;
2074 // check if Table SObject is selected
2075 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2076 if ( IsSObjectTable(SO) ) {
2077 // get name of SObject
2078 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
2079 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2080 SOName = aName->Value();
2082 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
2083 if ( dlg->exec() == QDialog::Accepted ) {
2084 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2085 // if study is not locked - create new table and container objects, create curves
2086 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
2088 QValueList<int> verIndices;
2089 dlg->getCurvesSource( horIndex, verIndices );
2090 if ( horIndex >= 0 && verIndices.count() > 0 ) {
2091 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
2092 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2093 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2094 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2095 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2097 if ( pContainer && pTable ) {
2098 for ( int i = 0; i < verIndices.count(); i++ ) {
2099 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2100 if( !CORBA::is_nil( aNewCurve ) ) {
2101 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2104 int marker, line, lineWidth;
2106 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2107 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2108 pCrv->SetColor( c );
2109 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2110 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2112 pContainer->AddCurve( pCrv->_this() );
2116 GetActiveStudy()->updateObjBrowser( true );
2117 PlotContainer( pContainer, VISU::eDisplay );
2122 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2123 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2124 Plot2d_CurveContainer container;
2125 dlg->getCurves( container );
2126 if ( !container.isEmpty() ) {
2127 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2128 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2129 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2130 getRightFrame()->getViewFrame()))->setTitle( SOName );
2141 void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
2142 SALOMEDS::GenericAttribute_var anAttr;
2143 SALOMEDS::AttributeName_var aName;
2145 if ( IsSObjectTable(theTableSO) ) {
2146 CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
2147 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2148 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2149 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
2150 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
2152 if ( pContainer && pTable ) {
2153 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
2154 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
2155 if( !CORBA::is_nil( aNewCurve ) ) {
2156 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
2158 pContainer->AddCurve( pCrv->_this() );
2162 GetActiveStudy()->updateObjBrowser( true );
2163 PlotContainer( pContainer, VISU::eDisplay );
2171 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2173 void VisuGUI::CurveProperties() {
2174 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2175 if( Sel->IObjectCount() !=1 )
2177 CORBA::Object_var anObject = GetSelectedObj();
2178 SALOMEDS::SObject_var SO;
2179 if (CORBA::is_nil( anObject )) return;
2181 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2182 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2184 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2185 if( !CORBA::is_nil( aCurve ) ) {
2186 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2187 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2188 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
2189 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2190 dlg->setMarker( (int)curve->GetMarker() );
2191 SALOMEDS::Color color = curve->GetColor();
2192 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2193 if( dlg->exec() == QDialog::Accepted ) {
2194 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2195 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2196 SALOMEDS::Color newColor;
2197 newColor.R = dlg->getColor().red()/255.;
2198 newColor.G = dlg->getColor().green()/255.;
2199 newColor.B = dlg->getColor().blue()/255.;
2200 curve->SetColor( newColor );
2201 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2202 if ( sfList.count() > 0 ) {
2203 QListIterator<QAD_StudyFrame> it( sfList );
2204 for ( ; it.current(); ++it ) {
2205 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2206 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2207 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2210 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2212 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2213 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2214 plotCurve->setColor( dlg->getColor() );
2215 aPlot->updateCurve( plotCurve, true );
2228 Slot : Clears container contents : for Container object selected
2230 void VisuGUI::ClearContainer() {
2231 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2232 if( Sel->IObjectCount() !=1 )
2235 CORBA::Object_var anObject = GetSelectedObj();
2236 SALOMEDS::SObject_var SO;
2237 if (CORBA::is_nil( anObject )) return;
2239 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2240 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2242 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2243 if( !CORBA::is_nil( aCnt ) ) {
2244 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2245 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2247 GetActiveStudy()->updateObjBrowser();
2254 Slot : Edit container contents : for Container object selected
2256 void VisuGUI::EditContainer() {
2257 CORBA::Object_var anObject = GetSelectedObj();
2258 if(CORBA::is_nil(anObject)) return;
2259 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
2260 if(!aServant.in()) return;
2261 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
2262 if(!aContainer) return;
2264 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
2265 aDlg->initFromPrsObject(aContainer);
2267 aDlg->storeToPrsObject(aContainer);
2268 GetActiveStudy()->updateObjBrowser( true );
2274 void VisuGUI::DeletePrs() {
2275 SALOMEDS::Study_var aStudy = GetStudyDocument();
2276 if (checkLock(aStudy)) return;
2278 // There is a transaction
2279 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
2280 aStudyBuilder->NewCommand();
2282 CORBA::Object_var anObject = GetSelectedObj();
2283 if ( !CORBA::is_nil( anObject ) ) {
2284 // is it Prs3d object ?
2285 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2287 DeletePresentation(aPrsObject);
2288 // is it Curve object ?
2289 VISU::Curve_i* aCurveObject = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
2291 DeletePresentation(aCurveObject);
2293 aStudyBuilder->CommitCommand();
2297 void VisuGUI::SaveViewParams()
2299 if (checkLock(GetStudyDocument())) return;
2300 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2301 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2302 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2304 if ( aSel->IObjectCount() == 0 ) {
2305 VISU::View3D_i::SaveViewParams(aStudyFrame,VISU::View3D_i::GenerateViewParamsName().latin1());
2307 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2308 VISU::View3D_i::SaveViewParams(aStudyFrame,anIO->getName());
2310 GetActiveStudy()->updateObjBrowser( true );
2314 void VisuGUI::RestoreViewParams()
2316 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2317 QAD_StudyFrame* aStudyFrame = GetActiveStudy()->getActiveStudyFrame();
2318 if ( aSel->IObjectCount() > 1 || aStudyFrame->getTypeView() != VIEW_VTK )
2320 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
2321 VISU::View3D_i::RestoreViewParams(aStudyFrame,anIO->getName());
2325 //=====================================================================================
2326 // function : DeleteViewParams()
2328 //=====================================================================================
2329 void VisuGUI::DeleteViewParams() {
2331 VISU::Storable::TRestoringMap aMap;
2332 Handle(SALOME_InteractiveObject) anIO;
2333 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2334 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2335 if(isExist && aType == VISU::TVIEW3D){
2336 SALOMEDS::Study_var aStudy = GetStudyDocument();
2337 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2338 aStudy->NewBuilder()->RemoveObject(aSObject);
2340 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2341 aSel->RemoveIObject(anIO, 0);
2343 GetActiveStudy()->updateObjBrowser( true );
2348 //=====================================================================================
2349 // function : Sweep()
2351 //=====================================================================================
2352 void VisuGUI::Sweep() {
2353 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2354 if (!aPrsObject) return;
2356 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2360 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2361 if ( !aTempoStr.isEmpty() )
2362 aTemp = int(1.E6*(aTempoStr.toFloat()));
2365 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2366 if ( !aCyclesStr.isEmpty() )
2367 aCycles = aCyclesStr.toInt();
2370 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2371 if ( !aStepsStr.isEmpty() )
2372 aSteps = aStepsStr.toInt();
2374 VISU_Actor* aActor = GetActor(aPrsObject);
2375 if (!aActor) return;
2377 if (!aActor->GetVisibility()) {
2378 aActor->VisibilityOn();
2381 QApplication::setOverrideCursor( Qt::waitCursor );
2383 for (int j=0 ; j<aCycles; j++) {
2384 for (int i=0 ; i<=aSteps; i++) {
2385 float aPercents = float(i)/aSteps;
2386 aPrsObject->SetMapScale(aPercents);
2387 aPrsObject->UpdateActor(aActor);
2388 vf->getRW()->getRenderWindow()->Render();
2392 }catch(std::exception& exc){
2393 INFOS("Follow exception was occured :\n"<<exc.what());
2395 INFOS("Unknown exception was occured!");
2397 QApplication::restoreOverrideCursor();
2402 void VisuGUI::TimeAnimation() {
2403 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2404 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2406 bool isDefined = false;
2408 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2409 for (; It.More(); It.Next()) {
2410 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2411 if (aSObject->_is_nil()) continue;
2412 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2413 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2417 aAnimationDlg->addField(aSObject);
2419 } else if (aNbTimes == aNumber) {
2420 aAnimationDlg->addField(aSObject);
2425 if (isDefined) aAnimationDlg->show();
2426 else delete aAnimationDlg;
2430 void VisuGUI::ImportMedField() {
2431 if (checkLock(GetStudyDocument())) return;
2432 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2433 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2434 QApplication::setOverrideCursor( Qt::waitCursor );
2435 for(;It.More();It.Next()) {
2436 Handle(SALOME_InteractiveObject) anIO = It.Value();
2437 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2438 if(!aSObject->_is_nil()){
2439 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2440 if(!CORBA::is_nil(anObject)){
2441 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2442 if(!CORBA::is_nil(aMED.in()))
2443 GetVisuGen()->ImportMed( aSObject );
2444 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2445 if(!CORBA::is_nil(aField.in()))
2446 GetVisuGen()->ImportMedField( aField );
2448 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2449 SALOMEDS::GenericAttribute_var anAttr;
2450 aSFather->FindAttribute(anAttr, "AttributeName");
2451 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2452 CORBA::String_var aValue = aName->Value();
2453 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2454 GetVisuGen()->ImportMed(aSObject);
2455 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2456 // VisuGUI::myComponent->ImportMed(aSObject);
2460 GetActiveStudy()->updateObjBrowser( true );
2461 QApplication::restoreOverrideCursor();
2464 //=====================================================================================
2465 // functions : Rename()
2467 //=====================================================================================
2468 void VisuGUI::Rename() {
2469 if (checkLock(GetStudyDocument())) return;
2470 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2471 if ( Sel->IObjectCount() != 1 )
2473 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2474 if( aSObj->_is_nil() ) return;
2476 VISU::Curve_i* curve = 0;
2477 CORBA::Object_var anObject = GetSelectedObj();
2478 if ( !CORBA::is_nil( anObject )) {
2479 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2480 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2482 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2483 if( !CORBA::is_nil( aCurve ) ) {
2484 curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2489 //TEST DU PARENT == VISU
2490 SALOMEDS::GenericAttribute_var anAttr;
2491 SALOMEDS::AttributeName_var aName;
2492 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2493 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2494 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2495 if ( !Name.isEmpty() ) {
2496 QApplication::setOverrideCursor( Qt::waitCursor );
2498 curve->SetName( Name.latin1() );
2499 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2500 QApplication::restoreOverrideCursor();
2502 //int TypeMode; bool InViewer;
2503 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2504 //ActorTmp->setName((Standard_CString)Name.latin1());
2509 //=====================================================================================
2510 // functions : RenameTable()
2512 //=====================================================================================
2513 void VisuGUI::RenameTable() {
2514 if (checkLock(GetStudyDocument())) return;
2515 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2516 if ( Sel->IObjectCount() != 1 )
2518 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2519 if( aSObj->_is_nil() ) return;
2521 VISU::Table_i* table = 0;
2522 CORBA::Object_var anObject = GetSelectedObj();
2523 if ( !CORBA::is_nil( anObject )) {
2524 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2525 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2527 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2528 if( !CORBA::is_nil( aTable ) ) {
2529 table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2534 //TEST DU PARENT == VISU
2535 SALOMEDS::GenericAttribute_var anAttr;
2536 SALOMEDS::AttributeName_var aName;
2537 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2538 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2539 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2540 if ( !Name.isEmpty() ) {
2541 QApplication::setOverrideCursor( Qt::waitCursor );
2543 table->SetName( Name.latin1() );
2544 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2545 QApplication::restoreOverrideCursor();
2547 //int TypeMode; bool InViewer;
2548 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2549 //ActorTmp->setName((Standard_CString)Name.latin1());
2556 //=====================================================================================
2557 // functions : RenameContainer()
2559 //=====================================================================================
2560 void VisuGUI::RenameContainer() {
2561 if (checkLock(GetStudyDocument())) return;
2562 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2563 if ( Sel->IObjectCount() != 1 )
2565 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2566 if( aSObj->_is_nil() ) return;
2568 VISU::Container_i* container = 0;
2569 CORBA::Object_var anObject = GetSelectedObj();
2570 if ( !CORBA::is_nil( anObject )) {
2571 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2572 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2574 CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2575 if( !CORBA::is_nil( aContainer ) ) {
2576 container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2581 //TEST DU PARENT == VISU
2582 SALOMEDS::GenericAttribute_var anAttr;
2583 SALOMEDS::AttributeName_var aName;
2584 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2585 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2586 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2587 if ( !Name.isEmpty() ) {
2588 QApplication::setOverrideCursor( Qt::waitCursor );
2590 container->SetName( Name.latin1() );
2591 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2592 QApplication::restoreOverrideCursor();
2594 //int TypeMode; bool InViewer;
2595 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2596 //ActorTmp->setName((Standard_CString)Name.latin1());
2603 //=====================================================================================
2604 // function : CopyPresentation()
2606 //=====================================================================================
2607 void VisuGUI::CopyPresentation(){
2608 if (checkLock(GetStudyDocument())) return;
2609 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2610 if (!aPrsObject) return;
2611 switch (aPrsObject->GetType()) {
2614 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2615 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2616 aSameMesh->SameAs(aMeshPrs);
2617 UpdateViewer(aSameMesh);
2620 case VISU::TSCALARMAP:
2622 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2623 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2624 aSameScalar->SameAs(aScalarPrs);
2625 UpdateViewer(aSameScalar);
2628 case VISU::TDEFORMEDSHAPE:
2630 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2631 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2632 aSameDeformed->SameAs(aDefPrs);
2633 UpdateViewer(aSameDeformed);
2636 case VISU::TCUTPLANES:
2638 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2639 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2640 aSameCut->SameAs(aCutPrs);
2641 UpdateViewer(aSameCut);
2644 case VISU::TCUTLINES:
2646 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2647 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2648 aSameCut->SameAs(aCutPrs);
2649 UpdateViewer(aSameCut);
2652 case VISU::TISOSURFACE:
2654 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2655 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2656 aSameIso->SameAs(aIsoPrs);
2657 UpdateViewer(aSameIso);
2660 case VISU::TSTREAMLINES:
2662 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2663 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2664 aSameLines->SameAs(aLinesPrs);
2665 UpdateViewer(aSameLines);
2668 case VISU::TVECTORS:
2670 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2671 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2672 aSameVectors->SameAs(aVectorsPrs);
2673 UpdateViewer(aSameVectors);
2677 GetActiveStudy()->updateObjBrowser();
2682 //=====================================================================================
2683 // function : DefinePopup()
2685 //=====================================================================================
2686 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2693 //=====================================================================================
2694 // function : checkHomoSelection()
2696 //=====================================================================================
2697 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2698 int VisuGUI::checkHomoSelection()
2700 int selMode = homoNone;
2701 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2702 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2703 for ( ; It.More(); It.Next() ) {
2704 int selNext = homoOther;
2705 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2706 if ( anIO->hasEntry() ) {
2707 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2708 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2709 VISU::Storable::TRestoringMap pMap;
2710 if( !aSObject->_is_nil() ) {
2711 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2712 if ( !CORBA::is_nil( aCORBAObject ) ) {
2713 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2714 if ( !CORBA::is_nil( aVisuObj ) ) {
2715 VISU::VISUType aType = aVisuObj->GetType();
2719 case VISU::TCONTAINER:
2720 selNext = homoCurves; break;
2722 case VISU::TSCALARMAP:
2723 case VISU::TISOSURFACE:
2724 case VISU::TDEFORMEDSHAPE:
2725 case VISU::TCUTPLANES:
2726 case VISU::TCUTLINES:
2727 case VISU::TVECTORS:
2728 case VISU::TSTREAMLINES:
2729 selNext = homoPresentations; break;
2731 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2732 selNext = homoAnimatable; break;
2734 selNext = homoOther; break;
2736 selNext = homoOther;
2741 SALOMEDS::GenericAttribute_var anAttr;
2742 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2743 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2744 string aComm = aComment->Value();
2745 QString strIn( aComm.c_str() );
2746 VISU::Storable::StrToMap( strIn, pMap );
2748 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2754 selNext = homoPresentable; break;
2756 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2757 selNext = homoAnimatable; break;
2759 selNext = homoOther; break;
2761 selNext = homoOther;
2768 if ( selMode == homoNone )
2771 if ( selMode != selNext )
2778 //=====================================================================================
2779 // function : GetNbChildren() [ static ]
2780 // purpose : get number of children
2781 //=====================================================================================
2782 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2784 if ( SO->_is_nil() )
2787 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2788 for ( ; Iter->More(); Iter->Next() ) {
2789 SALOMEDS::SObject_var refSO;
2790 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2796 //=====================================================================================
2797 // function : CustomPopup()
2799 //=====================================================================================
2800 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2801 const QString & theParent, const QString & theObject)
2803 int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2804 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2806 bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
2808 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2809 SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2810 QString aParentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
2811 int nbSel = aSelection->IObjectCount();
2816 if ( theParent == "Viewer" && isVTKViewer && !aIsLocked)
2817 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2821 int selMode = checkHomoSelection();
2822 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2823 if ( selMode == homoCurves ) {
2824 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2825 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2826 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2827 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2830 else if ( selMode == homoPresentations ) {
2832 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2833 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2836 else if ( selMode == homoPresentable ) {
2837 if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2839 else if ( selMode == homoAnimatable ) {
2840 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2844 VISU::Storable::TRestoringMap aMap;
2845 Handle(SALOME_InteractiveObject) anIO;
2846 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2847 if (!CORBA::is_nil(anObject)) {
2848 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2849 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2850 if (!CORBA::is_nil(aVisuObj)) {
2851 VISU::VISUType aType = aVisuObj->GetType();
2852 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2854 case VISU::TVISUGEN:
2855 thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
2856 thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
2857 thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
2861 if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
2865 if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2866 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2867 if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2868 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
2869 thePopup->insertSeparator();
2870 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2871 if ( GetNbChildren( aSObject, false ) > 0 ) {
2872 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2873 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2874 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2877 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2882 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2883 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2885 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2886 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2887 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2889 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2890 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2892 if ( !aIsLocked ) thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2895 case VISU::TCONTAINER:
2896 // if( !CORBA::is_nil( anObject ) ) {
2897 // CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2898 // if( !CORBA::is_nil( aCnt ) ) {
2899 // VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2900 // if ( container ) {
2901 // if ( !aIsLocked ) {
2902 // thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2903 // thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2904 // if (container->GetNbCurves() > 0)
2905 // thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2907 // if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2908 // thePopup->insertSeparator();
2909 // thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2910 // thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2911 // thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2917 thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2918 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2919 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2921 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2922 thePopup->insertSeparator();
2923 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2924 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2925 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2927 if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2930 default: // Presentation
2932 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2935 // Add Presentation menu
2936 if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2937 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2938 int aRepresent = anVISUActor->GetRepresentation();
2941 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2942 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2943 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2944 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2945 if (aType == VISU::TMESH)
2946 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2948 case VISU::WIREFRAME :
2949 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2950 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2951 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2952 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2953 if (aType == VISU::TMESH)
2954 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2957 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2958 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2959 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2960 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2961 if (aType == VISU::TMESH)
2962 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2964 case VISU::INSIDEFRAME :
2965 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2966 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2967 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2968 if (aType == VISU::TMESH)
2969 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2971 case VISU::SURFACEFRAME :
2972 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2973 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2974 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2975 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2978 if(anVISUActor->IsShrunkable())
2979 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2980 if (anVISUActor->IsShrunk())
2981 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2983 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2985 thePopup->insertItem("Representation", aPresMenu);
2988 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2989 if(aType == VISU::TMESH){
2990 if(aRepresent == VISU::SURFACEFRAME){
2991 aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2992 aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2994 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2995 }else if(aType == VISU::TDEFORMEDSHAPE)
2996 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2998 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2999 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
3000 if (aType != VISU::TVECTORS){
3001 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
3002 thePopup->insertItem("Properties", aPropMenu);
3004 thePopup->insertSeparator();
3007 if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
3008 if (aType != VISU::TMESH) {
3009 //if (aType != VISU::TSCALARMAP)
3010 if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
3012 if (aType == VISU::TCUTLINES) {
3013 // Check: Does it has living children (tables)
3014 SALOMEDS::ChildIterator_var aIter =
3015 GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
3016 bool isPresent = false;
3017 for ( ;aIter->More(); aIter->Next()) {
3018 SALOMEDS::SObject_var aTblObj = aIter->Value();
3019 isPresent = !aTblObj->_is_nil();
3021 SALOMEDS::GenericAttribute_var anAttr;
3022 isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
3023 if (isPresent) break; // We have at least a one child
3026 if ((!isPresent) && (!aIsLocked) )
3027 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
3029 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
3033 if ( theParent == "Viewer" &&
3034 ( aType == VISU::TMESH ||
3035 aType == VISU::TSCALARMAP ||
3036 aType == VISU::TDEFORMEDSHAPE ) ) {
3037 thePopup->insertSeparator();
3038 thePopup->insertItem("Selection info...", visuGUI, SLOT(SelectionInfo()));
3040 thePopup->insertSeparator();
3042 if (visuGUI->IsDisplayed(aPrsObject) ){
3043 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
3046 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
3048 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
3050 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
3051 if ((aType != VISU::TMESH) && (!aIsLocked)) {
3052 thePopup->insertSeparator();
3053 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
3062 // possibly this is the MED field/mesh and support objects
3063 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
3064 if(!CORBA::is_nil(aMED))
3065 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
3066 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
3067 if(!CORBA::is_nil(aField))
3068 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
3069 if ( aParentComponent != parent->getActiveComponent() ) {
3070 //insert pre-defined Display/Erase items
3071 if ( thePopup->count() > 0 ) {
3072 thePopup->insertSeparator();
3074 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3075 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3076 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3081 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
3082 if(!aSObject->_is_nil()){
3084 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
3090 if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3093 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK )
3094 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3096 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3097 // Available only for VTK viewer
3098 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3100 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3101 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3105 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
3106 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3108 case VISU::TTIMESTAMP: {
3109 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3110 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
3111 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3112 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
3113 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3114 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
3115 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3116 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
3117 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
3118 if(aNunComponent > 1){
3119 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
3120 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3121 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
3122 "Vectors...", visuGUI, SLOT(CreateVectors()));
3123 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
3124 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3132 if(IsSObjectTable(aSObject)){
3133 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
3134 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
3135 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
3136 thePopup->insertSeparator();
3137 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3141 CORBA::Long aTag = 1;
3142 SALOMEDS::SObject_var aSubObject;
3143 if(aSObject->FindSubObject(aTag,aSubObject) && IsSObjectTable(aSubObject)) {
3144 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
3148 aSObject = aSObject->GetFather();
3149 if(aSObject->_is_nil()) return false;
3150 SALOMEDS::GenericAttribute_var anAttr;
3151 aSObject->FindAttribute(anAttr, "AttributeName");
3152 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
3153 if(aName->_is_nil()) return false;
3154 CORBA::String_var aValue = aName->Value();
3155 //if(strcmp(aValue.in(),"MEDMESH") == 0)
3156 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
3157 if(strcmp(aValue.in(),"MEDFIELD") == 0)
3158 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
3159 if ( aParentComponent != parent->getActiveComponent() ) {
3160 //insert pre-defined Display/Erase items
3161 if ( thePopup->count() > 0 ) {
3162 thePopup->insertSeparator();
3164 thePopup->insertItem (tr ("MEN_APP_DISPLAY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_Display_Popup_ID);
3165 thePopup->insertItem (tr ("MEN_APP_DISPLAY_ONLY"), GetActiveStudy()->getApp(), SLOT(onDisplay(int)), 0, QAD_DisplayOnly_Popup_ID);
3166 thePopup->insertItem (tr ("MEN_APP_ERASE"), GetActiveStudy()->getApp(), SLOT(onErase()), 0, QAD_Erase_Popup_ID);
3175 //===========================================================================
3176 // BuildPresentation
3177 //===========================================================================
3178 void VisuGUI::BuildPresentation( const Handle(SALOME_InteractiveObject)& theIO,
3181 BEGIN_OF("VisuGUI::BuildPresentation");
3183 if (theIO.IsNull()) {
3184 if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3188 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3189 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3191 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK &&
3192 GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_PLOT2D) return;
3194 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3196 if (aSObj -> _is_nil() ) {
3197 if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3201 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3202 if(!CORBA::is_nil(anObject)) {
3203 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
3205 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3206 if(!SelectedActor) {
3208 SelectedActor = aPrsObject -> CreateActor();
3209 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3210 vf->AddActor(SelectedActor);
3211 }catch(std::runtime_error& exc){
3217 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
3220 PlotTable(aTable, VISU::eDisplay );
3222 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
3225 PlotContainer(aContainer, VISU::eDisplay );
3227 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
3230 PlotCurve(aCurve, VISU::eDisplay );
3233 if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3234 END_OF("VisuGUI::BuildPresentation");
3238 //===========================================================================
3239 // SupportedViewType
3240 //===========================================================================
3241 void VisuGUI::SupportedViewType(int* buffer, int bufferSize)
3243 if (!buffer || !bufferSize) return;
3244 buffer[0] = (int)VIEW_VTK;
3245 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3250 Standard_EXPORT SALOMEGUI* GetComponentGUI() {
3252 visuGUI = new VisuGUI( "" );
3258 //////////////////////////////////////////////////////////////////////////////////
3259 //////////////// CHANGE ACTOR COLOR ////////////////////////
3260 //////////////////////////////////////////////////////////////////////////////////
3261 ///////////////// /////////////////////////////////////////////////////////////////
3262 // change actor color
3263 // In : Name of Actor
3267 void VisuGUI::NewColor(VISU_Actor *theActor){
3268 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3269 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3270 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3271 SALOMEDS::Color anOldColor, aNewColor;
3272 int aRepresent = theActor->GetRepresentation();
3276 anOldColor = aMesh->GetNodeColor();
3278 case VISU::WIREFRAME :
3279 case VISU::INSIDEFRAME :
3280 anOldColor = aMesh->GetLinkColor();
3283 case VISU::SURFACEFRAME :
3284 anOldColor = aMesh->GetCellColor();
3287 else if(aDeformedShape)
3288 anOldColor = aDeformedShape->GetColor();
3291 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3292 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3293 if(aColorNew.isValid()){
3294 aNewColor.R = aColorNew.red()/255.;
3295 aNewColor.G = aColorNew.green()/255.;
3296 aNewColor.B = aColorNew.blue()/255.;
3300 aMesh->SetNodeColor(aNewColor);
3302 case VISU::WIREFRAME :
3303 case VISU::INSIDEFRAME :
3304 aMesh->SetLinkColor(aNewColor);
3307 case VISU::SURFACEFRAME :
3308 aMesh->SetCellColor(aNewColor);
3312 aDeformedShape->SetColor(aNewColor);
3313 RecreateActor(aPrs3d);
3318 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3319 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3320 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3321 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3322 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3323 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3324 if(aColorNew.isValid()){
3325 aNewColor.R = aColorNew.red()/255.;
3326 aNewColor.G = aColorNew.green()/255.;
3327 aNewColor.B = aColorNew.blue()/255.;
3328 aMesh->SetLinkColor(aNewColor);
3329 VisuGUI::RecreateActor(aMesh);
3335 //////////////////////////////////////////////////////////////////////////////////
3336 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3337 //////////////////////////////////////////////////////////////////////////////////
3338 //////////////////////////////////////////////////////////////////////////////////
3339 // change actor opacity
3340 // In : Name of Actor
3342 // Use CursorDlg to select a value between 0 and 100
3345 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3348 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3350 float oldopac,newopac;
3352 CursorDlg->Comment1->setText( tr( "Set value between") );
3353 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3354 oldopac=Actor->GetOpacity();
3355 intopac=int(oldopac*100.+0.5);
3356 CursorDlg->SpinBox1->setMinValue(0);
3357 CursorDlg->SpinBox1->setMaxValue(100);
3358 CursorDlg->SpinBox1->setValue(intopac);
3360 int ret = CursorDlg->exec();
3363 intopac = CursorDlg->SpinBox1->value() ;
3364 newopac = intopac/100.;
3365 Actor->SetOpacity(newopac);
3370 //////////////////////////////////////////////////////////////////////////////////
3371 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3372 //////////////////////////////////////////////////////////////////////////////////
3373 //////////////////////////////////////////////////////////////////////////////////
3374 // change actor linewidth
3375 // In : Name of Actor
3377 // Use CursorDlg to select a value between 0 and 10
3380 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3383 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3385 float oldlwid,newlwid;
3387 CursorDlg->Comment1->setText("Set value between");
3388 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3389 oldlwid=Actor->GetLineWidth();
3390 intlwid=int(oldlwid);
3391 CursorDlg->SpinBox1->setMinValue(1);
3392 CursorDlg->SpinBox1->setMaxValue(10);
3393 CursorDlg->SpinBox1->setValue(intlwid);
3395 int ret = CursorDlg->exec();
3397 intlwid = CursorDlg->SpinBox1->value() ;
3399 Actor->SetLineWidth(newlwid);
3404 /* ======================================================================================== */
3405 /* Setting parameters for Scalar Bar */
3406 /* ======================================================================================== */
3407 void VisuGUI::ChangeScalarBar()
3409 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3410 Scbar->initFromResources();
3411 int ret = Scbar->exec();
3413 Scbar->storeToResources();
3418 /* ======================================================================================== */
3419 /* Setting parameters for Sweeping */
3420 /* ======================================================================================== */
3421 void VisuGUI::SetSweepingPreferences()
3427 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3428 if ( !Tempo.isEmpty() )
3429 tempo = Tempo.toFloat();
3431 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3432 if ( !Cycles.isEmpty() )
3433 cycles = Cycles.toInt();
3435 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3436 if ( !Steps.isEmpty() )
3437 steps = Steps.toInt();
3439 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3441 Sweep->setTimeStep( tempo );
3442 Sweep->setNbCycles( cycles );
3443 Sweep->setNbSteps ( steps );
3445 if ( Sweep->exec() )
3447 tempo = Sweep->getTimeStep();
3448 cycles = Sweep->getNbCycles();
3449 steps = Sweep->getNbSteps();
3451 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3452 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3453 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3458 /* ======================================================================================== */
3459 /* Returns Visu input files directory (default is CSF_PATHData) */
3460 /* ======================================================================================== */
3461 QString VisuGUI::getVisuInputDir()
3463 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3464 if ( Tmp.isEmpty() )
3465 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3466 Tmp = QAD_Tools::addSlash(Tmp);
3470 /* ======================================================================================== */
3471 /* Returns Visu output files directory (default is InputDir) */
3472 /* ======================================================================================== */
3473 QString VisuGUI::getVisuOutputDir()
3475 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3476 if ( Tmp.isEmpty() )
3478 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3479 if ( Tmp2.isEmpty() )
3480 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3484 Tmp = QAD_Tools::addSlash(Tmp);
3489 /* ======================================================================================== */
3490 /* Global Method for Scalar Map */
3491 /* ======================================================================================== */
3492 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3493 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3494 SALOMEDS::SObject_var aSObj = theField->GetFather();
3495 if (CORBA::is_nil(aSObj)) return NULL;
3496 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3497 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3498 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3499 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3500 if(CORBA::is_nil(anObject)) return NULL;
3501 theResult = VISU::Result::_narrow(anObject);
3502 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
3504 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3505 tr ("WRN_NO_AVAILABLE_DATA"),
3506 tr ("VISU_BUT_OK"));
3510 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3511 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3512 const char* theMeshName, VISU::Entity theEntity, \
3513 const char* theFieldName, int theTimeId) {\
3514 VISU::Result_var aResult; \
3515 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3516 if(pResult != NULL){ \
3517 QApplication::setOverrideCursor( Qt::waitCursor ); \
3518 CORBA::Object_var anObject = \
3519 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3520 QApplication::restoreOverrideCursor(); \
3521 if(!CORBA::is_nil(anObject)) \
3522 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
3524 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3525 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3526 tr ("VISU_BUT_OK") ); \
3530 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3531 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3532 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3533 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3534 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3535 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3536 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3539 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3540 bool FNAME(SALOMEDS::SObject_var theField) { \
3541 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3543 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3544 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3545 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3546 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3547 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3548 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3549 Utils_Timer timer; \
3550 if(MYCHECKTIME) timer.Start(); \
3551 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3554 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \
3558 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3559 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3560 DLGNAME* aDlg = new DLGNAME(); \
3561 aDlg->initFromPrsObject(pPresent); \
3562 if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
3565 DeletePresentation(pPresent); \
3571 CreateActor(pPresent); \
3579 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3580 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3581 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3582 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3583 //BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3584 //BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3585 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3588 bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
3590 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3592 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3593 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3594 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3595 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3596 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3597 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3599 if(MYCHECKTIME) timer.Start();
3600 VISU::CutPlanes_i* pPresent =
3601 CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
3604 MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT");
3608 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3609 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3610 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
3611 aDlg->initFromPrsObject(pPresent);
3613 myActiveDialogBox = aDlg;
3614 // if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
3617 // DeletePresentation(pPresent);
3622 // CreateActor(pPresent);
3626 }catch (...){return false;}
3630 bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
3632 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3634 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3635 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3636 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3637 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3638 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3639 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3641 if(MYCHECKTIME) timer.Start();
3642 VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
3643 (VISU::Entity)anEntity.toInt(),
3644 aFieldName,aTimeStampId.toInt());
3647 MESSAGE("BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT");
3651 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3652 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3653 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true);
3654 aDlg->initFromPrsObject(pPresent);
3656 myActiveDialogBox = aDlg;
3658 // if (aDlg->exec()) {
3659 // aDlg->storeToPrsObject(pPresent);
3660 // if (aDlg->isGenerateTable()) {
3661 // GetVisuGen()->CreateTable(pPresent->GetEntry());
3662 // if (aDlg->isGenerateCurves()) {
3663 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3664 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
3665 // if(!aSObject->_is_nil()) {
3666 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
3667 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
3668 // for ( ;aIter->More(); aIter->Next()) {
3669 // SALOMEDS::SObject_var aTblObj = aIter->Value();
3670 // if (!aTblObj->_is_nil()) {
3671 // SALOMEDS::GenericAttribute_var anAttr;
3672 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
3673 // CreatePlot(aTblObj);
3679 // GetActiveStudy()->updateObjBrowser();
3682 // DeletePresentation(pPresent);
3688 // CreateActor(pPresent);
3692 }catch (...){return false; }
3698 /* ======================================================================================== */
3699 /* Global Method to import tables from file */
3700 /* ======================================================================================== */
3701 void VisuGUI::ImportTablesFromFile(){
3702 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3704 flt.append( "Files (*.xls *.txt *.tab)" );
3705 flt.append( "All Files (*.*)" );
3706 QString aDir = getVisuInputDir();
3707 QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3708 aDir,flt,tr("Import From File"),true);
3710 if(aFileInfo.exists()){
3711 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3712 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3713 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3716 CORBA::Object_var anObject;
3722 anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3726 MESSAGE("VisuGUI::ImportTablesFromFile() - IMPORT FILE");
3730 if(CORBA::is_nil(anObject)) {
3732 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3733 tr ("ERR_ERROR_IN_THE_FILE"),
3734 tr ("VISU_BUT_OK") );
3738 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3740 GetActiveStudy()->updateObjBrowser(); //update Object browser
3744 void VisuGUI::ExportTableToFile()
3746 QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
3747 SALOME_Selection* aSel = SALOME_Selection::Selection ( aQADStudy -> getSelection() );
3749 if( aSel->IObjectCount() > 0 ) {
3750 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
3751 if(anIO->hasEntry()){
3752 SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
3753 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
3754 if(CORBA::is_nil(aSObj)) return;
3757 SALOMEDS::GenericAttribute_var anAttr;
3759 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3760 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
3761 aSObj = aSObj->GetFather(); //if the current SObject is a table title
3762 // we take a father contaning the table
3763 if (!CORBA::is_nil(aSObj)) {
3764 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3765 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
3770 if (CORBA::is_nil(anAttr)) return;
3772 SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
3773 if (!CORBA::is_nil(aTabAttr))
3774 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3776 SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
3777 if (!CORBA::is_nil(aTabAttr))
3778 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3781 aTitle.simplifyWhiteSpace();
3783 flt.append("Table Files (*.xls)");
3785 QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
3786 aDlg -> setCaption("Export Table To File");
3787 aDlg -> setDir( getVisuOutputDir() );
3788 aDlg -> setFilters(flt);
3789 aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
3791 QString aFile = aDlg -> selectedFile();
3794 if(!aFile.isEmpty()){
3795 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3796 QString aDir = QAD_Tools::getDirFromPath(aFile);
3797 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3800 GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
3801 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3802 } catch(std::exception& ex) {
3804 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3805 tr ("ERR_ERROR_DURING_EXPORT") + " " + tr(ex.what()),
3806 tr ("VISU_BUT_OK") );
3808 INFOS(tr ("ERR_ERROR_DURING_EXPORT"));
3809 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3810 tr ("ERR_ERROR_DURING_EXPORT"),
3811 tr ("VISU_BUT_OK") );
3817 /* ======================================================================================== */
3818 /* Global Method to import mesh results in MED and DAT format */
3819 /* ======================================================================================== */
3820 void VisuGUI::ImportFile(){
3821 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
3823 void VisuGUI::CopyAndImportFile(){
3824 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
3826 void VisuGUI::ImportFromFile(TImportFun theImportFun){
3827 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3829 //flt.append( "Exportable Files (*.med *.dat)" );
3830 //flt.append( "Dat Files (*.dat)" );
3831 flt.append( "Med Files (*.med)" );
3832 QString aDir = getVisuInputDir();
3833 QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3834 aDir,flt,tr("Import From File"),true);
3836 if(aFileInfo.exists()){
3837 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3838 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3839 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3842 VISU::Result_var aResult;
3848 if(aFileInfo.extension(false) == "med"){
3849 QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3850 bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3851 if (VisuGUI_FileDlg::IsBuild){
3852 aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3853 if(!CORBA::is_nil(aResult.in()))
3854 if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
3855 if(!pResult->IsPossible())
3856 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3857 tr ("ERR_CANT_BUILD_PRESENTATION"),
3858 tr ("VISU_BUT_OK") );
3860 aResult->BuildAll();
3863 QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3864 //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
3865 aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1
3866 QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3871 MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE");
3875 if(CORBA::is_nil(aResult.in())) {
3877 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3878 tr ("ERR_ERROR_IN_THE_FILE"),
3879 tr ("VISU_BUT_OK") );
3883 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3885 GetActiveStudy()->updateObjBrowser(); //update Object browser
3889 void VisuGUI::ExportToFile(){
3890 CORBA::Object_var anObject = GetSelectedObj();
3891 if(CORBA::is_nil(anObject)) return;
3892 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
3893 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3895 flt.append( "Dat Files (*.dat)" );
3896 flt.append( "Med Files (*.med)" );
3897 QString aDir = getVisuOutputDir();
3898 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3899 aDir,flt,tr("Export To File"),false);
3900 if(!aFile.isEmpty()){
3901 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3902 aDir = QAD_Tools::getDirFromPath(aFile);
3903 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3904 if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3906 //APO - aResult->GetInput()->ToFile(aFile.latin1());
3907 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3908 }catch(std::exception& ex) {
3910 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3911 tr ("ERR_ERROR_DURING_EXPORT") + " " +tr(ex.what()),
3912 tr ("VISU_BUT_OK") );
3915 INFOS(tr ("ERR_ERROR_DURING_EXPORT").latin1());
3916 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3917 tr ("ERR_ERROR_DURING_EXPORT"),
3918 tr ("VISU_BUT_OK") );
3923 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3924 tr ("WRN_NO_AVAILABLE_DATA"),
3925 tr ("VISU_BUT_OK"));
3928 /* ======================================================================================== */
3929 /* Test and Read Object Browser before display */
3930 /* ======================================================================================== */
3931 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3932 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3933 Handle(SALOME_InteractiveObject) anIO;
3934 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3935 if(!anIO.IsNull() && anIO->hasEntry()){
3936 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3937 QString aValue = getValue(objVisu,"myType");
3938 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3940 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3941 tr("WRN_NO_AVAILABLE_DATA"),
3942 tr("VISU_BUT_OK") );
3947 * Returns Actor of presentation if it exists
3949 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3950 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3951 if (!vf) return NULL;
3953 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3954 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3955 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3956 if(thePrs == anVISUActor->GetPrs3d())
3957 return anVISUActor->GetParent();
3962 * Displays only actor of given presentation
3963 * Creates it if it is abcent
3965 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3966 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3967 if (!vf) return NULL;
3969 vtkRenderer *aRen = vf->getRenderer();
3970 vtkActorCollection *anActColl = aRen->GetActors();
3973 VISU_Actor* anVISUActor = NULL;
3974 VISU_Actor* aResActor = NULL;
3975 VISU::Prs3d_i* aSrcAddr = thePrs;
3976 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3977 if(anActor->IsA("VISU_Actor")){
3978 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3979 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
3980 if(aPrs == NULL) continue;
3981 if (thePrs == aPrs) {
3982 aResActor = anVISUActor->GetParent();
3983 thePrs->UpdateActor(aResActor);
3984 aResActor->VisibilityOn();
3986 } else if (theDispOnly) {
3987 anVISUActor->GetParent()->VisibilityOff();
3990 } else if (theDispOnly && anActor->GetVisibility()) {
3991 anActor->VisibilityOff();
3995 if (aResActor) return aResActor;
3997 anVISUActor = thePrs->CreateActor();
3998 vf->AddActor(anVISUActor);
3999 } catch ( std::runtime_error& exc ){
4001 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4002 tr("ERR_CANT_VISUALIZE_OBJECT") + " " + tr(exc.what()),
4003 tr ("VISU_BUT_OK") );
4011 * Returns TRUE if Presentation is displayed
4013 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
4014 VISU_Actor* anVISUActor = GetActor(thePrs);
4015 return (anVISUActor)? anVISUActor->GetVisibility() : false;
4019 * Erases Presentation
4021 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
4022 GetActiveStudy()->unHighlightAll();
4023 VISU_Actor* anVISUActor = GetActor(thePrs);
4025 anVISUActor->VisibilityOff();
4030 * Deletes given presentation from Data structure
4032 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
4033 if(checkLock(GetStudyDocument()) || !thePrs) return;
4034 GetActiveStudy()->unHighlightAll();
4035 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
4036 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
4037 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
4038 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
4039 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
4040 aViewFrame->RemoveActor(anActor);
4043 aViewFrame->unHighlightAll();
4046 thePrs->RemoveFromStudy();
4047 GetActiveStudy()->updateObjBrowser(); //update Object browser
4051 * Deletes given curve presentation from Data structure
4053 void VisuGUI::DeletePresentation(VISU::Curve_i* theCurve) {
4054 if(checkLock(GetStudyDocument()) || !theCurve) return;
4055 GetActiveStudy()->unHighlightAll();
4056 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
4057 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
4058 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
4059 if(Plot2d_ViewFrame* aViewFrame = dynamic_cast<Plot2d_ViewFrame*>(aVFrame)){
4060 QList<Plot2d_Curve> clist;
4061 aViewFrame->getCurves( clist );
4062 for ( int i = 0; i < clist.count(); i++ ) {
4063 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) )
4064 aViewFrame->eraseCurve( clist.at( i ) );
4066 aViewFrame->Repaint();
4067 aViewFrame->unHighlightAll();
4070 theCurve->RemoveFromStudy();
4071 GetActiveStudy()->updateObjBrowser(); //update Object browser
4075 * Creates new actor of presentation
4077 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
4078 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
4079 if (!thePrs) return;
4080 QApplication::setOverrideCursor( Qt::waitCursor );
4081 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
4087 MESSAGE("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4088 VISU_Actor* aActor = thePrs->CreateActor();
4089 vf->AddActor(aActor);
4090 }catch(std::runtime_error& exc) {
4091 INFOS("std::runtime_error "<<exc.what());
4092 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4093 QApplication::restoreOverrideCursor();
4094 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4095 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr(exc.what()),
4096 tr ("VISU_BUT_OK") );
4099 MESSAGE(" Unknown exception");
4100 QApplication::restoreOverrideCursor();
4101 INFOS("Unknown exception is caught in VisuGUI::CreateActor");
4102 INFOS("Available memory : "<<VISU_PipeLine::GetAvailableMemory());
4103 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
4104 tr ("WRN_CANT_VISUALIZE_PRS") + " " + tr("ERR_UNKNOWN_EXCEPTION"),
4105 tr ("VISU_BUT_OK") );
4110 MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR");
4114 QApplication::restoreOverrideCursor();
4119 /* ======================================================================================== */
4120 /* Functions to State of VisuGUI and Dialog Box */
4121 /* ======================================================================================== */
4123 void VisuGUI::SetState(int aState )
4125 this->myState = aState ;
4130 void VisuGUI::ResetState()
4132 this->myState = -1 ;
4136 void VisuGUI::EmitSignalDeactivateDialog()
4138 emit this->SignalDeactivateActiveDialog() ;
4142 void VisuGUI::EmitSignalCloseAllDialogs()
4144 emit this->SignalCloseAllDialogs() ;
4148 QDialog* VisuGUI::GetActiveDialogBox()
4150 return this->myActiveDialogBox ;
4153 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
4155 this->myActiveDialogBox = (QDialog*)aDlg ;