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_PhaseDlg.h"
53 #include "VisuGUI_MagnitudeDlg.h"
54 #include "VisuGUI_PhaseMagnitudeDlg.h"
55 #include "VisuGUI_PartialScaDlg.h"
56 #include "VisuGUI_CursorDlg.h"
57 #include "VisuGUI_ScalarBarDlg.h"
58 #include "VisuGUI_SweepPrefDlg.h"
59 #include "VisuGUI_CutPlanesDlg.h"
60 #include "VisuGUI_CutLinesDlg.h"
61 #include "VisuGUI_VectorsDlg.h"
62 #include "VisuGUI_IsoSurfacesDlg.h"
63 #include "VisuGUI_StreamLinesDlg.h"
64 #include "VisuGUI_TimeAnimation.h"
66 #include "VisuGUI_Selection.h"
67 #include "VisuGUI_VisuAsDlg.h"
68 #include "VisuGUI_SelVectCompDlg.h"
69 #include "VisuGUI_NonIsometricDlg.h"
71 #include "SALOMEGUI_ImportOperation.h"
72 #include "SALOMEGUI_QtCatchCorbaException.hxx"
73 #include "utilities.h"
75 #include "QAD_Config.h"
77 #include "QAD_Settings.h"
78 #include "QAD_Tools.h"
79 #include "QAD_LeftFrame.h"
80 #include "QAD_RightFrame.h"
81 #include "QAD_MessageBox.h"
82 #include "QAD_ObjectBrowser.h"
83 #include "QAD_ObjectBrowserItem.h"
84 #include "QAD_Menus.h"
85 #include "QAD_Resource.h"
86 #include "QAD_ResourceMgr.h"
87 #include "QAD_FileDlg.h"
88 #include "QAD_WaitCursor.h"
89 #include "SALOME_Selection.h"
90 #include "SALOMEGUI_NameDlg.h"
91 #include "SALOMEGUI_TableDlg.h"
92 #include "SALOMEGUI_SetupCurveDlg.h"
93 #include "SALOMEGUI_SetValueDlg.h"
94 #include "Plot2d_SetupPlot2dDlg.h"
95 #include "Plot2d_ViewFrame.h"
96 #include "VTKViewer_ViewFrame.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>
115 //VRV: porting on Qt 3.0.5
116 #if QT_VERSION >= 0x030005
117 #include <qlistview.h>
119 //VRV: porting on Qt 3.0.5
120 #include <qmessagebox.h>
123 #include CORBA_CLIENT_HEADER(MED_Gen)
125 #include <vtkActor.h>
126 #include <vtkDataSetMapper.h>
128 // Open CASCADE Include
129 #include <TCollection_AsciiString.hxx>
133 static int MYCHECKTIME = 1;
135 static int MYCHECKTIME = 0;
137 #include <Utils_Timer.hxx>
142 static int MYDEBUG = 0;
143 static int MYDEBUGWITHFILES = 0;
145 static int MYDEBUG = 0;
146 static int MYDEBUGWITHFILES = 0;
149 class CustomItem : public QCustomMenuItem{
151 CustomItem( const QString& s, const QFont& f )
152 : string( s ), font( f ){};
155 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
158 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
163 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
170 static VisuGUI MYVISUGUI;
171 static VisuGUI *visuGUI = &MYVISUGUI;
173 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
174 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
175 return VISU::VISU_Gen_i::GetVisuGenImpl();
178 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
179 const char* theActorClassName = "VISU_Actor")
181 vtkRenderer *aRen = theViewFrame->getRenderer();
182 vtkActorCollection *anActColl = aRen->GetActors();
185 int nothingVisible=1;
187 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
188 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
189 // loop through all props
190 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
191 // if it's invisible, or has no geometry, we can skip the rest
192 if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
193 bounds = prop->GetBounds();
194 // make sure we haven't got bogus bounds
195 if ( bounds != NULL &&
196 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
197 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
198 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
201 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
202 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
203 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
204 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
205 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
206 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
210 return nothingVisible;
213 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
214 static float PRECISION = 0.000001;
215 static float DEVIATION = 600;
217 if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
219 float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
221 float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
223 float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
225 CameraOrient aCameraOrient = e3D;
226 if(absX <= PRECISION) aCameraOrient = eFront;
227 else {if(absY <= PRECISION) aCameraOrient = eLeft;
228 else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
230 float dev_abs_XY = absX / absY;
231 float dev_abs_YZ = absY / absZ;
232 float dev_abs_XZ = absX / absZ;
233 if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
234 else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
235 else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
237 switch(aCameraOrient){
238 case eFront: theViewFrame->onViewFront(); break;
239 case eLeft: theViewFrame->onViewLeft(); break;
240 case eTop: theViewFrame->onViewTop(); break;
241 case e3D: theViewFrame->onViewReset(); break;
243 theViewFrame->getRenderer()->ResetCameraClippingRange();
244 theViewFrame->onViewFitAll();
247 QAD_Desktop* VisuGUI::GetDesktop(){
248 return QAD_Application::getDesktop() ;
251 QAD_Study* VisuGUI::GetActiveStudy(){
252 return GetDesktop()->getActiveStudy() ;
255 vtkRenderer* VisuGUI::GetRenderer(){
256 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
257 return aViewFrame->getRenderer();
261 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
262 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
263 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
266 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
267 return GetActiveStudy()->getStudyDocument();
270 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
271 return GetStudyDocument()->NewBuilder();
276 * Finds value by given key
279 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
280 VISU::Storable::TRestoringMap aMap;
281 if(!theSObject->_is_nil()){
282 SALOMEDS::GenericAttribute_var anAttr;
283 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
284 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
285 CORBA::String_var aString = aComment->Value();
286 QString strIn(aString.in());
287 VISU::Storable::StrToMap(strIn,aMap);
293 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
295 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
297 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
302 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
303 VISU::Storable::TRestoringMap* pMap = NULL)
305 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
306 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
307 if(aSel->IObjectCount() > 0){
308 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
309 if(pIO != NULL) *pIO = anIO;
310 if(anIO->hasEntry()){
311 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
312 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
313 if(!aSObject->_is_nil()){
314 SALOMEDS::GenericAttribute_var anAttr;
315 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
316 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
317 string aComm = aComment->Value();
318 QString strIn(aComm.c_str());
319 VISU::Storable::StrToMap(strIn,*pMap);
321 return VISU::SObjectToObject(aSObject);
325 return CORBA::Object::_nil();
329 int IsTrihedronDisplayed(){
330 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
331 return aVTKViewFrame->isTrihedronDisplayed();
336 void RepaintCurrentView(){
337 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
341 * Returns selected sclalar mode or -1 if it was cancelled
343 int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){
345 // const VISU::TField* aField = theResult->GetInput()->GetField(theFieldName);
346 // if(aField->myNbComp > 1){
347 // VisuGUI_SelVectCompDlg* SelCompDlg = new VisuGUI_SelVectCompDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
348 // if(SelCompDlg->exec()){
349 // aScalarMode = SelCompDlg->whatIsChecked();
353 // delete SelCompDlg;
361 /* ==================================================================================== */
362 /* ==================================================================================== */
364 /* ==================================================================================== */
365 /* ==================================================================================== */
367 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
368 return theStudy->GetProperties()->IsLocked();
371 static int checkLock(const SALOMEDS::Study_var& theStudy) {
372 if (isStudyLocked(theStudy)) {
373 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
374 QObject::tr("WRN_WARNING"),
375 QObject::tr("WRN_STUDY_LOCKED"),
376 QObject::tr("BUT_OK") );
384 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
387 QString VisuInputDir = getVisuInputDir();
388 QString VisuOutputDir = getVisuOutputDir();
389 vtkRenderer *theRenderer = GetRenderer();
391 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
392 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
393 SALOMEDS::GenericAttribute_var anAttr;
394 SALOMEDS::AttributeName_var aName;
395 SALOMEDS::AttributeIOR_var anIOR;
397 switch (theCommandID){
398 /* ======================================================================================== */
399 /* Define Selection Mode */
400 /* ======================================================================================== */
406 QApplication::setOverrideCursor( Qt::waitCursor );
407 int mode = theCommandID - 100; // Point, Edge, Cell, Actor
408 parent->SetSelectionMode( mode );
409 QApplication::restoreOverrideCursor();
413 /* ======================================================================================== */
414 /* Import Table from file */
415 /* ======================================================================================== */
419 if(checkLock(aStudy)) break;
420 visuGUI->ImportTablesFromFile();
424 /* ======================================================================================== */
425 /* Import Mesh from MED, DAT file */
426 /* ======================================================================================== */
430 visuGUI->ImportFromFile();
434 /* ======================================================================================== */
435 /* Export results and mesh into a file format */
436 /* ======================================================================================== */
440 //visuGUI->ExportToFile();
444 /* ========================================================================== */
445 /* Visualization of Results : */
446 /* 4011 : Scalar Map */
447 /* 4012 : Deformed Shape */
449 /* 4014 : Iso-Surfaces */
450 /* 4015 : Cut Planes */
451 /* 4016 : Stream Lines */
452 /* ========================================================================== */
455 visuGUI->CreateScalarMap();
458 visuGUI->CreateDeformedShape();
461 visuGUI->CreateVectors();
464 visuGUI->CreateIsoSurfaces();
467 visuGUI->CreateCutPlanes();
470 visuGUI->CreateCutLines();
473 visuGUI->CreateStreamLines();
476 /* ======================================================================================================================= */
477 /* View Scalar Animation (Animation/scalar) */
479 /* ======================================================================================================================= */
485 /* ========================================================================================================================= */
486 /* Selection - Cell by number */
487 /* ========================================================================================================================= */
490 visuGUI->SelectCell();
493 /* ========================================================================================================================= */
494 /* Selection - Cell - information attribute */
495 /* ========================================================================================================================= */
498 visuGUI->InfoOnCell();
501 /* ========================================================================================================================= */
502 /* Selection - Point - information number */
503 /* ========================================================================================================================= */
506 visuGUI->SelectPoint();
509 /* ========================================================================================================================= */
510 /* Selection - Point - information attribute */
511 /* ========================================================================================================================= */
514 visuGUI->InfoOnPoint();
517 /* ========================================================================================================================= */
518 /* Selection - Shape */
519 /* ========================================================================================================================= */
523 /* ========================================================================================================================= */
524 /* Visualization - Wireframe */
525 /* ========================================================================================================================= */
531 /* ========================================================================================================================= */
532 /* Visualization - Surface */
533 /* ========================================================================================================================= */
539 /* ========================================================================================================================= */
540 /* Visualization - Points */
541 /* ========================================================================================================================= */
547 /* ========================================================================================================================= */
548 /* Visualization - Erase */
549 /* ========================================================================================================================= */
555 /* ========================================================================================================================= */
556 /* Visualization - Global */
557 /* ========================================================================================================================= */
561 /* ========================================================================================================================= */
562 /* Visualization - Partial */
563 /* ========================================================================================================================= */
569 //Show dialog that allows to select scale function and corresponding scale factor
570 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
571 FALSE, Qt::WDestructiveClose );
576 /* ============================ */
577 /* POP-UP OBJECTS BROWSER */
578 /* ============================ */
580 case 900 : // Rename object
584 // ---------------- For Popup in Viewer
590 case 803 : // Display only
591 case 903 : // Display only
592 visuGUI->DisplayOnlyPrs();
595 case 901 : // Display
596 visuGUI->DisplayPrs();
599 case 8041 : // Object representation : Wireframe
600 case 9041 : // Object representation : Wireframe
601 visuGUI->ChangeRepresentation(VISU::WIREFRAME);
604 case 8042 : // Object representation : Surface
605 case 9042 : // Object representation : Surface
606 visuGUI->ChangeRepresentation(VISU::SHADED);
609 case 8043 : // Object representation : Points
610 case 9043 : // Object representation : Points
611 visuGUI->ChangeRepresentation(VISU::POINT);
614 case 8044 : // Object representation : Shrink/Unshrink
615 case 9044 : // Object representation : Shrink/Unshrink
616 visuGUI->ChangeRepresentation(VISU::SHRINK);
619 case 8051 : // Change object color
620 case 9051 : // Change object color
621 visuGUI->ChageColor();
624 case 8052 : // Change object opacity
625 case 9052 : // Change object opacity
626 visuGUI->ChangeOpacity();
629 case 8053 : // Change object line width
630 case 9053 : // Change object line width
631 visuGUI->ChangeLines();
634 case 808 : // Sweep IsoSurfaces or Cutplanes
635 case 908 : // Sweep IsoSurfaces or Cutplanes
639 /* ======================================================================================== */
640 /* Preferences for Scalar Bar */
641 /* ======================================================================================== */
648 /* ======================================================================================== */
649 /* Preferences for Sweeping */
650 /* ======================================================================================== */
653 SetSweepingPreferences();
657 /* ======================================================================================== */
658 /* Preferences for Full loading */
659 /* ======================================================================================== */
664 QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
665 bool check = !pp->isItemChecked(theCommandID);
666 pp->setItemChecked(theCommandID,check);
667 switch(theCommandID){
669 QAD_CONFIG->addSetting( "Visu:BuildResult", check );
672 QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
678 case 113: // Load MED using MED component
680 if (checkLock(GetStudyDocument())) break;
682 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
683 if (CORBA::is_nil(aMedComp)) return false;
684 SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
685 if (CORBA::is_nil(aMedGen)) return false;
687 QStringList filtersList ;
689 filtersList.append( tr("MED_MEN_IMPORT_MED") );
690 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
691 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
694 tr("MED_MEN_IMPORT"),
696 if (!aFileName.isEmpty()) {
697 QApplication::setOverrideCursor( Qt::waitCursor );
698 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
699 GetActiveStudy()->updateObjBrowser();
700 QApplication::restoreOverrideCursor();
706 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
707 tr ("MSG_NOT_IMPLEMENTED"),
708 tr ("VISU_BUT_OK") );
711 }catch (const SALOME::SALOME_Exception& S_ex) {
712 QtCatchCorbaException(S_ex);
716 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
717 tr("ERR_UNKNOWN_EXCEPTION"),
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){
752 if(vtkRenderer *aRen = GetRenderer()){
754 vtkActorCollection *anActColl = aRen->GetActors();
755 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
756 if(anActor->GetVisibility() > 0)
757 if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){
758 anVISUActor = anVISUActor->GetParent();
760 anVISUActor->SetRepresentation(theType);
762 anVISUActor->VisibilityOff();
765 RepaintCurrentView();
769 // -----------------------------------------------------------------------------------------
771 // -----------------------------------------------------------------------------------------
773 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
778 // ====================================================================================================================
780 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
785 // ===================================================================================================================
787 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
789 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
792 if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
798 if(MYDEBUG) MESSAGE("--> Key : Escape")
810 //=====================================================================================
811 // Slot-functions for presentations creation
812 //=====================================================================================
815 #define CREATEPRESENTATION(FunctionName) \
816 void FunctionName() { \
817 if (checkLock(GetStudyDocument())) return; \
818 SALOMEDS::SObject_var objVisu; \
819 if (!TestObjectBrowser(objVisu)) return; \
820 if(!FunctionName(objVisu)) return; \
821 GetActiveStudy()->updateObjBrowser(); \
822 GetDesktop()->putInfo("Ready"); \
823 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
825 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
826 vf->onViewFitAll(); \
831 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
832 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
833 CREATEPRESENTATION(VisuGUI::CreateVectors);
834 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
835 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
836 CREATEPRESENTATION(VisuGUI::CreateCutLines);
837 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);
866 //=====================================================================================
867 // function : DisplayPrs()
869 //=====================================================================================
870 void VisuGUI::DisplayPrs() {
871 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
872 Handle(SALOME_InteractiveObject) anIO;
873 CORBA::Object_var anObject = GetSelectedObj(&anIO);
874 if ( !CORBA::is_nil( anObject ) ) {
875 // is it Prs3d object ?
876 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
878 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
879 UpdateViewer(aPrsObject);
880 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
881 vf->getRenderer()->ResetCameraClippingRange();
883 vf->highlight(anIO, 1);
888 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
890 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
891 PlotCurve(aCurve, VISU::eDisplay );
895 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
897 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
898 PlotContainer(aContainer, VISU::eDisplay );
902 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
904 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
905 PlotTable(aTable, VISU::eDisplay );
911 //=====================================================================================
912 // function : DisplayOnlyPrs()
914 //=====================================================================================
915 void VisuGUI::DisplayOnlyPrs() {
916 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
917 CORBA::Object_var anObject = GetSelectedObj();
918 if ( !CORBA::is_nil( anObject ) ) {
919 // is it Prs3d object ?
920 PortableServer::Servant aServant = VISU::GetServant(anObject);
921 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant)){
922 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
923 UpdateViewer(aPrsObject, true);
924 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
926 vf->getRenderer()->ResetCameraClippingRange();
929 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant)){
930 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
931 PlotCurve(aCurve, VISU::eDisplayOnly );
932 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant)){
933 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
934 PlotContainer(aContainer, VISU::eDisplayOnly );
935 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant)){
936 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
937 PlotTable(aTable, VISU::eDisplayOnly );
942 //=====================================================================================
943 // function : ErasePrs()
945 //=====================================================================================
946 void VisuGUI::ErasePrs() {
947 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs");
948 CORBA::Object_var anObject = GetSelectedObj();
949 if ( !CORBA::is_nil( anObject ) ) {
950 // is it Prs3d object ?
951 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
953 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Prs3d object");
954 ErasePrs(aPrsObject);
955 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
961 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject));
963 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Curve object");
964 PlotCurve(aCurve, VISU::eErase );
967 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject));
969 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Container object");
970 PlotContainer(aContainer, VISU::eErase );
973 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject));
975 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Table object");
976 PlotTable(aTable, VISU::eErase );
981 //=====================================================================================
982 // function : DisplayManyPrs()
984 //=====================================================================================
985 void VisuGUI::DisplayManyPrs()
987 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
988 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
989 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
990 for ( ; It.More(); It.Next() ) {
991 Handle(SALOME_InteractiveObject)& anIO = It.Value();
992 if ( anIO->hasEntry() ) {
993 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
994 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
995 VISU::Storable::TRestoringMap pMap;
996 if( !aSObject->_is_nil() ) {
997 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
998 if ( !CORBA::is_nil( aCORBAObject ) ) {
999 // is it Prs3d object ?
1000 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject));
1002 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
1003 UpdateViewer(aPrsObject);
1004 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1006 vf->getRenderer()->ResetCameraClippingRange();
1008 vf->highlight(anIO, 1);
1013 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject));
1015 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
1016 PlotCurve(aCurve, VISU::eDisplay );
1019 // is it Container ?
1020 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject));
1022 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
1023 PlotContainer(aContainer, VISU::eDisplay );
1027 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject));
1029 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
1030 PlotTable(aTable, VISU::eDisplay );
1039 //=====================================================================================
1040 // function : DisplayOnlyManyPrs()
1042 //=====================================================================================
1043 void VisuGUI::DisplayOnlyManyPrs() {
1044 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
1045 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1046 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1047 bool aFirstElem = true;
1048 for ( ; It.More(); It.Next() ) {
1049 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1050 if ( anIO->hasEntry() ) {
1051 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1052 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1053 VISU::Storable::TRestoringMap pMap;
1054 if( !aSObject->_is_nil() ) {
1055 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1056 if ( !CORBA::is_nil( aCORBAObject ) ) {
1057 // is it Prs3d object ?
1058 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject));
1060 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1061 UpdateViewer(aPrsObject, aFirstElem);
1062 if (aFirstElem) aFirstElem = false;
1063 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1065 vf->getRenderer()->ResetCameraClippingRange();
1067 vf->highlight(anIO, 1);
1072 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject));
1074 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1076 PlotCurve(aCurve, VISU::eDisplayOnly );
1079 else PlotCurve(aCurve, VISU::eDisplay );
1082 // is it Container ?
1083 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject));
1085 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1087 PlotContainer(aContainer, VISU::eDisplayOnly );
1090 else PlotContainer(aContainer, VISU::eDisplay );
1094 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject));
1096 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1098 PlotTable(aTable, VISU::eDisplayOnly );
1101 else PlotTable(aTable, VISU::eDisplay );
1111 //=====================================================================================
1112 // function : EraseManyPrs()
1114 //=====================================================================================
1115 void VisuGUI::EraseManyPrs()
1117 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1118 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1119 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1120 SALOME_ListIteratorOfListIO It( LIO );
1121 for ( ; It.More(); It.Next() ) {
1122 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1123 if ( anIO->hasEntry() ) {
1124 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1125 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1126 VISU::Storable::TRestoringMap pMap;
1127 if( !aSObject->_is_nil() ) {
1128 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1129 if ( !CORBA::is_nil( aCORBAObject ) ) {
1130 // is it Prs3d object ?
1131 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject));
1133 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1134 ErasePrs(aPrsObject);
1135 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1142 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject));
1144 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1145 PlotCurve(aCurve, VISU::eErase );
1148 // is it Container ?
1149 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject));
1151 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1152 PlotContainer(aContainer, VISU::eErase );
1156 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject));
1158 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1159 PlotTable(aTable, VISU::eErase );
1168 //=====================================================================================
1169 // function : RecreateActor()
1171 //=====================================================================================
1172 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1173 QApplication::setOverrideCursor(Qt::waitCursor);
1176 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1177 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1178 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1179 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1180 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1181 thePrs->UpdateActor(anActor);
1183 }catch(std::runtime_error& ex){
1184 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1185 tr ("ERR_CANT_BUILD_PRESENTATION"),
1186 tr ("VISU_BUT_OK") );
1188 QApplication::restoreOverrideCursor();
1192 //=====================================================================================
1193 // function : EditPrs()
1195 //=====================================================================================
1196 #define EDITPRS(PrsName, DlgName) \
1198 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1200 DlgName* aDlg = new DlgName(); \
1201 aDlg->initFromPrsObject(aPrsObject); \
1202 if ( aDlg->exec() ) { \
1203 aDlg->storeToPrsObject(aPrsObject); \
1204 RecreateActor(aPrsObject); \
1205 /*RepaintCurrentView();*/ \
1206 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1207 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1208 vf->getRenderer()->ResetCameraClippingRange(); \
1209 vf->onViewFitAll(); \
1218 void VisuGUI::EditPrs() {
1219 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1221 switch (aPrs3d->GetType()) {
1222 case VISU::TMESH: // Mesh 13
1225 case VISU::TSCALARMAP: // ScalarMap 18
1226 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1229 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1230 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1233 case VISU::TCUTPLANES: // Cut planes 42
1234 EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1237 case VISU::TCUTLINES: // Cut planes 42
1238 EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1241 case VISU::TISOSURFACE: // Iso surfaces
1242 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1244 case VISU::TVECTORS: // Vectors 64
1245 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1248 case VISU::TSTREAMLINES:
1249 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1254 Handle(SALOME_InteractiveObject) anIO;
1255 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1256 if ( !CORBA::is_nil( anObject ) )
1257 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1258 vf->highlight(anIO, 1);
1262 //=====================================================================================
1263 // function : EditScalarBar()
1265 //=====================================================================================
1266 void VisuGUI::EditScalarBar() {
1267 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1268 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
1270 VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false);
1271 aDlg->initFromPrsObject(aPrsObject);
1272 if ( aDlg->exec() ) {
1273 aDlg->storeToPrsObject(aPrsObject);
1274 RecreateActor(aPrsObject);
1276 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1281 Handle(SALOME_InteractiveObject) anIO;
1282 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1283 if ( !CORBA::is_nil( anObject ) )
1284 vf->highlight(anIO, 1);
1287 if (aDlg->isToSave())
1288 aDlg->storeToResources();
1296 //=====================================================================================
1297 // function : CreateMesh()
1299 //=====================================================================================
1300 void VisuGUI::CreateMesh() {
1301 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1302 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1304 if (checkLock(GetStudyDocument())) return;
1306 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1307 aSObj = aSObj->GetFather();
1308 aSObj = aSObj->GetFather();
1309 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1310 if(CORBA::is_nil(anObject)) {
1311 aSObj = aSObj->GetFather();
1312 anObject = VISU::SObjectToObject(aSObj);
1314 VISU::Result_var aResult;
1315 if (!CORBA::is_nil(anObject)) {
1316 aResult = VISU::Result::_narrow(anObject);
1318 if(CORBA::is_nil(aResult)) {
1319 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1320 tr ("WRN_NO_AVAILABLE_DATA"),
1321 tr ("VISU_BUT_OK"));
1324 VISU::Storable::TRestoringMap aMap;
1325 SALOMEDS::GenericAttribute_var anAttr;
1326 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1327 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1328 string aComm = aComment->Value();
1329 QString strIn(aComm.c_str());
1330 VISU::Storable::StrToMap(strIn,aMap);
1333 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1334 if(!isExist) return;
1335 CORBA::Object_var aMesh;
1336 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1341 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()));
1342 if(aComment == "ENTITY"){
1343 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1344 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1345 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1346 }else if(aComment == "FAMILY"){
1347 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1348 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1349 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1350 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1351 }else if(aComment == "GROUP"){
1352 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1353 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1354 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1358 cout<<"VisuGUI::CreateMesh() - CREATE MESH\n";
1362 QApplication::restoreOverrideCursor();
1363 VISU::Mesh_i* pPresent = NULL;
1364 if(!CORBA::is_nil(aMesh))
1365 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
1366 if (pPresent == NULL) {
1367 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1368 tr ("ERR_CANT_BUILD_PRESENTATION"),
1369 tr ("VISU_BUT_OK") );
1373 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1375 VISU_Actor *anActor = pPresent->CreateActor();
1380 vf->AddActor(anActor);
1384 cout<<"VisuGUI::CreateMesh() - DISPLAY MESH\n";
1387 //GetActiveStudy()->updateObjBrowser(); //not necessary
1388 GetDesktop()->putInfo("Ready");
1389 }catch(std::runtime_error& exc){
1390 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1391 tr ("ERR_CANT_CREATE_ACTOR"),
1392 tr ("VISU_BUT_OK") );
1397 //=====================================================================================
1398 // function : CreateManyMesh()
1400 //=====================================================================================
1401 void VisuGUI::CreateManyMesh(){
1402 if (checkLock(GetStudyDocument())) return;
1404 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1405 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1406 for ( ; It.More(); It.Next() ) {
1407 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1408 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1409 aSObj = aSObj->GetFather();
1410 aSObj = aSObj->GetFather();
1411 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1412 if(CORBA::is_nil(anObject)) {
1413 aSObj = aSObj->GetFather();
1414 anObject = VISU::SObjectToObject(aSObj);
1415 if(CORBA::is_nil(anObject)) return;
1417 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1418 if(CORBA::is_nil(aResult)) return;
1420 VISU::Storable::TRestoringMap aMap;
1421 SALOMEDS::GenericAttribute_var anAttr;
1422 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1423 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1424 string aComm = aComment->Value();
1425 QString strIn(aComm.c_str());
1426 VISU::Storable::StrToMap(strIn,aMap);
1429 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1430 if(!isExist) return;
1431 CORBA::Object_var aMesh;
1432 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1433 if(aComment == "ENTITY"){
1434 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1435 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1436 }else if(aComment == "FAMILY"){
1437 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1438 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1439 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1440 }else if(aComment == "GROUP"){
1441 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1442 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1444 QApplication::restoreOverrideCursor();
1445 if(CORBA::is_nil(aMesh)) return;
1447 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh));
1449 VISU_Actor *anActor = pPresent->CreateActor();
1450 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1451 vf->AddActor(anActor);
1454 GetDesktop()->putInfo("Ready");
1455 }catch(std::runtime_error& exc){
1460 //=====================================================================================
1461 // function : ChangeRepresentation()
1463 //=====================================================================================
1465 static void ShrinkMesh(VISU_Actor *theActor){
1466 if(theActor->IsShrunk())
1467 theActor->UnShrink();
1469 theActor->SetShrink(0.8);
1472 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1473 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1474 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1477 ShrinkMesh(anActor);
1480 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1481 aMesh->SetPresentationType(theType);
1482 RecreateActor(aMesh);
1484 anActor->SetRepresentation(theType);
1486 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1492 void VisuGUI::MakeSurfaceframe() {
1493 ChangeRepresentation(VISU::SURFACEFRAME);
1496 void VisuGUI::MakeInsideframe() {
1497 ChangeRepresentation(VISU::INSIDEFRAME);
1500 void VisuGUI::MakeWireframe() {
1501 ChangeRepresentation(VISU::WIREFRAME);
1504 void VisuGUI::MakeSurface() {
1505 ChangeRepresentation(VISU::SHADED);
1508 void VisuGUI::MakePoints() {
1509 ChangeRepresentation(VISU::POINT);
1512 void VisuGUI::MakeShrink() {
1513 ChangeRepresentation(VISU::SHRINK);
1518 //=====================================================================================
1519 // functions : Change Propertise
1521 //=====================================================================================
1522 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1523 CORBA::Object_var anObject = GetSelectedObj(theIO);
1524 if(CORBA::is_nil(anObject)) return NULL;
1525 PortableServer::Servant aServant = VISU::GetServant(anObject);
1526 if(!aServant) return NULL;
1527 return dynamic_cast<VISU::Prs3d_i*>(aServant);
1530 void VisuGUI::ChageColor() {
1531 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1532 if(!aPrsObject) return;
1534 VISU_Actor* anActor = GetActor(aPrsObject);
1535 if (!anActor) return;
1539 void VisuGUI::ChangeWireframeColor() {
1540 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1541 if(!aPrsObject) return;
1543 VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1544 if (!anActor) return;
1545 NewWireframeColor(anActor);
1549 void VisuGUI::ChangeOpacity() {
1550 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1551 if(!aPrsObject) return;
1553 VISU_Actor* anActor = GetActor(aPrsObject);
1554 if (!anActor) return;
1555 NewOpacity(anActor);
1559 void VisuGUI::ChangeLines() {
1560 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1561 if(!aPrsObject) return;
1563 VISU_Actor* anActor = GetActor(aPrsObject);
1564 if (!anActor) return;
1565 NewLinewidth(anActor);
1567 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1569 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1570 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1571 if ( theDisplaying == VISU::eDisplayOnly )
1573 QList<Plot2d_Curve> clist;
1574 aPlot->getCurves( clist );
1575 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1576 if ( !TableSO->_is_nil() ) {
1577 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1578 for ( ; Iter->More(); Iter->Next() ) {
1579 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1580 if( !CORBA::is_nil( childObject ) ) {
1581 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1582 if( !CORBA::is_nil( aCurve ) ) {
1583 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
1584 Plot2d_Curve* plotCurve = 0;
1585 for ( int i = 0; i < clist.count(); i++ ) {
1586 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1587 plotCurve = clist.at( i );
1591 if ( theDisplaying == VISU::eErase ) {
1593 aPlot->eraseCurve( plotCurve, false );
1594 clist.remove( plotCurve );
1597 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1599 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1600 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1601 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1602 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1603 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1604 /* - DATA NOT UPDATED */
1605 if ( !plotCurve->isAutoAssign() ) {
1606 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1607 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1608 SALOMEDS::Color color = theCurve->GetColor();
1609 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1610 plotCurve->setAutoAssign( theCurve->IsAuto() );
1612 aPlot->displayCurve( plotCurve, false );
1615 Plot2d_Curve* crv = theCurve->CreatePresentation();
1617 aPlot->displayCurve( crv, false );
1618 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1619 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1620 SALOMEDS::Color newColor;
1621 newColor.R = crv->getColor().red()/255.;
1622 newColor.G = crv->getColor().green()/255.;
1623 newColor.B = crv->getColor().blue()/255.;
1624 theCurve->SetColor( newColor );
1635 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1637 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1638 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1639 // if ( theDisplaying == VISU::eDisplayOnly )
1640 // aPlot->EraseAll();
1641 QList<Plot2d_Curve> clist;
1642 aPlot->getCurves( clist );
1643 Plot2d_Curve* plotCurve = 0;
1644 for ( int i = 0; i < clist.count(); i++ ) {
1645 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1646 plotCurve = clist.at( i );
1648 else if ( theDisplaying == VISU::eDisplayOnly ) {
1649 aPlot->eraseCurve( clist.at( i ) );
1652 if ( theDisplaying == VISU::eErase ) {
1654 aPlot->eraseCurve( plotCurve, false );
1656 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1658 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1659 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1660 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1661 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1662 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1663 /* DATA NOT UPDATED */
1664 if ( !plotCurve->isAutoAssign() ) {
1665 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1666 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1667 SALOMEDS::Color color = theCurve->GetColor();
1668 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1669 plotCurve->setAutoAssign( theCurve->IsAuto() );
1671 aPlot->displayCurve( plotCurve, false );
1674 Plot2d_Curve* crv = theCurve->CreatePresentation();
1676 aPlot->displayCurve( crv, false );
1677 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1678 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1679 SALOMEDS::Color newColor;
1680 newColor.R = crv->getColor().red()/255.;
1681 newColor.G = crv->getColor().green()/255.;
1682 newColor.B = crv->getColor().blue()/255.;
1683 theCurve->SetColor( newColor );
1690 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1692 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1693 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1694 if ( theDisplaying == VISU::eDisplayOnly )
1696 QList<Plot2d_Curve> clist;
1697 aPlot->getCurves( clist );
1698 if ( container->GetNbCurves() > 0 ) {
1699 int nbCurves = container->GetNbCurves();
1700 for ( int k = 1; k <= nbCurves; k++ ) {
1701 VISU::Curve_i* theCurve = container->GetCurve( k );
1702 if ( theCurve && theCurve->IsValid() ) {
1703 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) );
1704 // for ( int i = 0; i < clist.count(); i++ ) {
1705 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1706 // plotCurve = clist.at( i );
1710 if ( theDisplaying == VISU::eErase ) {
1712 aPlot->eraseCurve( plotCurve, false );
1713 clist.remove( plotCurve );
1716 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1718 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1719 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1720 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1721 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1722 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1723 /* - DATA NOT UPDATED */
1724 if ( !plotCurve->isAutoAssign() ) {
1725 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1726 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1727 SALOMEDS::Color color = theCurve->GetColor();
1728 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1729 plotCurve->setAutoAssign( theCurve->IsAuto() );
1731 aPlot->displayCurve( plotCurve, false );
1734 Plot2d_Curve* crv = theCurve->CreatePresentation();
1736 aPlot->displayCurve( crv, false );
1737 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1738 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1739 SALOMEDS::Color newColor;
1740 newColor.R = crv->getColor().red()/255.;
1741 newColor.G = crv->getColor().green()/255.;
1742 newColor.B = crv->getColor().blue()/255.;
1743 theCurve->SetColor( newColor );
1755 Slot : opens Table view : for Table object or SObject with table attribute selected
1757 void VisuGUI::ShowTable() {
1758 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1759 if( Sel->IObjectCount() !=1 )
1761 Handle(SALOME_InteractiveObject) anIO;
1762 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1763 SALOMEDS::SObject_var SO;
1764 if ( !CORBA::is_nil( anObject ) ) {
1765 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1766 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1767 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1768 if( !CORBA::is_nil( aTable ) ) {
1769 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
1771 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1776 // possibly this is Table SObject
1777 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1779 SALOMEDS::GenericAttribute_var anAttr;
1780 if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" )
1781 && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) )
1783 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1786 //SAL2670 Orientation of show tables
1787 SALOMEGUI_TableDlg::ttAuto,
1793 Slot : opens Table view : for Table object or SObject with table attribute selected
1795 void VisuGUI::CreateTable() {
1796 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1797 if( aSel->IObjectCount() !=1 )
1800 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1801 if (anIO->hasEntry()){
1802 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1803 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1804 if(!aSObject->_is_nil()) {
1805 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1806 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1807 SALOMEDS::GenericAttribute_var anAttr;
1808 if(!aCutLines->_is_nil() ||
1809 aSObject->FindAttribute( anAttr, "AttributeTableOfInteger") ||
1810 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ){
1811 GetVisuGen()->CreateTable(aSObject->GetID());
1812 GetActiveStudy()->updateObjBrowser();
1819 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1821 void VisuGUI::PlotData() {
1822 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1823 if( Sel->IObjectCount() !=1 )
1825 CORBA::Object_var anObject = GetSelectedObj();
1826 SALOMEDS::SObject_var SO;
1827 if ( !CORBA::is_nil( anObject ) ) {
1828 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1829 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1830 // Table (VISU object) is selected
1831 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1832 if( !CORBA::is_nil( aTbl ) ) {
1833 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTbl ) );
1835 SALOMEDS::GenericAttribute_var anAttr;
1836 SALOMEDS::AttributeName_var aName;
1838 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1839 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
1840 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
1841 // get name of SObject
1842 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1843 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1844 SOName = strdup( aName->Value() );
1846 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1847 if ( dlg->exec() == QDialog::Accepted ) {
1848 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1849 // if study is not locked - create new container, create curves
1850 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1852 QValueList<int> verIndices;
1853 dlg->getCurvesSource( horIndex, verIndices );
1854 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1855 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1856 if( !CORBA::is_nil( aContainer ) ) {
1857 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
1859 for ( int i = 0; i < verIndices.count(); i++ ) {
1860 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1861 if( !CORBA::is_nil( aNewCurve ) ) {
1862 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
1865 int marker, line, lineWidth;
1867 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1868 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1869 pCrv->SetColor( c );
1870 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1871 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1873 pContainer->AddCurve( pCrv->_this() );
1877 GetActiveStudy()->updateObjBrowser( true );
1878 PlotContainer( pContainer, VISU::eDisplay );
1884 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
1885 Plot2d_CurveContainer container;
1886 dlg->getCurves( container );
1887 if ( !container.isEmpty() ) {
1888 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1889 getRightFrame()->getViewFrame()))->displayCurves( container, true );
1890 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1891 getRightFrame()->getViewFrame()))->setTitle( SOName );
1902 // possibly this is Table SObject
1903 SALOMEDS::GenericAttribute_var anAttr;
1904 SALOMEDS::AttributeName_var aName;
1907 // check if Table SObject is selected
1908 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1909 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
1910 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
1911 // get name of SObject
1912 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1913 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1914 SOName = strdup( aName->Value() );
1916 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1917 if ( dlg->exec() == QDialog::Accepted ) {
1918 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1919 // if study is not locked - create new table and container objects, create curves
1920 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1922 QValueList<int> verIndices;
1923 dlg->getCurvesSource( horIndex, verIndices );
1924 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1925 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
1926 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1927 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
1928 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
1929 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
1931 if ( pContainer && pTable ) {
1932 for ( int i = 0; i < verIndices.count(); i++ ) {
1933 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
1934 if( !CORBA::is_nil( aNewCurve ) ) {
1935 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aNewCurve ) );
1938 int marker, line, lineWidth;
1940 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1941 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1942 pCrv->SetColor( c );
1943 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1944 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1946 pContainer->AddCurve( pCrv->_this() );
1950 GetActiveStudy()->updateObjBrowser( true );
1951 PlotContainer( pContainer, VISU::eDisplay );
1957 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
1958 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1959 Plot2d_CurveContainer container;
1960 dlg->getCurves( container );
1961 if ( !container.isEmpty() ) {
1962 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1963 getRightFrame()->getViewFrame()))->displayCurves( container, true );
1964 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1965 getRightFrame()->getViewFrame()))->setTitle( SOName );
1975 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
1977 void VisuGUI::CurveProperties() {
1978 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1979 if( Sel->IObjectCount() !=1 )
1981 CORBA::Object_var anObject = GetSelectedObj();
1982 SALOMEDS::SObject_var SO;
1983 if (CORBA::is_nil( anObject )) return;
1985 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1986 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
1988 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
1989 if( !CORBA::is_nil( aCurve ) ) {
1990 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
1991 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1992 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
1993 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
1994 dlg->setMarker( (int)curve->GetMarker() );
1995 SALOMEDS::Color color = curve->GetColor();
1996 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1997 if( dlg->exec() == QDialog::Accepted ) {
1998 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
1999 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2000 SALOMEDS::Color newColor;
2001 newColor.R = dlg->getColor().red()/255.;
2002 newColor.G = dlg->getColor().green()/255.;
2003 newColor.B = dlg->getColor().blue()/255.;
2004 curve->SetColor( newColor );
2005 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2006 if ( sfList.count() > 0 ) {
2007 QListIterator<QAD_StudyFrame> it( sfList );
2008 for ( ; it.current(); ++it ) {
2009 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2010 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2011 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2014 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2016 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2017 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2018 plotCurve->setColor( dlg->getColor() );
2019 aPlot->updateCurve( plotCurve, true );
2032 Slot : Clears container contents : for Container object selected
2034 void VisuGUI::ClearContainer() {
2035 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2036 if( Sel->IObjectCount() !=1 )
2039 CORBA::Object_var anObject = GetSelectedObj();
2040 SALOMEDS::SObject_var SO;
2041 if (CORBA::is_nil( anObject )) return;
2043 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2044 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2046 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2047 if( !CORBA::is_nil( aCnt ) ) {
2048 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
2049 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2051 GetActiveStudy()->updateObjBrowser();
2058 void VisuGUI::DeletePrs() {
2059 DeletePresentation(GetSelectedPrs3d());
2063 void VisuGUI::SaveViewParams()
2065 if (checkLock(GetStudyDocument())) return;
2066 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2067 if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2069 VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
2070 if(!CORBA::is_nil(aVM.in())){
2071 VISU::View_var aView = aVM->GetCurrentView();
2072 if(!CORBA::is_nil(aView.in())){
2073 VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
2074 if(CORBA::is_nil(aView3D.in())) return;
2075 if ( Sel->IObjectCount() == 0 ) {
2076 // Save view parameters by new name
2077 aView3D->SaveViewParams( 0 );
2078 GetActiveStudy()->updateObjBrowser( true );
2081 VISU::Storable::TRestoringMap aMap;
2082 Handle(SALOME_InteractiveObject) anIO;
2083 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2084 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2085 if(isExist && aType == VISU::TVIEW3D){
2086 aView3D->SaveViewParams( anIO->getName() );
2087 GetActiveStudy()->updateObjBrowser( true );
2095 void VisuGUI::RestoreViewParams()
2097 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2098 if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2100 VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
2101 if(!CORBA::is_nil(aVM.in())){
2102 VISU::View_var aView = aVM->GetCurrentView();
2103 if(!CORBA::is_nil(aView.in())){
2104 VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
2105 if(CORBA::is_nil(aView3D.in())) return;
2107 VISU::Storable::TRestoringMap aMap;
2108 Handle(SALOME_InteractiveObject) anIO;
2109 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2110 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2111 if(isExist && aType == VISU::TVIEW3D)
2112 aView3D->RestoreViewParams( anIO->getName() );
2117 //=====================================================================================
2118 // function : DeleteViewParams()
2120 //=====================================================================================
2121 void VisuGUI::DeleteViewParams() {
2123 VISU::Storable::TRestoringMap aMap;
2124 Handle(SALOME_InteractiveObject) anIO;
2125 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2126 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2127 if(isExist && aType == VISU::TVIEW3D){
2128 SALOMEDS::Study_var aStudy = GetStudyDocument();
2129 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2130 aStudy->NewBuilder()->RemoveObject(aSObject);
2132 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2133 aSel->RemoveIObject(anIO, 0);
2135 GetActiveStudy()->updateObjBrowser( true );
2140 //=====================================================================================
2141 // function : Sweep()
2143 //=====================================================================================
2144 void VisuGUI::Sweep() {
2145 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2146 if (!aPrsObject) return;
2148 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2152 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2153 if ( !aTempoStr.isEmpty() )
2154 aTemp = int(1.E6*(aTempoStr.toFloat()));
2157 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2158 if ( !aCyclesStr.isEmpty() )
2159 aCycles = aCyclesStr.toInt();
2162 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2163 if ( !aStepsStr.isEmpty() )
2164 aSteps = aStepsStr.toInt();
2166 VISU_Actor* aActor = GetActor(aPrsObject);
2167 if (!aActor) return;
2169 if (!aActor->GetVisibility()) {
2170 aActor->VisibilityOn();
2173 QApplication::setOverrideCursor( Qt::waitCursor );
2174 for (int j=0 ; j<aCycles; j++) {
2175 for (int i=0 ; i<=aSteps; i++) {
2176 float aPercents = float(i)/aSteps;
2177 aPrsObject->SetMapScale(aPercents);
2178 aPrsObject->UpdateActor(aActor);
2179 vf->getRW()->getRenderWindow()->Render();
2183 QApplication::restoreOverrideCursor();
2188 void VisuGUI::TimeAnimation() {
2189 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2190 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2192 bool isDefined = false;
2194 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2195 for (; It.More(); It.Next()) {
2196 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2197 if (aSObject->_is_nil()) continue;
2198 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2199 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2203 aAnimationDlg->addField(aSObject);
2205 } else if (aNbTimes == aNumber) {
2206 aAnimationDlg->addField(aSObject);
2211 if (isDefined) aAnimationDlg->show();
2212 else delete aAnimationDlg;
2216 void VisuGUI::ImportMedField() {
2217 if (checkLock(GetStudyDocument())) return;
2218 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2219 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2220 QApplication::setOverrideCursor( Qt::waitCursor );
2221 for(;It.More();It.Next()) {
2222 Handle(SALOME_InteractiveObject) anIO = It.Value();
2223 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2224 if(!aSObject->_is_nil()){
2225 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2226 if(!CORBA::is_nil(anObject)){
2227 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2228 if(!CORBA::is_nil(aMED.in()))
2229 GetVisuGen()->ImportMed( aSObject );
2230 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2231 if(!CORBA::is_nil(aField.in()))
2232 GetVisuGen()->ImportMedField( aField );
2234 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2235 SALOMEDS::GenericAttribute_var anAttr;
2236 aSFather->FindAttribute(anAttr, "AttributeName");
2237 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2238 CORBA::String_var aValue = aName->Value();
2239 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2240 GetVisuGen()->ImportMed(aSObject);
2241 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2242 // VisuGUI::myComponent->ImportMed(aSObject);
2246 GetActiveStudy()->updateObjBrowser( true );
2247 QApplication::restoreOverrideCursor();
2250 //=====================================================================================
2251 // functions : Rename()
2253 //=====================================================================================
2254 void VisuGUI::Rename() {
2255 if (checkLock(GetStudyDocument())) return;
2256 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2257 if ( Sel->IObjectCount() != 1 )
2259 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2260 if( aSObj->_is_nil() ) return;
2262 VISU::Curve_i* curve = 0;
2263 CORBA::Object_var anObject = GetSelectedObj();
2264 if ( !CORBA::is_nil( anObject )) {
2265 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2266 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2268 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2269 if( !CORBA::is_nil( aCurve ) ) {
2270 curve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( aCurve ) );
2275 //TEST DU PARENT == VISU
2276 SALOMEDS::GenericAttribute_var anAttr;
2277 SALOMEDS::AttributeName_var aName;
2278 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2279 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2280 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2281 if ( !Name.isEmpty() ) {
2282 QApplication::setOverrideCursor( Qt::waitCursor );
2284 curve->SetName( Name.latin1() );
2285 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2286 QApplication::restoreOverrideCursor();
2288 //int TypeMode; bool InViewer;
2289 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2290 //ActorTmp->setName((Standard_CString)Name.latin1());
2295 //=====================================================================================
2296 // functions : RenameTable()
2298 //=====================================================================================
2299 void VisuGUI::RenameTable() {
2300 if (checkLock(GetStudyDocument())) return;
2301 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2302 if ( Sel->IObjectCount() != 1 )
2304 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2305 if( aSObj->_is_nil() ) return;
2307 VISU::Table_i* table = 0;
2308 CORBA::Object_var anObject = GetSelectedObj();
2309 if ( !CORBA::is_nil( anObject )) {
2310 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2311 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2313 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2314 if( !CORBA::is_nil( aTable ) ) {
2315 table = dynamic_cast<VISU::Table_i*>( VISU::GetServant( aTable ) );
2320 //TEST DU PARENT == VISU
2321 SALOMEDS::GenericAttribute_var anAttr;
2322 SALOMEDS::AttributeName_var aName;
2323 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2324 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2325 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2326 if ( !Name.isEmpty() ) {
2327 QApplication::setOverrideCursor( Qt::waitCursor );
2329 table->SetName( Name.latin1() );
2330 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2331 QApplication::restoreOverrideCursor();
2333 //int TypeMode; bool InViewer;
2334 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2335 //ActorTmp->setName((Standard_CString)Name.latin1());
2342 //=====================================================================================
2343 // functions : RenameContainer()
2345 //=====================================================================================
2346 void VisuGUI::RenameContainer() {
2347 if (checkLock(GetStudyDocument())) return;
2348 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2349 if ( Sel->IObjectCount() != 1 )
2351 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2352 if( aSObj->_is_nil() ) return;
2354 VISU::Container_i* container = 0;
2355 CORBA::Object_var anObject = GetSelectedObj();
2356 if ( !CORBA::is_nil( anObject )) {
2357 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2358 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2360 CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2361 if( !CORBA::is_nil( aContainer ) ) {
2362 container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aContainer ) );
2367 //TEST DU PARENT == VISU
2368 SALOMEDS::GenericAttribute_var anAttr;
2369 SALOMEDS::AttributeName_var aName;
2370 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2371 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2372 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2373 if ( !Name.isEmpty() ) {
2374 QApplication::setOverrideCursor( Qt::waitCursor );
2376 container->SetName( Name.latin1() );
2377 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2378 QApplication::restoreOverrideCursor();
2380 //int TypeMode; bool InViewer;
2381 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2382 //ActorTmp->setName((Standard_CString)Name.latin1());
2389 //=====================================================================================
2390 // function : CopyPresentation()
2392 //=====================================================================================
2393 void VisuGUI::CopyPresentation(){
2394 if (checkLock(GetStudyDocument())) return;
2395 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2396 if (!aPrsObject) return;
2397 switch (aPrsObject->GetType()) {
2400 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2401 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2402 aSameMesh->SameAs(aMeshPrs);
2403 UpdateViewer(aSameMesh);
2406 case VISU::TSCALARMAP:
2408 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2409 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2410 aSameScalar->SameAs(aScalarPrs);
2411 UpdateViewer(aSameScalar);
2414 case VISU::TDEFORMEDSHAPE:
2416 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2417 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2418 aSameDeformed->SameAs(aDefPrs);
2419 UpdateViewer(aSameDeformed);
2422 case VISU::TCUTPLANES:
2424 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2425 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2426 aSameCut->SameAs(aCutPrs);
2427 UpdateViewer(aSameCut);
2430 case VISU::TCUTLINES:
2432 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2433 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2434 aSameCut->SameAs(aCutPrs);
2435 UpdateViewer(aSameCut);
2438 case VISU::TISOSURFACE:
2440 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2441 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2442 aSameIso->SameAs(aIsoPrs);
2443 UpdateViewer(aSameIso);
2446 case VISU::TSTREAMLINES:
2448 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2449 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2450 aSameLines->SameAs(aLinesPrs);
2451 UpdateViewer(aSameLines);
2454 case VISU::TVECTORS:
2456 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2457 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2458 aSameVectors->SameAs(aVectorsPrs);
2459 UpdateViewer(aSameVectors);
2463 GetActiveStudy()->updateObjBrowser();
2466 //=====================================================================================
2467 // function : InfoOnPoint() [ slot ]
2469 //=====================================================================================
2470 void VisuGUI::InfoOnPoint(){
2471 GetInfo(SelectionPoint,&(VisuGUI_Selection::PickingPoint));
2474 //=====================================================================================
2475 // function : InfoOnCell() [ slot ]
2477 //=====================================================================================
2478 void VisuGUI::InfoOnCell(){
2479 GetInfo(SelectionCell,&(VisuGUI_Selection::PickingCell));
2482 void VisuGUI::GetInfo(int theSelectionMode, TGetInfoFun theGetInfoFun){
2483 SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2484 if ( aSel->SelectionMode() == theSelectionMode ){
2485 Handle(SALOME_InteractiveObject) anIO;
2486 if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){
2487 TColStd_MapOfInteger aMapIndex;
2488 aSel->GetIndex(anIO,aMapIndex);
2489 TColStd_MapIteratorOfMapOfInteger anIter(aMapIndex);
2491 vtkDataSet* aDataSet = aPrs3d->GetPipeLine()->GetMapper()->GetInput();
2492 (*theGetInfoFun)(GetActiveStudy(), aDataSet, anIter.Key());
2496 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2497 tr ("VISU_WARNING"),
2498 tr ("WRN_NO_AVAILABLE_DATA"),
2499 tr ("VISU_BUT_OK"));
2501 QAD_MessageBox::warn1( GetDesktop(),
2503 tr ("ERR_WRONG_SELECTION_MODE"),
2504 tr ("VISU_BUT_OK") );
2507 //=====================================================================================
2508 // function : SelectPoint() [ slot ]
2510 //=====================================================================================
2511 void VisuGUI::SelectPoint(){
2512 Select(SelectionPoint,&vtkDataSet::GetNumberOfPoints,"Point selection","Point number:");
2515 //=====================================================================================
2516 // function : SelectCell() [ slot ]
2518 //=====================================================================================
2519 void VisuGUI::SelectCell(){
2520 Select(SelectionCell,&vtkDataSet::GetNumberOfCells,"Cell selection","Cell number:");
2523 void VisuGUI::Select(int theSelectionMode, TSelectFun theSelectFun,
2524 const char* theTitle, const char* theRequest)
2526 SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2527 if(aSel->SelectionMode() == theSelectionMode){
2528 Handle(SALOME_InteractiveObject) anIO;
2529 if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){
2532 TColStd_MapOfInteger aMapIndex;
2533 aSel->GetIndex(anIO,aMapIndex);
2534 TColStd_MapIteratorOfMapOfInteger anIter(aMapIndex);
2535 if(anIter.More()) anIndex = anIter.Key();
2536 int anId = SALOMEGUI_SetValueDlg::getInteger( tr(theTitle),
2542 vtkDataSet* aDataSet = aPrs3d->GetPipeLine()->GetMapper()->GetInput();
2543 int aMaxId = (aDataSet->*theSelectFun)();
2544 if(0 <= anId && anId < aMaxId){
2545 VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId );
2549 QAD_MessageBox::warn1(QAD_Application::getDesktop(),
2550 tr ("VISU_WARNING"),
2551 tr ("WRN_NO_AVAILABLE_DATA"),
2552 tr ("VISU_BUT_OK"));
2554 QAD_MessageBox::warn1( GetDesktop(),
2556 tr ("ERR_WRONG_SELECTION_MODE"),
2557 tr ("VISU_BUT_OK") );
2560 //=====================================================================================
2561 // function : DefinePopup()
2563 //=====================================================================================
2564 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2571 //=====================================================================================
2572 // function : checkHomoSelection()
2574 //=====================================================================================
2575 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2576 int VisuGUI::checkHomoSelection()
2578 int selMode = homoNone;
2579 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2580 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2581 for ( ; It.More(); It.Next() ) {
2582 int selNext = homoOther;
2583 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2584 if ( anIO->hasEntry() ) {
2585 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2586 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2587 VISU::Storable::TRestoringMap pMap;
2588 if( !aSObject->_is_nil() ) {
2589 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2590 if ( !CORBA::is_nil( aCORBAObject ) ) {
2591 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2592 if ( !CORBA::is_nil( aVisuObj ) ) {
2593 VISU::VISUType aType = aVisuObj->GetType();
2597 case VISU::TCONTAINER:
2598 selNext = homoCurves; break;
2600 case VISU::TSCALARMAP:
2601 case VISU::TISOSURFACE:
2602 case VISU::TDEFORMEDSHAPE:
2603 case VISU::TCUTPLANES:
2604 case VISU::TCUTLINES:
2605 case VISU::TVECTORS:
2606 case VISU::TSTREAMLINES:
2607 selNext = homoPresentations; break;
2609 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2610 selNext = homoAnimatable; break;
2612 selNext = homoOther; break;
2614 selNext = homoOther;
2619 SALOMEDS::GenericAttribute_var anAttr;
2620 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2621 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2622 string aComm = aComment->Value();
2623 QString strIn( aComm.c_str() );
2624 VISU::Storable::StrToMap( strIn, pMap );
2626 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2632 selNext = homoPresentable; break;
2634 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2635 selNext = homoAnimatable; break;
2637 selNext = homoOther; break;
2639 selNext = homoOther;
2646 if ( selMode == homoNone )
2649 if ( selMode != selNext )
2656 //=====================================================================================
2657 // function : GetNbChildren() [ static ]
2658 // purpose : get number of children
2659 //=====================================================================================
2660 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2662 if ( SO->_is_nil() )
2665 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2666 for ( ; Iter->More(); Iter->Next() ) {
2667 SALOMEDS::SObject_var refSO;
2668 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2674 //=====================================================================================
2675 // function : CustomPopup()
2677 //=====================================================================================
2678 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2679 const QString & theParent, const QString & theObject)
2681 int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2682 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2684 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2686 SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2687 if ( aSelection->IObjectCount() == 0 ) {
2688 if ( theParent == "Viewer" && isVTKViewer)
2689 // Available only for VTK viewer
2690 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2693 if( aSelection->IObjectCount() > 1 ) {
2694 int selMode = checkHomoSelection();
2695 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2696 if ( selMode == homoCurves ) {
2697 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2698 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2699 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2700 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2703 else if ( selMode == homoPresentations ) {
2705 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2706 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2709 else if ( selMode == homoPresentable ) {
2710 thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2712 else if ( selMode == homoAnimatable ) {
2713 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2717 VISU::Storable::TRestoringMap aMap;
2718 Handle(SALOME_InteractiveObject) anIO;
2719 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2720 if (!CORBA::is_nil(anObject)) {
2721 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2722 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2723 if (!CORBA::is_nil(aVisuObj)) {
2724 VISU::VISUType aType = aVisuObj->GetType();
2725 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2727 case VISU::TVISUGEN:
2728 thePopup->insertItem("Import From File", visuGUI, SLOT(ImportFromFile()));
2732 //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh()));
2733 //thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile()));
2734 //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2738 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2739 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2740 thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2741 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2742 if ( GetNbChildren( aSObject, false ) > 0 ) {
2743 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2744 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2745 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2751 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2752 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2753 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2755 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2756 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2757 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2759 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2760 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2764 case VISU::TCONTAINER:
2765 if( !CORBA::is_nil( anObject ) ) {
2766 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2767 if( !CORBA::is_nil( aCnt ) ) {
2768 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>( VISU::GetServant( aCnt ) );
2769 if ( container && container->GetNbCurves() > 0 ) {
2770 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2771 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2772 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2774 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2775 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2776 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2777 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2784 default: // Presentation
2786 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
2789 // Add Presentation menu
2790 if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2791 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2792 int aRepresent = anVISUActor->GetRepresentation();
2795 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2796 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2797 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2798 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2799 if (aType == VISU::TMESH)
2800 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2802 case VISU::WIREFRAME :
2803 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2804 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2805 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2806 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2807 if (aType == VISU::TMESH)
2808 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2811 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2812 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2813 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2814 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2815 if (aType == VISU::TMESH)
2816 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2818 case VISU::INSIDEFRAME :
2819 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2820 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2821 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2822 if (aType == VISU::TMESH)
2823 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2825 case VISU::SURFACEFRAME :
2826 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2827 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2828 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2829 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2832 if(anVISUActor->GetShrinkable())
2833 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2834 if (anVISUActor->IsShrunk())
2835 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2837 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2839 thePopup->insertItem("Representation", aPresMenu);
2842 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2843 if(aType == VISU::TMESH){
2844 if(aRepresent == VISU::SURFACEFRAME){
2845 aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2846 aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2848 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2849 }else if(aType == VISU::TDEFORMEDSHAPE)
2850 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2852 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2853 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2854 if (aType != VISU::TVECTORS){
2855 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2856 thePopup->insertItem("Properties", aPropMenu);
2858 thePopup->insertSeparator();
2861 thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
2862 if (aType != VISU::TMESH) {
2863 if (aType != VISU::TSCALARMAP)
2864 thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
2865 thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar()));
2867 if (aType == VISU::TCUTLINES)
2868 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
2870 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
2874 if ( theParent == "Viewer" &&
2875 ( aType == VISU::TMESH ||
2876 aType == VISU::TSCALARMAP ||
2877 aType == VISU::TDEFORMEDSHAPE ) ) {
2878 thePopup->insertSeparator();
2879 TColStd_MapOfInteger aMapIndex;
2880 aSelection->GetIndex(anIO,aMapIndex);
2881 if ( aSelection->SelectionMode() == SelectionPoint ) {
2882 if(aMapIndex.Extent() == 1)
2883 thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint()));
2884 thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint()));
2886 else if ( aSelection->SelectionMode() == SelectionCell) {
2887 if(aMapIndex.Extent() == 1)
2888 thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell()));
2889 thePopup->insertItem("Select a Cell", visuGUI, SLOT(SelectCell()));
2892 thePopup->insertSeparator();
2894 if (visuGUI->IsDisplayed(aPrsObject) ){
2895 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
2898 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
2900 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
2902 if (aType != VISU::TMESH) {
2903 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2904 thePopup->insertSeparator();
2905 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
2914 // possibly this is the MED field/mesh and support objects
2915 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
2916 if(!CORBA::is_nil(aMED))
2917 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
2918 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2919 if(!CORBA::is_nil(aField))
2920 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
2924 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2925 if(!aSObject->_is_nil()){
2927 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2933 thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
2936 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
2937 // Available only for VTK viewer
2938 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2939 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
2941 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
2942 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
2945 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
2946 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2948 case VISU::TTIMESTAMP: {
2949 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
2950 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
2951 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
2952 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
2953 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
2954 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
2955 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
2956 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
2957 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
2958 if(aNunComponent > 1){
2959 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
2960 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
2961 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
2962 "Vectors...", visuGUI, SLOT(CreateVectors()));
2963 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
2964 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
2971 SALOMEDS::GenericAttribute_var anAttr;
2972 if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
2973 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){
2974 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
2975 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
2978 aSObject = aSObject->GetFather();
2979 aSObject->FindAttribute(anAttr, "AttributeName");
2980 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2981 CORBA::String_var aValue = aName->Value();
2982 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2983 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
2984 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2985 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
2992 //===========================================================================
2993 // BuildPresentation
2994 //===========================================================================
2995 void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
2997 BEGIN_OF("VisuGUI::BuildPresentation");
2999 if (theIO.IsNull()) {
3000 if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3004 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3005 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3007 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
3009 vtkRenderer *Renderer = GetRenderer();
3011 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3013 if (aSObj -> _is_nil() ) {
3014 if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3018 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3019 if(!CORBA::is_nil(anObject)) {
3020 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject));
3021 if ( !aPrsObject ) {
3022 if(MYDEBUG) MESSAGE("The object is not VISU::Prs3d_i");
3025 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3028 SelectedActor = aPrsObject -> CreateActor();
3029 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3030 vf->AddActor(SelectedActor);
3031 }catch(std::runtime_error& exc){
3034 if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3035 END_OF("VisuGUI::BuildPresentation");
3041 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
3043 //if(MYDEBUG) MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID);
3044 return VisuGUI::OnGUIEvent(theCommandID, parent);
3047 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3049 if(MYDEBUG) MESSAGE("VisuGUI::OnKeyPress ");
3050 return VisuGUI::OnKeyPress (pe, parent, studyFrame);
3053 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3055 //if(MYDEBUG) MESSAGE("VisuGUI::OnMousePress ");
3056 return VisuGUI::OnMousePress (pe, parent, studyFrame);
3059 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3061 //if(MYDEBUG) MESSAGE("VisuGUI::OnMouseMove ");
3062 return VisuGUI::OnMouseMove (pe, parent, studyFrame);
3065 bool SetSettings ( QAD_Desktop* parent )
3067 return VisuGUI::setSettings( parent );
3070 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
3071 const QString & theParent, const QString & theObject )
3073 return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
3076 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
3078 VisuGUI::DefinePopup( theContext, theParent, theObject );
3081 bool activeStudyChanged ( QAD_Desktop* parent )
3083 //VisuGUI::activeStudyChanged( parent );
3085 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
3087 VisuGUI::BuildPresentation(theIO);
3090 void supportedViewType(int* buffer, int bufferSize)
3092 if (!buffer || !bufferSize) return;
3093 buffer[0] = (int)VIEW_VTK;
3094 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3099 //////////////////////////////////////////////////////////////////////////////////
3100 //////////////// CHANGE ACTOR COLOR ////////////////////////
3101 //////////////////////////////////////////////////////////////////////////////////
3102 ///////////////// /////////////////////////////////////////////////////////////////
3103 // change actor color
3104 // In : Name of Actor
3108 void VisuGUI::NewColor(VISU_Actor *theActor){
3109 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3110 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3111 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3112 SALOMEDS::Color anOldColor, aNewColor;
3113 int aRepresent = theActor->GetRepresentation();
3117 anOldColor = aMesh->GetNodeColor();
3119 case VISU::WIREFRAME :
3120 case VISU::INSIDEFRAME :
3121 anOldColor = aMesh->GetLinkColor();
3124 case VISU::SURFACEFRAME :
3125 anOldColor = aMesh->GetCellColor();
3128 else if(aDeformedShape)
3129 anOldColor = aDeformedShape->GetColor();
3132 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3133 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3134 if(aColorNew.isValid()){
3135 aNewColor.R = aColorNew.red()/255.;
3136 aNewColor.G = aColorNew.green()/255.;
3137 aNewColor.B = aColorNew.blue()/255.;
3141 aMesh->SetNodeColor(aNewColor);
3143 case VISU::WIREFRAME :
3144 case VISU::INSIDEFRAME :
3145 aMesh->SetLinkColor(aNewColor);
3148 case VISU::SURFACEFRAME :
3149 aMesh->SetCellColor(aNewColor);
3153 aDeformedShape->SetColor(aNewColor);
3154 RecreateActor(aPrs3d);
3159 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3160 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3161 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3162 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3163 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3164 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3165 if(aColorNew.isValid()){
3166 aNewColor.R = aColorNew.red()/255.;
3167 aNewColor.G = aColorNew.green()/255.;
3168 aNewColor.B = aColorNew.blue()/255.;
3169 aMesh->SetLinkColor(aNewColor);
3170 VisuGUI::RecreateActor(aMesh);
3176 //////////////////////////////////////////////////////////////////////////////////
3177 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3178 //////////////////////////////////////////////////////////////////////////////////
3179 //////////////////////////////////////////////////////////////////////////////////
3180 // change actor opacity
3181 // In : Name of Actor
3183 // Use CursorDlg to select a value between 0 and 100
3186 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3189 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3191 float oldopac,newopac;
3193 CursorDlg->Comment1->setText( tr( "Set value between") );
3194 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3195 oldopac=Actor->GetProperty()->GetOpacity();
3196 intopac=int(oldopac*100.);
3197 CursorDlg->SpinBox1->setMinValue(0);
3198 CursorDlg->SpinBox1->setMaxValue(100);
3199 CursorDlg->SpinBox1->setValue(intopac);
3201 int ret = CursorDlg->exec();
3204 intopac = CursorDlg->SpinBox1->value() ;
3205 newopac = intopac/100.;
3206 Actor->GetProperty()->SetOpacity(newopac);
3211 //////////////////////////////////////////////////////////////////////////////////
3212 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3213 //////////////////////////////////////////////////////////////////////////////////
3214 //////////////////////////////////////////////////////////////////////////////////
3215 // change actor linewidth
3216 // In : Name of Actor
3218 // Use CursorDlg to select a value between 0 and 10
3221 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3224 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3226 float oldlwid,newlwid;
3228 CursorDlg->Comment1->setText("Set value between");
3229 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3230 oldlwid=Actor->GetLineWidth();
3231 intlwid=int(oldlwid);
3232 CursorDlg->SpinBox1->setMinValue(1);
3233 CursorDlg->SpinBox1->setMaxValue(10);
3234 CursorDlg->SpinBox1->setValue(intlwid);
3236 int ret = CursorDlg->exec();
3238 intlwid = CursorDlg->SpinBox1->value() ;
3240 Actor->SetLineWidth(newlwid);
3245 /* ======================================================================================== */
3246 /* Setting parameters for Scalar Bar */
3247 /* ======================================================================================== */
3248 void VisuGUI::ChangeScalarBar()
3250 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3251 Scbar->initFromResources();
3252 int ret = Scbar->exec();
3254 Scbar->storeToResources();
3259 /* ======================================================================================== */
3260 /* Setting parameters for Sweeping */
3261 /* ======================================================================================== */
3262 void VisuGUI::SetSweepingPreferences()
3268 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3269 if ( !Tempo.isEmpty() )
3270 tempo = Tempo.toFloat();
3272 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3273 if ( !Cycles.isEmpty() )
3274 cycles = Cycles.toInt();
3276 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3277 if ( !Steps.isEmpty() )
3278 steps = Steps.toInt();
3280 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3282 Sweep->setTimeStep( tempo );
3283 Sweep->setNbCycles( cycles );
3284 Sweep->setNbSteps ( steps );
3286 if ( Sweep->exec() )
3288 tempo = Sweep->getTimeStep();
3289 cycles = Sweep->getNbCycles();
3290 steps = Sweep->getNbSteps();
3292 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3293 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3294 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3299 /* ======================================================================================== */
3300 /* Returns Visu input files directory (default is CSF_PATHData) */
3301 /* ======================================================================================== */
3302 QString VisuGUI::getVisuInputDir()
3304 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3305 if ( Tmp.isEmpty() )
3306 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3307 Tmp = QAD_Tools::addSlash(Tmp);
3311 /* ======================================================================================== */
3312 /* Returns Visu output files directory (default is InputDir) */
3313 /* ======================================================================================== */
3314 QString VisuGUI::getVisuOutputDir()
3316 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3317 if ( Tmp.isEmpty() )
3319 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3320 if ( Tmp2.isEmpty() )
3321 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3325 Tmp = QAD_Tools::addSlash(Tmp);
3330 /* ======================================================================================== */
3331 /* Global Method for Scalar Map */
3332 /* ======================================================================================== */
3333 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3334 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3335 SALOMEDS::SObject_var aSObj = theField->GetFather();
3336 if (CORBA::is_nil(aSObj)) return NULL;
3337 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3338 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3339 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3340 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3341 if(CORBA::is_nil(anObject)) return NULL;
3342 theResult = VISU::Result::_narrow(anObject);
3343 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject));
3345 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3346 tr ("WRN_NO_AVAILABLE_DATA"),
3347 tr ("VISU_BUT_OK"));
3351 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3352 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3353 const char* theMeshName, VISU::Entity theEntity, \
3354 const char* theFieldName, int theTimeId) {\
3355 VISU::Result_var aResult; \
3356 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3357 if(pResult != NULL){ \
3358 if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \
3359 QApplication::setOverrideCursor( Qt::waitCursor ); \
3360 CORBA::Object_var anObject = \
3361 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3362 QApplication::restoreOverrideCursor(); \
3363 if(!CORBA::is_nil(anObject)) \
3364 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject)); \
3367 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3368 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3369 tr ("VISU_BUT_OK") ); \
3373 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3374 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3375 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3376 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3377 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3378 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3379 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3382 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3383 bool FNAME(SALOMEDS::SObject_var theField) { \
3384 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3386 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3387 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3388 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3389 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3390 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3391 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3392 Utils_Timer timer; \
3393 if(MYCHECKTIME) timer.Start(); \
3394 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3397 cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n"; \
3401 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3402 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3403 DLGNAME* aDlg = new DLGNAME(); \
3404 aDlg->initFromPrsObject(pPresent); \
3405 if (aDlg->exec()) { \
3406 aDlg->storeToPrsObject(pPresent); \
3408 DeletePresentation(pPresent); \
3414 CreateActor(pPresent); \
3420 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3421 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3422 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3423 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3424 BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3425 BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3426 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3430 /* ======================================================================================== */
3431 /* Global Method to import tables from file */
3432 /* ======================================================================================== */
3433 void VisuGUI::ImportTablesFromFile(){
3435 flt.append( "Files (*.xls *.txt *.tab)" );
3436 flt.append( "All Files (*.*)" );
3437 QString aDir = getVisuInputDir();
3438 QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3439 aDir,flt,tr("Import From File"),true);
3441 if(aFileInfo.exists()){
3442 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3443 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3444 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3447 CORBA::Object_var anObject;
3453 anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3457 cout<<"VisuGUI::ImportTablesFromFile() - IMPORT FILE\n";
3461 if(CORBA::is_nil(anObject)) {
3463 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3464 tr ("ERR_ERROR_IN_THE_FILE"),
3465 tr ("VISU_BUT_OK") );
3469 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3471 GetActiveStudy()->updateObjBrowser(); //update Object browser
3475 /* ======================================================================================== */
3476 /* Global Method to import mesh results in MED and DAT format */
3477 /* ======================================================================================== */
3478 void VisuGUI::ImportFromFile(){
3479 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3481 //flt.append( "Exportable Files (*.med *.dat)" );
3482 //flt.append( "Dat Files (*.dat)" );
3483 flt.append( "Med Files (*.med)" );
3484 QString aDir = getVisuInputDir();
3485 QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3486 aDir,flt,tr("Import From File"),true);
3488 if(aFileInfo.exists()){
3489 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3490 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3491 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3494 VISU::Result_var aResult;
3500 if(aFileInfo.extension(false) == "med"){
3501 QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3502 bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3504 if (VisuGUI_FileDlg::IsBuild)
3506 aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3507 if(!CORBA::is_nil(aResult.in())) aResult->BuildAll();
3511 QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3512 aResult=GetVisuGen()->ImportFile( aFileInfo.filePath() );
3513 QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3519 cout<<"VisuGUI::ImportFromFile() - IMPORT FILE\n";
3523 if(CORBA::is_nil(aResult.in())) {
3525 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3526 tr ("ERR_ERROR_IN_THE_FILE"),
3527 tr ("VISU_BUT_OK") );
3531 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3533 GetActiveStudy()->updateObjBrowser(); //update Object browser
3537 void VisuGUI::ExportToFile(){
3538 CORBA::Object_var anObject = GetSelectedObj();
3539 if(CORBA::is_nil(anObject)) return;
3540 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject));
3541 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3543 flt.append( "Dat Files (*.dat)" );
3544 flt.append( "Med Files (*.med)" );
3545 QString aDir = getVisuOutputDir();
3546 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3547 aDir,flt,tr("Export To File"),false);
3548 if(!aFile.isEmpty()){
3549 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3550 aDir = QAD_Tools::getDirFromPath(aFile);
3551 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3552 if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3554 //APO - aResult->GetInput()->ToFile(aFile.latin1());
3555 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3557 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3558 tr ("ERR_ERROR_DURING_EXPORT"),
3559 tr ("VISU_BUT_OK") );
3564 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3565 tr ("WRN_NO_AVAILABLE_DATA"),
3566 tr ("VISU_BUT_OK"));
3569 /* ======================================================================================== */
3570 /* Test and Read Object Browser before display */
3571 /* ======================================================================================== */
3572 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3573 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3574 Handle(SALOME_InteractiveObject) anIO;
3575 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3576 if(!anIO.IsNull() && anIO->hasEntry()){
3577 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3578 QString aValue = getValue(objVisu,"myType");
3579 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3581 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3582 tr("WRN_NO_AVAILABLE_DATA"),
3583 tr("VISU_BUT_OK") );
3588 * Returns Actor of presentation if it exists
3590 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3591 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3592 if (!vf) return NULL;
3594 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3595 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3596 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3597 if(thePrs == anVISUActor->GetPrs3d())
3598 return anVISUActor->GetParent();
3603 * Displays only actor of given presentation
3604 * Creates it if it is abcent
3606 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3607 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3608 if (!vf) return NULL;
3610 vtkRenderer *aRen = vf->getRenderer();
3611 vtkActorCollection *anActColl = aRen->GetActors();
3614 VISU_Actor* anVISUActor = NULL;
3615 VISU_Actor* aResActor = NULL;
3616 VISU::Prs3d_i* aSrcAddr = thePrs;
3617 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3618 if(anActor->IsA("VISU_Actor")){
3619 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3620 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
3621 if(aPrs == NULL) continue;
3622 if (thePrs == aPrs) {
3623 aResActor = anVISUActor->GetParent();
3624 thePrs->UpdateActor(aResActor);
3625 aResActor->VisibilityOn();
3627 } else if (theDispOnly) {
3628 anVISUActor->GetParent()->VisibilityOff();
3632 if (aResActor) return aResActor;
3634 anVISUActor = thePrs->CreateActor();
3635 vf->AddActor(anVISUActor);
3636 }catch(std::runtime_error& exc){
3637 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3638 tr ("ERR_CANT_VISUALIZE_OBJECT"),
3639 tr ("VISU_BUT_OK") );
3647 * Returns TRUE if Presentation is displayed
3649 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
3650 VISU_Actor* anVISUActor = GetActor(thePrs);
3651 return (anVISUActor)? anVISUActor->GetVisibility() : false;
3655 * Erases Presentation
3657 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
3658 GetActiveStudy()->unHighlightAll();
3659 VISU_Actor* anVISUActor = GetActor(thePrs);
3661 anVISUActor->VisibilityOff();
3666 * Deletes given presentation from Data structure
3668 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
3669 if(checkLock(GetStudyDocument()) || !thePrs) return;
3670 GetActiveStudy()->unHighlightAll();
3671 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
3672 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
3673 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
3674 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
3675 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
3676 aViewFrame->RemoveActor(anActor);
3681 GetActiveStudy()->updateObjBrowser(); //update Object browser
3685 * Creates new actor of presentation
3687 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
3688 if (!thePrs) return;
3689 QApplication::setOverrideCursor( Qt::waitCursor );
3690 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
3696 VISU_Actor* aActor = thePrs->CreateActor();
3697 vf->AddActor(aActor);
3698 }catch(std::runtime_error& exc){
3699 QApplication::restoreOverrideCursor();
3700 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3701 tr ("WRN_CANT_VISUALIZE_PRS"),
3702 tr ("VISU_BUT_OK") );
3706 cout<<"VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR\n";
3710 QApplication::restoreOverrideCursor();
3715 /* ======================================================================================== */
3716 /* Functions to State of VisuGUI and Dialog Box */
3717 /* ======================================================================================== */
3719 void VisuGUI::SetState(int aState )
3721 this->myState = aState ;
3726 void VisuGUI::ResetState()
3728 this->myState = -1 ;
3732 void VisuGUI::EmitSignalDeactivateDialog()
3734 emit this->SignalDeactivateActiveDialog() ;
3738 void VisuGUI::EmitSignalCloseAllDialogs()
3740 emit this->SignalCloseAllDialogs() ;
3744 QDialog* VisuGUI::GetActiveDialogBox()
3746 return this->myActiveDialogBox ;
3749 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
3751 this->myActiveDialogBox = (QDialog*)aDlg ;