1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
25 // Author : Laurent CORNABE
31 #include "VISU_Gen_i.hh"
32 #include "VISU_Result_i.hh"
33 #include "VISU_PrsObject_i.hh"
34 #include "VISU_ViewManager_i.hh"
36 #include "VISU_PipeLine.hxx"
38 #include "VISU_Prs3d_i.hh"
39 #include "VISU_Mesh_i.hh"
40 #include "VISU_ScalarMap_i.hh"
41 #include "VISU_IsoSurfaces_i.hh"
42 #include "VISU_DeformedShape_i.hh"
43 #include "VISU_CutPlanes_i.hh"
44 #include "VISU_CutLines_i.hh"
45 #include "VISU_Vectors_i.hh"
46 #include "VISU_StreamLines_i.hh"
47 #include "VISU_Table_i.hh"
49 #include "VISU_Actor.h"
50 #include "VISU_MeshAct.h"
52 #include "VisuGUI_MagnitudeDlg.h"
53 #include "VisuGUI_CursorDlg.h"
54 #include "VisuGUI_ScalarBarDlg.h"
55 #include "VisuGUI_SweepPrefDlg.h"
56 #include "VisuGUI_CutPlanesDlg.h"
57 #include "VisuGUI_CutLinesDlg.h"
58 #include "VisuGUI_VectorsDlg.h"
59 #include "VisuGUI_IsoSurfacesDlg.h"
60 #include "VisuGUI_StreamLinesDlg.h"
61 #include "VisuGUI_EditContainerDlg.h"
62 #include "VisuGUI_TimeAnimation.h"
64 #include "VisuGUI_Selection.h"
65 #include "VisuGUI_NonIsometricDlg.h"
67 #include "SALOMEGUI_ImportOperation.h"
68 #include "SALOMEGUI_QtCatchCorbaException.hxx"
69 #include "utilities.h"
71 #include "QAD_Config.h"
73 #include "QAD_Settings.h"
74 #include "QAD_Tools.h"
75 #include "QAD_LeftFrame.h"
76 #include "QAD_RightFrame.h"
77 #include "QAD_MessageBox.h"
78 #include "QAD_ObjectBrowser.h"
79 #include "QAD_ObjectBrowserItem.h"
80 #include "QAD_Menus.h"
81 #include "QAD_Resource.h"
82 #include "QAD_ResourceMgr.h"
83 #include "QAD_FileDlg.h"
84 #include "QAD_WaitCursor.h"
85 #include "SALOME_Selection.h"
86 #include "SALOMEGUI_NameDlg.h"
87 #include "SALOMEGUI_TableDlg.h"
88 #include "SALOMEGUI_SetupCurveDlg.h"
89 #include "SALOMEGUI_SetValueDlg.h"
90 #include "Plot2d_SetupPlot2dDlg.h"
91 #include "Plot2d_ViewFrame.h"
92 #include "VTKViewer_ViewFrame.h"
93 #include "VisuGUI_FileDlg.h"
96 #define INCLUDE_MENUITEM_DEF
97 #include <qpopupmenu.h>
101 #include <qapplication.h>
102 #include <qinputdialog.h>
103 #include <qcolordialog.h>
105 #include <qspinbox.h>
106 #include <qradiobutton.h>
108 #include <qlistbox.h>
109 #include <qcombobox.h>
112 //VRV: porting on Qt 3.0.5
113 #if QT_VERSION >= 0x030005
114 #include <qlistview.h>
116 //VRV: porting on Qt 3.0.5
117 #include <qmessagebox.h>
120 #include CORBA_CLIENT_HEADER(MED_Gen)
122 #include <vtkActor.h>
123 #include <vtkDataSetMapper.h>
125 // Open CASCADE Include
126 #include <TCollection_AsciiString.hxx>
130 static int MYCHECKTIME = 1;
132 static int MYCHECKTIME = 0;
134 #include <Utils_Timer.hxx>
139 static int MYDEBUG = 0;
140 static int MYDEBUGWITHFILES = 0;
142 static int MYDEBUG = 0;
143 static int MYDEBUGWITHFILES = 0;
146 class CustomItem : public QCustomMenuItem{
148 CustomItem( const QString& s, const QFont& f )
149 : string( s ), font( f ){};
152 void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h )
155 p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
160 return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string );
167 static VisuGUI MYVISUGUI;
168 VisuGUI *visuGUI = &MYVISUGUI;
170 VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){
171 VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument());
172 return VISU::VISU_Gen_i::GetVisuGenImpl();
175 static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6],
176 const char* theActorClassName = "VISU_Actor")
178 vtkRenderer *aRen = theViewFrame->getRenderer();
179 vtkActorCollection *anActColl = aRen->GetActors();
182 int nothingVisible=1;
184 allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT;
185 allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT;
186 // loop through all props
187 for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){
188 // if it's invisible, or has no geometry, we can skip the rest
189 if ( prop->GetVisibility() && prop->IsA(theActorClassName)){
190 bounds = prop->GetBounds();
191 // make sure we haven't got bogus bounds
192 if ( bounds != NULL &&
193 bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT &&
194 bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT &&
195 bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT )
198 if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0];
199 if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1];
200 if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2];
201 if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3];
202 if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4];
203 if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5];
207 return nothingVisible;
210 VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){
211 static float PRECISION = 0.000001;
212 static float DEVIATION = 600;
214 if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D;
216 float absX = XYZ_Bnd[1]-XYZ_Bnd[0];
218 float absY = XYZ_Bnd[3]-XYZ_Bnd[2];
220 float absZ = XYZ_Bnd[5]-XYZ_Bnd[4];
222 CameraOrient aCameraOrient = e3D;
223 if(absX <= PRECISION) aCameraOrient = eFront;
224 else {if(absY <= PRECISION) aCameraOrient = eLeft;
225 else {if(absZ <= PRECISION) aCameraOrient = eTop;}}
227 float dev_abs_XY = absX / absY;
228 float dev_abs_YZ = absY / absZ;
229 float dev_abs_XZ = absX / absZ;
230 if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft;
231 else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront;
232 else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}}
234 switch(aCameraOrient){
235 case eFront: theViewFrame->onViewFront(); break;
236 case eLeft: theViewFrame->onViewLeft(); break;
237 case eTop: theViewFrame->onViewTop(); break;
238 case e3D: theViewFrame->onViewReset(); break;
240 theViewFrame->getRenderer()->ResetCameraClippingRange();
241 theViewFrame->onViewFitAll();
244 QAD_Desktop* VisuGUI::GetDesktop(){
245 return QAD_Application::getDesktop() ;
248 QAD_Study* VisuGUI::GetActiveStudy(){
249 return GetDesktop()->getActiveStudy() ;
252 vtkRenderer* VisuGUI::GetRenderer(){
253 if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame())
254 return aViewFrame->getRenderer();
258 VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){
259 QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
260 return dynamic_cast<VTKViewer_ViewFrame*>(aViewFrame);
263 SALOMEDS::Study_var VisuGUI::GetStudyDocument(){
264 return GetActiveStudy()->getStudyDocument();
267 SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){
268 return GetStudyDocument()->NewBuilder();
273 * Finds value by given key
276 VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) {
277 VISU::Storable::TRestoringMap aMap;
278 if(!theSObject->_is_nil()){
279 SALOMEDS::GenericAttribute_var anAttr;
280 if (theSObject->FindAttribute(anAttr, "AttributeComment")) {
281 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
282 CORBA::String_var aString = aComment->Value();
283 QString strIn(aString.in());
284 VISU::Storable::StrToMap(strIn,aMap);
290 QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) {
292 VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject);
294 aStr = VISU::Storable::FindValue(aMap, theKey.latin1());
299 CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL,
300 VISU::Storable::TRestoringMap* pMap = NULL)
302 if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy();
303 SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection());
304 if(aSel->IObjectCount() > 0){
305 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
306 if(pIO != NULL) *pIO = anIO;
307 if(anIO->hasEntry()){
308 SALOMEDS::Study_var aStudy = theStudy->getStudyDocument();
309 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
310 if(!aSObject->_is_nil()){
311 SALOMEDS::GenericAttribute_var anAttr;
312 if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) {
313 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
314 string aComm = aComment->Value();
315 QString strIn(aComm.c_str());
316 VISU::Storable::StrToMap(strIn,*pMap);
318 return VISU::SObjectToObject(aSObject);
322 return CORBA::Object::_nil();
326 int IsTrihedronDisplayed(){
327 if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame())
328 return aVTKViewFrame->isTrihedronDisplayed();
333 void RepaintCurrentView(){
334 if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint();
342 /* ==================================================================================== */
343 /* ==================================================================================== */
345 /* ==================================================================================== */
346 /* ==================================================================================== */
348 static int isStudyLocked(const SALOMEDS::Study_var& theStudy){
349 return theStudy->GetProperties()->IsLocked();
352 static int checkLock(const SALOMEDS::Study_var& theStudy) {
353 if (isStudyLocked(theStudy)) {
354 QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(),
355 QObject::tr("WRN_WARNING"),
356 QObject::tr("WRN_STUDY_LOCKED"),
357 QObject::tr("BUT_OK") );
365 bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent)
368 QString VisuInputDir = getVisuInputDir();
369 QString VisuOutputDir = getVisuOutputDir();
370 vtkRenderer *theRenderer = GetRenderer();
372 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active
373 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
374 SALOMEDS::GenericAttribute_var anAttr;
375 SALOMEDS::AttributeName_var aName;
376 SALOMEDS::AttributeIOR_var anIOR;
378 switch (theCommandID){
379 /* ======================================================================================== */
380 /* Import Table from file */
381 /* ======================================================================================== */
385 if(checkLock(aStudy)) break;
386 visuGUI->ImportTablesFromFile();
390 /* ======================================================================================== */
391 /* Import Mesh from MED, DAT file */
392 /* ======================================================================================== */
396 visuGUI->CopyAndImportFile();
401 visuGUI->ImportFile();
405 /* ======================================================================================== */
406 /* Export results and mesh into a file format */
407 /* ======================================================================================== */
411 //visuGUI->ExportToFile();
415 /* ========================================================================== */
416 /* Visualization of Results : */
417 /* 4011 : Scalar Map */
418 /* 4012 : Deformed Shape */
420 /* 4014 : Iso-Surfaces */
421 /* 4015 : Cut Planes */
422 /* 4016 : Stream Lines */
423 /* ========================================================================== */
426 visuGUI->CreateScalarMap();
429 visuGUI->CreateDeformedShape();
432 visuGUI->CreateVectors();
435 visuGUI->CreateIsoSurfaces();
438 visuGUI->CreateCutPlanes();
441 visuGUI->CreateCutLines();
444 visuGUI->CreateStreamLines();
448 visuGUI->SelectionInfo();
451 /* ========================================================================================================================= */
452 /* Selection - Shape */
453 /* ========================================================================================================================= */
457 /* ========================================================================================================================= */
458 /* Visualization - Wireframe */
459 /* ========================================================================================================================= */
465 /* ========================================================================================================================= */
466 /* Visualization - Surface */
467 /* ========================================================================================================================= */
473 /* ========================================================================================================================= */
474 /* Visualization - Points */
475 /* ========================================================================================================================= */
481 /* ========================================================================================================================= */
482 /* Visualization - Erase */
483 /* ========================================================================================================================= */
489 /* ========================================================================================================================= */
490 /* Visualization - Global */
491 /* ========================================================================================================================= */
495 /* ========================================================================================================================= */
496 /* Visualization - Partial */
497 /* ========================================================================================================================= */
503 //Show dialog that allows to select scale function and corresponding scale factor
504 VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg",
505 FALSE, Qt::WDestructiveClose );
510 /* ============================ */
511 /* POP-UP OBJECTS BROWSER */
512 /* ============================ */
514 case 900 : // Rename object
518 // ---------------- For Popup in Viewer
524 case 803 : // Display only
525 case 903 : // Display only
526 visuGUI->DisplayOnlyPrs();
529 case 901 : // Display
530 visuGUI->DisplayPrs();
533 case 8041 : // Object representation : Wireframe
534 case 9041 : // Object representation : Wireframe
535 visuGUI->ChangeRepresentation(VISU::WIREFRAME);
538 case 8042 : // Object representation : Surface
539 case 9042 : // Object representation : Surface
540 visuGUI->ChangeRepresentation(VISU::SHADED);
543 case 8043 : // Object representation : Points
544 case 9043 : // Object representation : Points
545 visuGUI->ChangeRepresentation(VISU::POINT);
548 case 8044 : // Object representation : Shrink/Unshrink
549 case 9044 : // Object representation : Shrink/Unshrink
550 visuGUI->ChangeRepresentation(VISU::SHRINK);
553 case 8051 : // Change object color
554 case 9051 : // Change object color
555 visuGUI->ChageColor();
558 case 8052 : // Change object opacity
559 case 9052 : // Change object opacity
560 visuGUI->ChangeOpacity();
563 case 8053 : // Change object line width
564 case 9053 : // Change object line width
565 visuGUI->ChangeLines();
568 case 808 : // Sweep IsoSurfaces or Cutplanes
569 case 908 : // Sweep IsoSurfaces or Cutplanes
573 /* ======================================================================================== */
574 /* Preferences for Scalar Bar */
575 /* ======================================================================================== */
582 /* ======================================================================================== */
583 /* Preferences for Sweeping */
584 /* ======================================================================================== */
587 SetSweepingPreferences();
591 /* ======================================================================================== */
592 /* Preferences for Full loading */
593 /* ======================================================================================== */
598 QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp);
599 bool check = !pp->isItemChecked(theCommandID);
600 pp->setItemChecked(theCommandID,check);
601 switch(theCommandID){
603 QAD_CONFIG->addSetting( "Visu:BuildResult", check );
606 QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check );
612 case 113: // Load MED using MED component
614 if (checkLock(GetStudyDocument())) break;
616 Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED");
617 if (CORBA::is_nil(aMedComp)) return false;
618 SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp);
619 if (CORBA::is_nil(aMedGen)) return false;
621 QStringList filtersList ;
623 filtersList.append( tr("MED_MEN_IMPORT_MED") );
624 filtersList.append( tr("MED_MEN_ALL_FILES") ) ;
625 QString aFileName = QAD_FileDlg::getFileName(GetDesktop(),
628 tr("MED_MEN_IMPORT"),
630 if (!aFileName.isEmpty()) {
631 QApplication::setOverrideCursor( Qt::waitCursor );
632 aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle());
633 GetActiveStudy()->updateObjBrowser();
634 QApplication::restoreOverrideCursor();
640 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
641 tr ("MSG_NOT_IMPLEMENTED"),
642 tr ("VISU_BUT_OK") );
645 }catch (const SALOME::SALOME_Exception& S_ex) {
646 QtCatchCorbaException(S_ex);
650 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
651 tr("ERR_UNKNOWN_EXCEPTION"),
659 void VisuGUI::SelectionInfo() {
660 if (mySelectionDlg) {
661 mySelectionDlg->close(true);
664 mySelectionDlg = new VisuGUI_SelectionDlg();
665 mySelectionDlg->show();
671 /* ********************************************************************************** */
672 /* Function ShowTrihedron */
673 /* ********************************************************************************** */
675 void VisuGUI::ShowTrihedron(bool ShowThd){
676 bool ThdIsVisible = true;
677 if( ShowThd && !ThdIsVisible)
678 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
679 if( !ShowThd && ThdIsVisible)
680 ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron();
683 /* ********************************************************************************** */
685 /* Clear all tmp files used in VISU */
686 /* ********************************************************************************** */
689 if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI");
692 /* ********************************************************************************** */
693 /* Function ChangeViewer */
694 /* Change representation of all actors */
695 /* ********************************************************************************** */
697 void VisuGUI::ChangeViewer(int theType){
699 GetActiveStudy()->unHighlightAll();
700 if(vtkRenderer *aRen = GetRenderer()){
702 vtkActorCollection *anActColl = aRen->GetActors();
703 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
704 if(anActor->GetVisibility() > 0)
705 if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){
706 anVISUActor = anVISUActor->GetParent();
708 anVISUActor->SetRepresentation(theType);
710 anVISUActor->VisibilityOff();
713 RepaintCurrentView();
717 // -----------------------------------------------------------------------------------------
719 // -----------------------------------------------------------------------------------------
721 bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
726 // ====================================================================================================================
728 bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
733 // ===================================================================================================================
735 bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
737 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC
740 if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() )
746 if(MYDEBUG) MESSAGE("--> Key : Escape")
758 //=====================================================================================
759 // Slot-functions for presentations creation
760 //=====================================================================================
763 #define CREATEPRESENTATION(FunctionName) \
764 void FunctionName() { \
765 if (checkLock(GetStudyDocument())) return; \
766 SALOMEDS::SObject_var objVisu; \
767 if (!TestObjectBrowser(objVisu)) return; \
768 if(!FunctionName(objVisu)) return; \
769 GetActiveStudy()->updateObjBrowser(); \
770 GetDesktop()->putInfo("Ready"); \
771 VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \
773 /*vf->getRenderer()->ResetCameraClippingRange();*/ \
774 vf->onViewFitAll(); \
779 CREATEPRESENTATION(VisuGUI::CreateScalarMap);
780 CREATEPRESENTATION(VisuGUI::CreateDeformedShape);
781 CREATEPRESENTATION(VisuGUI::CreateVectors);
782 CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces);
783 CREATEPRESENTATION(VisuGUI::CreateCutPlanes);
784 CREATEPRESENTATION(VisuGUI::CreateCutLines);
785 CREATEPRESENTATION(VisuGUI::CreateStreamLines);
790 //=====================================================================================
791 // function : setSettings()
793 //=====================================================================================
794 bool VisuGUI::setSettings(QAD_Desktop* parent)
798 QMenuItem* item = parent->menuBar()->findItem(anId,&pp);
799 QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult");
801 if(aValue.isEmpty()? 0 : aValue.toInt())
802 pp->setItemChecked(anId, true);
805 item = parent->menuBar()->findItem(anId,&pp);
806 aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
808 if(aValue.isEmpty()? 0 : aValue.toInt())
809 pp->setItemChecked(anId, true);
814 //=====================================================================================
815 // function : DisplayPrs()
817 //=====================================================================================
818 void VisuGUI::DisplayPrs() {
819 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
820 Handle(SALOME_InteractiveObject) anIO;
821 CORBA::Object_var anObject = GetSelectedObj(&anIO);
822 if ( !CORBA::is_nil( anObject ) ) {
823 // is it Prs3d object ?
824 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
826 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
827 UpdateViewer(aPrsObject);
828 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
829 vf->getRenderer()->ResetCameraClippingRange();
831 vf->highlight(anIO, 1);
836 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
838 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
839 PlotCurve(aCurve, VISU::eDisplay );
843 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
845 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
846 PlotContainer(aContainer, VISU::eDisplay );
850 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
852 if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
853 PlotTable(aTable, VISU::eDisplay );
859 //=====================================================================================
860 // function : DisplayOnlyPrs()
862 //=====================================================================================
863 void VisuGUI::DisplayOnlyPrs() {
864 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs");
865 CORBA::Object_var anObject = GetSelectedObj();
866 if ( !CORBA::is_nil( anObject ) ) {
867 // is it Prs3d object ?
868 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
869 if(VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in())){
870 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object");
871 UpdateViewer(aPrsObject, true);
872 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
874 vf->getRenderer()->ResetCameraClippingRange();
877 }else if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aServant.in())){
878 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object");
879 PlotCurve(aCurve, VISU::eDisplayOnly );
880 }else if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in())){
881 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object");
882 PlotContainer(aContainer, VISU::eDisplayOnly );
883 }else if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aServant.in())){
884 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object");
885 PlotTable(aTable, VISU::eDisplayOnly );
890 //=====================================================================================
891 // function : ErasePrs()
893 //=====================================================================================
894 void VisuGUI::ErasePrs() {
895 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs");
896 CORBA::Object_var anObject = GetSelectedObj();
897 if ( !CORBA::is_nil( anObject ) ) {
898 // is it Prs3d object ?
899 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
901 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Prs3d object");
902 ErasePrs(aPrsObject);
903 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
909 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
911 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Curve object");
912 PlotCurve(aCurve, VISU::eErase );
915 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
917 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Container object");
918 PlotContainer(aContainer, VISU::eErase );
921 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
923 if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Table object");
924 PlotTable(aTable, VISU::eErase );
929 //=====================================================================================
930 // function : DisplayManyPrs()
932 //=====================================================================================
933 void VisuGUI::DisplayManyPrs()
935 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
936 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
937 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
938 for ( ; It.More(); It.Next() ) {
939 Handle(SALOME_InteractiveObject)& anIO = It.Value();
940 if ( anIO->hasEntry() ) {
941 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
942 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
943 VISU::Storable::TRestoringMap pMap;
944 if( !aSObject->_is_nil() ) {
945 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
946 if ( !CORBA::is_nil( aCORBAObject ) ) {
947 // is it Prs3d object ?
948 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
950 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
951 UpdateViewer(aPrsObject);
952 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
954 vf->getRenderer()->ResetCameraClippingRange();
956 vf->highlight(anIO, 1);
961 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
963 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
964 PlotCurve(aCurve, VISU::eDisplay );
968 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
970 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
971 PlotContainer(aContainer, VISU::eDisplay );
975 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
977 if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
978 PlotTable(aTable, VISU::eDisplay );
987 //=====================================================================================
988 // function : DisplayOnlyManyPrs()
990 //=====================================================================================
991 void VisuGUI::DisplayOnlyManyPrs() {
992 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs");
993 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
994 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
995 bool aFirstElem = true;
996 for ( ; It.More(); It.Next() ) {
997 Handle(SALOME_InteractiveObject)& anIO = It.Value();
998 if ( anIO->hasEntry() ) {
999 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1000 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1001 VISU::Storable::TRestoringMap pMap;
1002 if( !aSObject->_is_nil() ) {
1003 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1004 if ( !CORBA::is_nil( aCORBAObject ) ) {
1005 // is it Prs3d object ?
1006 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1008 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object");
1009 UpdateViewer(aPrsObject, aFirstElem);
1010 if (aFirstElem) aFirstElem = false;
1011 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1013 vf->getRenderer()->ResetCameraClippingRange();
1015 vf->highlight(anIO, 1);
1020 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1022 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object");
1024 PlotCurve(aCurve, VISU::eDisplayOnly );
1027 else PlotCurve(aCurve, VISU::eDisplay );
1030 // is it Container ?
1031 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1033 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object");
1035 PlotContainer(aContainer, VISU::eDisplayOnly );
1038 else PlotContainer(aContainer, VISU::eDisplay );
1042 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1044 if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object");
1046 PlotTable(aTable, VISU::eDisplayOnly );
1049 else PlotTable(aTable, VISU::eDisplay );
1059 //=====================================================================================
1060 // function : EraseManyPrs()
1062 //=====================================================================================
1063 void VisuGUI::EraseManyPrs()
1065 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
1066 SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
1067 SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
1068 SALOME_ListIteratorOfListIO It( LIO );
1069 for ( ; It.More(); It.Next() ) {
1070 Handle(SALOME_InteractiveObject)& anIO = It.Value();
1071 if ( anIO->hasEntry() ) {
1072 SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
1073 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
1074 VISU::Storable::TRestoringMap pMap;
1075 if( !aSObject->_is_nil() ) {
1076 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
1077 if ( !CORBA::is_nil( aCORBAObject ) ) {
1078 // is it Prs3d object ?
1079 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
1081 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
1082 ErasePrs(aPrsObject);
1083 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
1090 VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
1092 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
1093 PlotCurve(aCurve, VISU::eErase );
1096 // is it Container ?
1097 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
1099 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
1100 PlotContainer(aContainer, VISU::eErase );
1104 VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
1106 if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
1107 PlotTable(aTable, VISU::eErase );
1116 //=====================================================================================
1117 // function : RecreateActor()
1119 //=====================================================================================
1120 void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) {
1121 QApplication::setOverrideCursor(Qt::waitCursor);
1124 //UpdateViewer(thePrs); Avoid unnessary settings of visibility on for thePrs
1125 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1126 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1127 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1128 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame))
1129 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame))
1130 thePrs->UpdateActor(anActor);
1132 }catch(std::runtime_error& ex){
1133 QApplication::restoreOverrideCursor();
1135 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1136 tr ("ERR_CANT_BUILD_PRESENTATION"),
1137 tr ("VISU_BUT_OK") );
1138 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
1139 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
1140 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
1141 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)) {
1142 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) {
1143 aViewFrame->RemoveActor(anActor);
1150 QApplication::restoreOverrideCursor();
1154 //=====================================================================================
1155 // function : EditPrs()
1157 //=====================================================================================
1158 #define EDITPRS(PrsName, DlgName) \
1160 PrsName* aPrsObject = dynamic_cast<PrsName*>(aPrs3d); \
1162 DlgName* aDlg = new DlgName(); \
1163 aDlg->initFromPrsObject(aPrsObject); \
1164 if ( aDlg->exec() ) { \
1165 if(!(aDlg->storeToPrsObject(aPrsObject))){ \
1169 RecreateActor(aPrsObject); \
1170 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \
1171 if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \
1172 vf->getRenderer()->ResetCameraClippingRange(); \
1181 void VisuGUI::EditPrs() {
1182 VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d();
1184 switch (aPrs3d->GetType()) {
1185 case VISU::TMESH: // Mesh 13
1188 case VISU::TSCALARMAP: // ScalarMap 18
1189 EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg);
1192 case VISU::TDEFORMEDSHAPE: // Deformed Shape 28
1193 EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg);
1196 case VISU::TCUTPLANES: // Cut planes 42
1197 //EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg);
1199 VISU::CutPlanes_i* aPrsObject = dynamic_cast<VISU::CutPlanes_i*>(aPrs3d);
1201 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(false, false);
1202 aDlg->initFromPrsObject(aPrsObject);
1204 myActiveDialogBox = aDlg;
1205 // if ( aDlg->exec() ) {
1206 // if(!(aDlg->storeToPrsObject(aPrsObject))){
1210 // RecreateActor(aPrsObject);
1211 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1212 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1213 // vf->getRenderer()->ResetCameraClippingRange();
1223 case VISU::TCUTLINES: // Cut planes 42
1224 //EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg);
1226 VISU::CutLines_i* aPrsObject = dynamic_cast<VISU::CutLines_i*>(aPrs3d);
1228 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(false);
1229 aDlg->initFromPrsObject(aPrsObject);
1231 myActiveDialogBox = aDlg;
1232 // if ( aDlg->exec() ) {
1233 // aDlg->storeToPrsObject(aPrsObject);
1234 // RecreateActor(aPrsObject);
1235 // if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
1236 // if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
1237 // vf->getRenderer()->ResetCameraClippingRange();
1241 // // Remove old Table
1242 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1243 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(aPrsObject->GetEntry());
1244 // if(!aSObject->_is_nil()) {
1245 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1246 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1247 // for ( ;aIter->More(); aIter->Next()) {
1248 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1249 // if (!aTblObj->_is_nil()) {
1250 // SALOMEDS::GenericAttribute_var anAttr;
1251 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1252 // aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
1257 // if (aDlg->isGenerateTable()) {
1258 // GetVisuGen()->CreateTable(aSObject->GetID());
1259 // if (aDlg->isGenerateCurves()) {
1260 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1261 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
1262 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
1263 // for ( ;aIter->More(); aIter->Next()) {
1264 // SALOMEDS::SObject_var aTblObj = aIter->Value();
1265 // if (!aTblObj->_is_nil()) {
1266 // SALOMEDS::GenericAttribute_var anAttr;
1267 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
1268 // CreatePlot(aTblObj);
1275 // GetActiveStudy()->updateObjBrowser();
1283 case VISU::TISOSURFACE: // Iso surfaces
1284 EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg);
1286 case VISU::TVECTORS: // Vectors 64
1287 EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg);
1290 case VISU::TSTREAMLINES:
1291 EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg);
1297 Handle(SALOME_InteractiveObject) anIO;
1298 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1299 if ( !CORBA::is_nil( anObject ) )
1300 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1301 vf->highlight(anIO, 1);
1305 //=====================================================================================
1306 // function : CreateMesh()
1308 //=====================================================================================
1309 void VisuGUI::CreateMesh() {
1310 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1311 SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1313 if (checkLock(GetStudyDocument())) return;
1315 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1316 aSObj = aSObj->GetFather();
1317 aSObj = aSObj->GetFather();
1318 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1319 if(CORBA::is_nil(anObject)) {
1320 aSObj = aSObj->GetFather();
1321 anObject = VISU::SObjectToObject(aSObj);
1323 VISU::Result_var aResult;
1324 if (!CORBA::is_nil(anObject)) {
1325 aResult = VISU::Result::_narrow(anObject);
1327 if(CORBA::is_nil(aResult)) {
1328 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1329 tr ("WRN_NO_AVAILABLE_DATA"),
1330 tr ("VISU_BUT_OK"));
1333 VISU::Storable::TRestoringMap aMap;
1334 SALOMEDS::GenericAttribute_var anAttr;
1335 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1336 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1337 string aComm = aComment->Value();
1338 QString strIn(aComm.c_str());
1339 VISU::Storable::StrToMap(strIn,aMap);
1342 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1343 if(!isExist) return;
1344 CORBA::Object_var aMesh;
1345 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1350 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(aResult.in()).in());
1351 if(aComment == "ENTITY"){
1352 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1353 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
1354 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1355 }else if(aComment == "FAMILY"){
1356 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1357 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1358 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
1359 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1360 }else if(aComment == "GROUP"){
1361 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1362 if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
1363 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1367 cout<<"VisuGUI::CreateMesh() - CREATE MESH\n";
1371 QApplication::restoreOverrideCursor();
1372 VISU::Mesh_i* pPresent = NULL;
1373 if(!CORBA::is_nil(aMesh))
1374 pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1375 if (pPresent == NULL) {
1376 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1377 tr ("ERR_CANT_BUILD_PRESENTATION"),
1378 tr ("VISU_BUT_OK") );
1382 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1384 VISU_Actor *anActor = pPresent->CreateActor();
1389 vf->AddActor(anActor);
1393 cout<<"VisuGUI::CreateMesh() - DISPLAY MESH\n";
1396 //GetActiveStudy()->updateObjBrowser(); //not necessary
1397 GetDesktop()->putInfo("Ready");
1398 }catch(std::runtime_error& exc){
1400 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
1401 tr ("ERR_CANT_CREATE_ACTOR"),
1402 tr ("VISU_BUT_OK") );
1407 //=====================================================================================
1408 // function : CreateManyMesh()
1410 //=====================================================================================
1411 void VisuGUI::CreateManyMesh(){
1412 if (checkLock(GetStudyDocument())) return;
1414 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
1415 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
1416 for ( ; It.More(); It.Next() ) {
1417 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry());
1418 SALOMEDS::SObject_var aSObj = aSObject->GetFather();
1419 aSObj = aSObj->GetFather();
1420 aSObj = aSObj->GetFather();
1421 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
1422 if(CORBA::is_nil(anObject)) {
1423 aSObj = aSObj->GetFather();
1424 anObject = VISU::SObjectToObject(aSObj);
1425 if(CORBA::is_nil(anObject)) return;
1427 VISU::Result_var aResult = VISU::Result::_narrow(anObject);
1428 if(CORBA::is_nil(aResult)) return;
1430 VISU::Storable::TRestoringMap aMap;
1431 SALOMEDS::GenericAttribute_var anAttr;
1432 if(aSObject->FindAttribute(anAttr, "AttributeComment")) {
1433 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
1434 string aComm = aComment->Value();
1435 QString strIn(aComm.c_str());
1436 VISU::Storable::StrToMap(strIn,aMap);
1439 string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1();
1440 if(!isExist) return;
1441 CORBA::Object_var aMesh;
1442 string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1();
1443 if(aComment == "ENTITY"){
1444 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt();
1445 aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
1446 }else if(aComment == "FAMILY"){
1447 VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt();
1448 string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1();
1449 aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
1450 }else if(aComment == "GROUP"){
1451 string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1();
1452 aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
1454 QApplication::restoreOverrideCursor();
1455 if(CORBA::is_nil(aMesh)) return;
1457 VISU::Mesh_i* pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
1459 VISU_Actor *anActor = pPresent->CreateActor();
1460 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
1461 vf->AddActor(anActor);
1464 GetDesktop()->putInfo("Ready");
1465 }catch(std::runtime_error& exc){
1471 //=====================================================================================
1472 // function : ChangeRepresentation()
1474 //=====================================================================================
1476 static void ShrinkMesh(VISU_Actor *theActor){
1477 if(theActor->IsShrunk())
1478 theActor->UnShrink();
1480 theActor->SetShrink(0.8);
1483 void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) {
1484 if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d())
1485 if(VISU_Actor* anActor = GetActor(aPrsObject)){
1488 ShrinkMesh(anActor);
1491 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrsObject)){
1492 aMesh->SetPresentationType(theType);
1493 RecreateActor(aMesh);
1495 anActor->SetRepresentation(theType);
1497 if (VTKViewer_ViewFrame* vf = GetVtkViewFrame())
1503 void VisuGUI::MakeSurfaceframe() {
1504 ChangeRepresentation(VISU::SURFACEFRAME);
1507 void VisuGUI::MakeInsideframe() {
1508 ChangeRepresentation(VISU::INSIDEFRAME);
1511 void VisuGUI::MakeWireframe() {
1512 ChangeRepresentation(VISU::WIREFRAME);
1515 void VisuGUI::MakeSurface() {
1516 ChangeRepresentation(VISU::SHADED);
1519 void VisuGUI::MakePoints() {
1520 ChangeRepresentation(VISU::POINT);
1523 void VisuGUI::MakeShrink() {
1524 ChangeRepresentation(VISU::SHRINK);
1529 //=====================================================================================
1530 // functions : Change Propertise
1532 //=====================================================================================
1533 VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) {
1534 CORBA::Object_var anObject = GetSelectedObj(theIO);
1535 if(CORBA::is_nil(anObject)) return NULL;
1536 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
1537 if(!aServant.in()) return NULL;
1538 return dynamic_cast<VISU::Prs3d_i*>(aServant.in());
1541 void VisuGUI::ChageColor() {
1542 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1543 if(!aPrsObject) return;
1545 VISU_Actor* anActor = GetActor(aPrsObject);
1546 if (!anActor) return;
1550 void VisuGUI::ChangeWireframeColor() {
1551 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1552 if(!aPrsObject) return;
1554 VISU_MeshAct* anActor = dynamic_cast<VISU_MeshAct*>(GetActor(aPrsObject));
1555 if (!anActor) return;
1556 NewWireframeColor(anActor);
1560 void VisuGUI::ChangeOpacity() {
1561 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1562 if(!aPrsObject) return;
1564 VISU_Actor* anActor = GetActor(aPrsObject);
1565 if (!anActor) return;
1566 NewOpacity(anActor);
1570 void VisuGUI::ChangeLines() {
1571 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
1572 if(!aPrsObject) return;
1574 VISU_Actor* anActor = GetActor(aPrsObject);
1575 if (!anActor) return;
1576 NewLinewidth(anActor);
1578 void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying )
1580 if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1581 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1582 if ( theDisplaying == VISU::eDisplayOnly )
1584 QList<Plot2d_Curve> clist;
1585 aPlot->getCurves( clist );
1586 SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() );
1587 if ( !TableSO->_is_nil() ) {
1588 SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO );
1589 for ( ; Iter->More(); Iter->Next() ) {
1590 CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() );
1591 if( !CORBA::is_nil( childObject ) ) {
1592 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject );
1593 if( !CORBA::is_nil( aCurve ) ) {
1594 VISU::Curve_i* theCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
1595 Plot2d_Curve* plotCurve = 0;
1596 for ( int i = 0; i < clist.count(); i++ ) {
1597 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1598 plotCurve = clist.at( i );
1602 if ( theDisplaying == VISU::eErase ) {
1604 aPlot->eraseCurve( plotCurve, false );
1605 clist.remove( plotCurve );
1608 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1610 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1611 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1612 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1613 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1614 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1615 /* - DATA NOT UPDATED */
1616 if ( !plotCurve->isAutoAssign() ) {
1617 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1618 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1619 SALOMEDS::Color color = theCurve->GetColor();
1620 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1621 plotCurve->setAutoAssign( theCurve->IsAuto() );
1623 aPlot->displayCurve( plotCurve, false );
1626 Plot2d_Curve* crv = theCurve->CreatePresentation();
1628 aPlot->displayCurve( crv, false );
1629 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1630 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1631 SALOMEDS::Color newColor;
1632 newColor.R = crv->getColor().red()/255.;
1633 newColor.G = crv->getColor().green()/255.;
1634 newColor.B = crv->getColor().blue()/255.;
1635 theCurve->SetColor( newColor );
1646 void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying )
1648 if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1649 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1650 // if ( theDisplaying == VISU::eDisplayOnly )
1651 // aPlot->EraseAll();
1652 QList<Plot2d_Curve> clist;
1653 aPlot->getCurves( clist );
1654 Plot2d_Curve* plotCurve = 0;
1655 for ( int i = 0; i < clist.count(); i++ ) {
1656 if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1657 plotCurve = clist.at( i );
1659 else if ( theDisplaying == VISU::eDisplayOnly ) {
1660 aPlot->eraseCurve( clist.at( i ) );
1663 if ( theDisplaying == VISU::eErase ) {
1665 aPlot->eraseCurve( plotCurve, false );
1667 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1669 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1670 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1671 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1672 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1673 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1674 /* DATA NOT UPDATED */
1675 if ( !plotCurve->isAutoAssign() ) {
1676 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1677 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1678 SALOMEDS::Color color = theCurve->GetColor();
1679 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1680 plotCurve->setAutoAssign( theCurve->IsAuto() );
1682 aPlot->displayCurve( plotCurve, false );
1685 Plot2d_Curve* crv = theCurve->CreatePresentation();
1687 aPlot->displayCurve( crv, false );
1688 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1689 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1690 SALOMEDS::Color newColor;
1691 newColor.R = crv->getColor().red()/255.;
1692 newColor.G = crv->getColor().green()/255.;
1693 newColor.B = crv->getColor().blue()/255.;
1694 theCurve->SetColor( newColor );
1701 void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying )
1703 if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
1704 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame();
1705 if ( theDisplaying == VISU::eDisplayOnly )
1707 QList<Plot2d_Curve> clist;
1708 aPlot->getCurves( clist );
1709 if ( container->GetNbCurves() > 0 ) {
1710 int nbCurves = container->GetNbCurves();
1711 for ( int k = 1; k <= nbCurves; k++ ) {
1712 VISU::Curve_i* theCurve = container->GetCurve( k );
1713 if ( theCurve && theCurve->IsValid() ) {
1714 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) );
1715 // for ( int i = 0; i < clist.count(); i++ ) {
1716 // if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) {
1717 // plotCurve = clist.at( i );
1721 if ( theDisplaying == VISU::eErase ) {
1723 aPlot->eraseCurve( plotCurve, false );
1724 clist.remove( plotCurve );
1727 else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) {
1729 plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) );
1730 //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) );
1731 plotCurve->setVerTitle( strdup( theCurve->GetName() ) );
1732 plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) );
1733 plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) );
1734 /* - DATA NOT UPDATED */
1735 if ( !plotCurve->isAutoAssign() ) {
1736 plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() );
1737 plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() );
1738 SALOMEDS::Color color = theCurve->GetColor();
1739 plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
1740 plotCurve->setAutoAssign( theCurve->IsAuto() );
1742 aPlot->displayCurve( plotCurve, false );
1745 Plot2d_Curve* crv = theCurve->CreatePresentation();
1747 aPlot->displayCurve( crv, false );
1748 theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() );
1749 theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker());
1750 SALOMEDS::Color newColor;
1751 newColor.R = crv->getColor().red()/255.;
1752 newColor.G = crv->getColor().green()/255.;
1753 newColor.B = crv->getColor().blue()/255.;
1754 theCurve->SetColor( newColor );
1766 Slot : opens Table view : for Table object or SObject with table attribute selected
1768 void VisuGUI::ShowTable() {
1769 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1770 if( Sel->IObjectCount() !=1 )
1772 Handle(SALOME_InteractiveObject) anIO;
1773 CORBA::Object_var anObject = GetSelectedObj(&anIO);
1774 SALOMEDS::SObject_var SO;
1775 if ( !CORBA::is_nil( anObject ) ) {
1776 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1777 if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
1778 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
1779 if( !CORBA::is_nil( aTable ) ) {
1780 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
1782 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1787 // possibly this is Table SObject
1788 SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() );
1790 SALOMEDS::GenericAttribute_var anAttr;
1791 if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" )
1792 && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) )
1794 SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(),
1797 //SAL2670 Orientation of show tables
1798 SALOMEGUI_TableDlg::ttAuto,
1805 Slot : opens Table view : for Table object or SObject with table attribute selected
1807 void VisuGUI::CreateTable() {
1808 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1809 if( aSel->IObjectCount() !=1 )
1812 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1813 if (anIO->hasEntry()){
1814 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
1815 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1816 if(!aSObject->_is_nil()) {
1817 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
1818 VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
1819 SALOMEDS::GenericAttribute_var anAttr;
1820 if(!aCutLines->_is_nil() ||
1821 aSObject->FindAttribute( anAttr, "AttributeTableOfInteger") ||
1822 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )) {
1823 GetVisuGen()->CreateTable(aSObject->GetID());
1824 GetActiveStudy()->updateObjBrowser();
1832 Slot : deletes SObject with all subobjects
1834 void VisuGUI::DeleteObject() {
1835 SALOMEDS::Study_var aStudy = GetStudyDocument();
1836 if (checkLock(aStudy)) return;
1838 SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1839 if( aSel->IObjectCount() !=1 )
1841 Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
1842 if (anIO->hasEntry()){
1843 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
1844 if(!aSObject->_is_nil()){
1845 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
1846 // There is a transaction
1847 aStudyBuilder->NewCommand();
1848 CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
1849 if(!CORBA::is_nil(anObj)){
1850 VISU::Base_var aBase = VISU::Base::_narrow(anObj);
1851 if(!CORBA::is_nil(aBase)){
1852 VISU::VISUType aType = aBase->GetType();
1854 case VISU::TRESULT:{
1855 SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
1856 for(aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()){
1857 SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
1858 CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
1859 if(CORBA::is_nil(aChildObj)) continue;
1860 VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
1861 if(CORBA::is_nil(aPrs3d)) continue;
1862 VISU::Prs3d_i* pPrs3d = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aPrs3d).in());
1863 DeletePresentation(pPrs3d);
1869 aStudyBuilder->RemoveObjectWithChildren(aSObject);
1870 aStudyBuilder->CommitCommand();
1871 GetActiveStudy()->unHighlightAll();
1872 GetActiveStudy()->updateObjBrowser(true);
1879 Slot : deletes empty container
1881 void VisuGUI::CreatePlot2dView() {
1882 if (checkLock(GetStudyDocument())) return;
1883 GetVisuGen()->CreateContainer();
1884 GetActiveStudy()->updateObjBrowser( true );
1890 Opens dialog box for curves creation. Acts only for selected SObject with table attribute.
1892 void VisuGUI::PlotData() {
1893 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
1894 if( Sel->IObjectCount() !=1 )
1896 CORBA::Object_var anObject = GetSelectedObj();
1897 SALOMEDS::SObject_var SO;
1898 if ( !CORBA::is_nil( anObject ) ) {
1899 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
1900 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
1901 // Table (VISU object) is selected
1902 CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
1903 if( !CORBA::is_nil( aTbl ) ) {
1904 VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
1906 SALOMEDS::GenericAttribute_var anAttr;
1907 SALOMEDS::AttributeName_var aName;
1909 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() );
1910 if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
1911 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
1912 // get name of SObject
1913 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1914 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1915 SOName = strdup( aName->Value() );
1917 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1918 if ( dlg->exec() == QDialog::Accepted ) {
1919 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1920 // if study is not locked - create new container, create curves
1921 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1923 QValueList<int> verIndices;
1924 dlg->getCurvesSource( horIndex, verIndices );
1925 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1926 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1927 if( !CORBA::is_nil( aContainer ) ) {
1928 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
1930 for ( int i = 0; i < verIndices.count(); i++ ) {
1931 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 );
1932 if( !CORBA::is_nil( aNewCurve ) ) {
1933 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
1936 int marker, line, lineWidth;
1938 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
1939 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
1940 pCrv->SetColor( c );
1941 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
1942 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
1944 pContainer->AddCurve( pCrv->_this() );
1948 GetActiveStudy()->updateObjBrowser( true );
1949 PlotContainer( pContainer, VISU::eDisplay );
1955 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
1956 Plot2d_CurveContainer container;
1957 dlg->getCurves( container );
1958 if ( !container.isEmpty() ) {
1959 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1960 getRightFrame()->getViewFrame()))->displayCurves( container, true );
1961 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
1962 getRightFrame()->getViewFrame()))->setTitle( SOName );
1973 // possibly this is Table SObject
1974 SALOMEDS::GenericAttribute_var anAttr;
1975 SALOMEDS::AttributeName_var aName;
1978 // check if Table SObject is selected
1979 SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
1980 if ( !SO->_is_nil() &&
1981 ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
1982 SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
1983 // get name of SObject
1984 if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
1985 aName = SALOMEDS::AttributeName::_narrow( anAttr );
1986 SOName = strdup( aName->Value() );
1988 Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() );
1989 if ( dlg->exec() == QDialog::Accepted ) {
1990 if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
1991 // if study is not locked - create new table and container objects, create curves
1992 // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
1994 QValueList<int> verIndices;
1995 dlg->getCurvesSource( horIndex, verIndices );
1996 if ( horIndex >= 0 && verIndices.count() > 0 ) {
1997 CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() );
1998 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
1999 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2000 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2001 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2003 if ( pContainer && pTable ) {
2004 for ( int i = 0; i < verIndices.count(); i++ ) {
2005 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 );
2006 if( !CORBA::is_nil( aNewCurve ) ) {
2007 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
2010 int marker, line, lineWidth;
2012 if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) {
2013 SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.;
2014 pCrv->SetColor( c );
2015 pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
2016 pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
2018 pContainer->AddCurve( pCrv->_this() );
2022 GetActiveStudy()->updateObjBrowser( true );
2023 PlotContainer( pContainer, VISU::eDisplay );
2028 // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type
2029 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2030 Plot2d_CurveContainer container;
2031 dlg->getCurves( container );
2032 if ( !container.isEmpty() ) {
2033 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2034 getRightFrame()->getViewFrame()))->displayCurves( container, true );
2035 ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()->
2036 getRightFrame()->getViewFrame()))->setTitle( SOName );
2047 void VisuGUI::CreatePlot(SALOMEDS::SObject_var theTableSO) {
2048 SALOMEDS::GenericAttribute_var anAttr;
2049 SALOMEDS::AttributeName_var aName;
2051 if ( !theTableSO->_is_nil() &&
2052 ( theTableSO->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
2053 theTableSO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) {
2054 CORBA::Object_var aTable = VISU::SObjectToObject(theTableSO);
2055 CORBA::Object_var aContainer = GetVisuGen()->CreateContainer();
2056 if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
2057 VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
2058 VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>( VISU::GetServant(aContainer).in() );
2060 if ( pContainer && pTable ) {
2061 for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
2062 CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), 1, i );
2063 if( !CORBA::is_nil( aNewCurve ) ) {
2064 VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
2066 pContainer->AddCurve( pCrv->_this() );
2070 GetActiveStudy()->updateObjBrowser( true );
2071 PlotContainer( pContainer, VISU::eDisplay );
2079 Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected
2081 void VisuGUI::CurveProperties() {
2082 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2083 if( Sel->IObjectCount() !=1 )
2085 CORBA::Object_var anObject = GetSelectedObj();
2086 SALOMEDS::SObject_var SO;
2087 if (CORBA::is_nil( anObject )) return;
2089 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2090 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2092 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2093 if( !CORBA::is_nil( aCurve ) ) {
2094 VISU::Curve_i* curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2095 if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2096 SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() );
2097 dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() );
2098 dlg->setMarker( (int)curve->GetMarker() );
2099 SALOMEDS::Color color = curve->GetColor();
2100 dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) );
2101 if( dlg->exec() == QDialog::Accepted ) {
2102 curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2103 curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker());
2104 SALOMEDS::Color newColor;
2105 newColor.R = dlg->getColor().red()/255.;
2106 newColor.G = dlg->getColor().green()/255.;
2107 newColor.B = dlg->getColor().blue()/255.;
2108 curve->SetColor( newColor );
2109 QList<QAD_StudyFrame> sfList = GetActiveStudy()->getStudyFrames();
2110 if ( sfList.count() > 0 ) {
2111 QListIterator<QAD_StudyFrame> it( sfList );
2112 for ( ; it.current(); ++it ) {
2113 if ( it.current()->getTypeView() == VIEW_PLOT2D ) {
2114 Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame();
2115 Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() );
2118 Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO );
2120 plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() );
2121 plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() );
2122 plotCurve->setColor( dlg->getColor() );
2123 aPlot->updateCurve( plotCurve, true );
2136 Slot : Clears container contents : for Container object selected
2138 void VisuGUI::ClearContainer() {
2139 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2140 if( Sel->IObjectCount() !=1 )
2143 CORBA::Object_var anObject = GetSelectedObj();
2144 SALOMEDS::SObject_var SO;
2145 if (CORBA::is_nil( anObject )) return;
2147 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2148 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2150 CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2151 if( !CORBA::is_nil( aCnt ) ) {
2152 VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2153 if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) {
2155 GetActiveStudy()->updateObjBrowser();
2162 Slot : Edit container contents : for Container object selected
2164 void VisuGUI::EditContainer() {
2165 CORBA::Object_var anObject = GetSelectedObj();
2166 if(CORBA::is_nil(anObject)) return;
2167 PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
2168 if(!aServant.in()) return;
2169 VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
2170 if(!aContainer) return;
2172 VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg();
2173 aDlg->initFromPrsObject(aContainer);
2175 aDlg->storeToPrsObject(aContainer);
2176 GetActiveStudy()->updateObjBrowser( true );
2182 void VisuGUI::DeletePrs() {
2183 SALOMEDS::Study_var aStudy = GetStudyDocument();
2184 if (checkLock(aStudy)) return;
2186 // There is a transaction
2187 SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
2188 aStudyBuilder->NewCommand();
2190 DeletePresentation(GetSelectedPrs3d());
2192 aStudyBuilder->CommitCommand();
2196 void VisuGUI::SaveViewParams()
2198 if (checkLock(GetStudyDocument())) return;
2199 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2200 if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2202 VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
2203 if(!CORBA::is_nil(aVM.in())){
2204 VISU::View_var aView = aVM->GetCurrentView();
2205 if(!CORBA::is_nil(aView.in())){
2206 VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
2207 if(CORBA::is_nil(aView3D.in())) return;
2208 if ( Sel->IObjectCount() == 0 ) {
2209 // Save view parameters by new name
2210 aView3D->SaveViewParams( 0 );
2211 GetActiveStudy()->updateObjBrowser( true );
2214 VISU::Storable::TRestoringMap aMap;
2215 Handle(SALOME_InteractiveObject) anIO;
2216 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2217 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2218 if(isExist && aType == VISU::TVIEW3D){
2219 aView3D->SaveViewParams( anIO->getName() );
2220 GetActiveStudy()->updateObjBrowser( true );
2228 void VisuGUI::RestoreViewParams()
2230 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2231 if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK )
2233 VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager();
2234 if(!CORBA::is_nil(aVM.in())){
2235 VISU::View_var aView = aVM->GetCurrentView();
2236 if(!CORBA::is_nil(aView.in())){
2237 VISU::View3D_var aView3D = VISU::View3D::_narrow(aView);
2238 if(CORBA::is_nil(aView3D.in())) return;
2240 VISU::Storable::TRestoringMap aMap;
2241 Handle(SALOME_InteractiveObject) anIO;
2242 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2243 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2244 if(isExist && aType == VISU::TVIEW3D)
2245 aView3D->RestoreViewParams( anIO->getName() );
2250 //=====================================================================================
2251 // function : DeleteViewParams()
2253 //=====================================================================================
2254 void VisuGUI::DeleteViewParams() {
2256 VISU::Storable::TRestoringMap aMap;
2257 Handle(SALOME_InteractiveObject) anIO;
2258 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2259 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2260 if(isExist && aType == VISU::TVIEW3D){
2261 SALOMEDS::Study_var aStudy = GetStudyDocument();
2262 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
2263 aStudy->NewBuilder()->RemoveObject(aSObject);
2265 SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2266 aSel->RemoveIObject(anIO, 0);
2268 GetActiveStudy()->updateObjBrowser( true );
2273 //=====================================================================================
2274 // function : Sweep()
2276 //=====================================================================================
2277 void VisuGUI::Sweep() {
2278 VISU::ScalarMap_i* aPrsObject = dynamic_cast<VISU::ScalarMap_i*>(GetSelectedPrs3d());
2279 if (!aPrsObject) return;
2281 VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame();
2285 QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo");
2286 if ( !aTempoStr.isEmpty() )
2287 aTemp = int(1.E6*(aTempoStr.toFloat()));
2290 QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles");
2291 if ( !aCyclesStr.isEmpty() )
2292 aCycles = aCyclesStr.toInt();
2295 QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps");
2296 if ( !aStepsStr.isEmpty() )
2297 aSteps = aStepsStr.toInt();
2299 VISU_Actor* aActor = GetActor(aPrsObject);
2300 if (!aActor) return;
2302 if (!aActor->GetVisibility()) {
2303 aActor->VisibilityOn();
2306 QApplication::setOverrideCursor( Qt::waitCursor );
2307 for (int j=0 ; j<aCycles; j++) {
2308 for (int i=0 ; i<=aSteps; i++) {
2309 float aPercents = float(i)/aSteps;
2310 aPrsObject->SetMapScale(aPercents);
2311 aPrsObject->UpdateActor(aActor);
2312 vf->getRW()->getRenderWindow()->Render();
2316 QApplication::restoreOverrideCursor();
2321 void VisuGUI::TimeAnimation() {
2322 VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument());
2323 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2325 bool isDefined = false;
2327 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2328 for (; It.More(); It.Next()) {
2329 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() );
2330 if (aSObject->_is_nil()) continue;
2331 if (getValue(aSObject, "myComment") == QString("FIELD")) {
2332 long aNumber = getValue(aSObject, "myNbTimeStamps").toLong();
2336 aAnimationDlg->addField(aSObject);
2338 } else if (aNbTimes == aNumber) {
2339 aAnimationDlg->addField(aSObject);
2344 if (isDefined) aAnimationDlg->show();
2345 else delete aAnimationDlg;
2349 void VisuGUI::ImportMedField() {
2350 if (checkLock(GetStudyDocument())) return;
2351 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2352 SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
2353 QApplication::setOverrideCursor( Qt::waitCursor );
2354 for(;It.More();It.Next()) {
2355 Handle(SALOME_InteractiveObject) anIO = It.Value();
2356 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2357 if(!aSObject->_is_nil()){
2358 CORBA::Object_var anObject = VISU::SObjectToObject(aSObject);
2359 if(!CORBA::is_nil(anObject)){
2360 SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject );
2361 if(!CORBA::is_nil(aMED.in()))
2362 GetVisuGen()->ImportMed( aSObject );
2363 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2364 if(!CORBA::is_nil(aField.in()))
2365 GetVisuGen()->ImportMedField( aField );
2367 SALOMEDS::SObject_var aSFather = aSObject->GetFather();
2368 SALOMEDS::GenericAttribute_var anAttr;
2369 aSFather->FindAttribute(anAttr, "AttributeName");
2370 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
2371 CORBA::String_var aValue = aName->Value();
2372 if(strcmp(aValue.in(),"MEDFIELD") == 0)
2373 GetVisuGen()->ImportMed(aSObject);
2374 //if(strcmp(aValue.in(),"MEDMESH") == 0)
2375 // VisuGUI::myComponent->ImportMed(aSObject);
2379 GetActiveStudy()->updateObjBrowser( true );
2380 QApplication::restoreOverrideCursor();
2383 //=====================================================================================
2384 // functions : Rename()
2386 //=====================================================================================
2387 void VisuGUI::Rename() {
2388 if (checkLock(GetStudyDocument())) return;
2389 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2390 if ( Sel->IObjectCount() != 1 )
2392 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2393 if( aSObj->_is_nil() ) return;
2395 VISU::Curve_i* curve = 0;
2396 CORBA::Object_var anObject = GetSelectedObj();
2397 if ( !CORBA::is_nil( anObject )) {
2398 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2399 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
2401 CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
2402 if( !CORBA::is_nil( aCurve ) ) {
2403 curve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
2408 //TEST DU PARENT == VISU
2409 SALOMEDS::GenericAttribute_var anAttr;
2410 SALOMEDS::AttributeName_var aName;
2411 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2412 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2413 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2414 if ( !Name.isEmpty() ) {
2415 QApplication::setOverrideCursor( Qt::waitCursor );
2417 curve->SetName( Name.latin1() );
2418 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2419 QApplication::restoreOverrideCursor();
2421 //int TypeMode; bool InViewer;
2422 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2423 //ActorTmp->setName((Standard_CString)Name.latin1());
2428 //=====================================================================================
2429 // functions : RenameTable()
2431 //=====================================================================================
2432 void VisuGUI::RenameTable() {
2433 if (checkLock(GetStudyDocument())) return;
2434 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2435 if ( Sel->IObjectCount() != 1 )
2437 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2438 if( aSObj->_is_nil() ) return;
2440 VISU::Table_i* table = 0;
2441 CORBA::Object_var anObject = GetSelectedObj();
2442 if ( !CORBA::is_nil( anObject )) {
2443 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2444 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
2446 CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
2447 if( !CORBA::is_nil( aTable ) ) {
2448 table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
2453 //TEST DU PARENT == VISU
2454 SALOMEDS::GenericAttribute_var anAttr;
2455 SALOMEDS::AttributeName_var aName;
2456 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2457 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2458 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2459 if ( !Name.isEmpty() ) {
2460 QApplication::setOverrideCursor( Qt::waitCursor );
2462 table->SetName( Name.latin1() );
2463 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2464 QApplication::restoreOverrideCursor();
2466 //int TypeMode; bool InViewer;
2467 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2468 //ActorTmp->setName((Standard_CString)Name.latin1());
2475 //=====================================================================================
2476 // functions : RenameContainer()
2478 //=====================================================================================
2479 void VisuGUI::RenameContainer() {
2480 if (checkLock(GetStudyDocument())) return;
2481 SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
2482 if ( Sel->IObjectCount() != 1 )
2484 SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() );
2485 if( aSObj->_is_nil() ) return;
2487 VISU::Container_i* container = 0;
2488 CORBA::Object_var anObject = GetSelectedObj();
2489 if ( !CORBA::is_nil( anObject )) {
2490 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2491 if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
2493 CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject );
2494 if( !CORBA::is_nil( aContainer ) ) {
2495 container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
2500 //TEST DU PARENT == VISU
2501 SALOMEDS::GenericAttribute_var anAttr;
2502 SALOMEDS::AttributeName_var aName;
2503 if ( aSObj->FindAttribute(anAttr, "AttributeName") ) {
2504 aName = SALOMEDS::AttributeName::_narrow( anAttr );
2505 QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() );
2506 if ( !Name.isEmpty() ) {
2507 QApplication::setOverrideCursor( Qt::waitCursor );
2509 container->SetName( Name.latin1() );
2510 GetActiveStudy()->renameIObject( Sel->firstIObject(), Name );
2511 QApplication::restoreOverrideCursor();
2513 //int TypeMode; bool InViewer;
2514 //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode);
2515 //ActorTmp->setName((Standard_CString)Name.latin1());
2522 //=====================================================================================
2523 // function : CopyPresentation()
2525 //=====================================================================================
2526 void VisuGUI::CopyPresentation(){
2527 if (checkLock(GetStudyDocument())) return;
2528 VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d();
2529 if (!aPrsObject) return;
2530 switch (aPrsObject->GetType()) {
2533 VISU::Mesh_i* aMeshPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
2534 VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult());
2535 aSameMesh->SameAs(aMeshPrs);
2536 UpdateViewer(aSameMesh);
2539 case VISU::TSCALARMAP:
2541 VISU::ScalarMap_i* aScalarPrs = dynamic_cast<VISU::ScalarMap_i*>(aPrsObject);
2542 VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult());
2543 aSameScalar->SameAs(aScalarPrs);
2544 UpdateViewer(aSameScalar);
2547 case VISU::TDEFORMEDSHAPE:
2549 VISU::DeformedShape_i* aDefPrs = dynamic_cast<VISU::DeformedShape_i*>(aPrsObject);
2550 VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult());
2551 aSameDeformed->SameAs(aDefPrs);
2552 UpdateViewer(aSameDeformed);
2555 case VISU::TCUTPLANES:
2557 VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
2558 VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult());
2559 aSameCut->SameAs(aCutPrs);
2560 UpdateViewer(aSameCut);
2563 case VISU::TCUTLINES:
2565 VISU::CutLines_i* aCutPrs = dynamic_cast<VISU::CutLines_i*>(aPrsObject);
2566 VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult());
2567 aSameCut->SameAs(aCutPrs);
2568 UpdateViewer(aSameCut);
2571 case VISU::TISOSURFACE:
2573 VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast<VISU::IsoSurfaces_i*>(aPrsObject);
2574 VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult());
2575 aSameIso->SameAs(aIsoPrs);
2576 UpdateViewer(aSameIso);
2579 case VISU::TSTREAMLINES:
2581 VISU::StreamLines_i* aLinesPrs = dynamic_cast<VISU::StreamLines_i*>(aPrsObject);
2582 VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult());
2583 aSameLines->SameAs(aLinesPrs);
2584 UpdateViewer(aSameLines);
2587 case VISU::TVECTORS:
2589 VISU::Vectors_i* aVectorsPrs = dynamic_cast<VISU::Vectors_i*>(aPrsObject);
2590 VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult());
2591 aSameVectors->SameAs(aVectorsPrs);
2592 UpdateViewer(aSameVectors);
2596 GetActiveStudy()->updateObjBrowser();
2601 //=====================================================================================
2602 // function : DefinePopup()
2604 //=====================================================================================
2605 void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject )
2612 //=====================================================================================
2613 // function : checkHomoSelection()
2615 //=====================================================================================
2616 enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther };
2617 int VisuGUI::checkHomoSelection()
2619 int selMode = homoNone;
2620 SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2621 SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
2622 for ( ; It.More(); It.Next() ) {
2623 int selNext = homoOther;
2624 Handle(SALOME_InteractiveObject)& anIO = It.Value();
2625 if ( anIO->hasEntry() ) {
2626 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
2627 SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
2628 VISU::Storable::TRestoringMap pMap;
2629 if( !aSObject->_is_nil() ) {
2630 CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
2631 if ( !CORBA::is_nil( aCORBAObject ) ) {
2632 VISU::Base_var aVisuObj = VISU::Base::_narrow( aCORBAObject );
2633 if ( !CORBA::is_nil( aVisuObj ) ) {
2634 VISU::VISUType aType = aVisuObj->GetType();
2638 case VISU::TCONTAINER:
2639 selNext = homoCurves; break;
2641 case VISU::TSCALARMAP:
2642 case VISU::TISOSURFACE:
2643 case VISU::TDEFORMEDSHAPE:
2644 case VISU::TCUTPLANES:
2645 case VISU::TCUTLINES:
2646 case VISU::TVECTORS:
2647 case VISU::TSTREAMLINES:
2648 selNext = homoPresentations; break;
2650 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2651 selNext = homoAnimatable; break;
2653 selNext = homoOther; break;
2655 selNext = homoOther;
2660 SALOMEDS::GenericAttribute_var anAttr;
2661 if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) {
2662 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr );
2663 string aComm = aComment->Value();
2664 QString strIn( aComm.c_str() );
2665 VISU::Storable::StrToMap( strIn, pMap );
2667 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
2673 selNext = homoPresentable; break;
2675 if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) {
2676 selNext = homoAnimatable; break;
2678 selNext = homoOther; break;
2680 selNext = homoOther;
2687 if ( selMode == homoNone )
2690 if ( selMode != selNext )
2697 //=====================================================================================
2698 // function : GetNbChildren() [ static ]
2699 // purpose : get number of children
2700 //=====================================================================================
2701 int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo )
2703 if ( SO->_is_nil() )
2706 SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO );
2707 for ( ; Iter->More(); Iter->Next() ) {
2708 SALOMEDS::SObject_var refSO;
2709 if ( !Iter->Value()->ReferencedObject( refSO ) || refToo )
2715 //=====================================================================================
2716 // function : CustomPopup()
2718 //=====================================================================================
2719 bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext,
2720 const QString & theParent, const QString & theObject)
2722 int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900;
2723 QAD_ResourceMgr* rmgr = parent->createResourceManager();
2725 bool aIsLocked = isStudyLocked( GetActiveStudy()->getStudyDocument() );
2727 bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK);
2729 SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
2730 if ( aSelection->IObjectCount() == 0 ) {
2731 if ( theParent == "Viewer" && isVTKViewer)
2732 // Available only for VTK viewer
2733 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
2736 if( aSelection->IObjectCount() > 1 ) {
2737 int selMode = checkHomoSelection();
2738 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<<selMode );
2739 if ( selMode == homoCurves ) {
2740 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2741 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2742 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2743 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) );
2746 else if ( selMode == homoPresentations ) {
2748 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) );
2749 thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) );
2752 else if ( selMode == homoPresentable ) {
2753 if (!aIsLocked) thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh()));
2755 else if ( selMode == homoAnimatable ) {
2756 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
2760 VISU::Storable::TRestoringMap aMap;
2761 Handle(SALOME_InteractiveObject) anIO;
2762 CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap);
2763 if (!CORBA::is_nil(anObject)) {
2764 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2765 VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
2766 if (!CORBA::is_nil(aVisuObj)) {
2767 VISU::VISUType aType = aVisuObj->GetType();
2768 if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - VISU object :: "<<aType);
2770 case VISU::TVISUGEN:
2771 thePopup->insertItem("Import MED", visuGUI, SLOT(ImportFile()));
2772 thePopup->insertItem("Import TABLE", visuGUI, SLOT(ImportTablesFromFile()));
2773 thePopup->insertItem("Create Plot2d View", visuGUI, SLOT(CreatePlot2dView()));
2777 if (!aIsLocked) thePopup->insertItem("Delete", visuGUI, SLOT(DeleteObject()));
2781 if (!aIsLocked) thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) );
2782 thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) );
2783 if (!aIsLocked) thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) );
2784 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
2785 thePopup->insertSeparator();
2786 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2787 if ( GetNbChildren( aSObject, false ) > 0 ) {
2788 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2789 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2790 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2793 thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2798 thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) );
2799 thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename()));
2801 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2802 if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) )
2803 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2805 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2806 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2810 case VISU::TCONTAINER:
2811 // if( !CORBA::is_nil( anObject ) ) {
2812 // CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject );
2813 // if( !CORBA::is_nil( aCnt ) ) {
2814 // VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
2815 // if ( container ) {
2816 // if ( !aIsLocked ) {
2817 // thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2818 // thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2819 // if (container->GetNbCurves() > 0)
2820 // thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2822 // if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2823 // thePopup->insertSeparator();
2824 // thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2825 // thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2826 // thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2832 thePopup->insertItem( "Edit...", visuGUI, SLOT( EditContainer() ) );
2833 thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) );
2834 thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) );
2836 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) {
2837 thePopup->insertSeparator();
2838 thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) );
2839 thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) );
2840 thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) );
2842 if ( !aIsLocked ) thePopup->insertItem( "Delete", visuGUI, SLOT( DeleteObject() ) );
2845 default: // Presentation
2847 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
2850 // Add Presentation menu
2851 if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){
2852 QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop());
2853 int aRepresent = anVISUActor->GetRepresentation();
2856 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2857 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2858 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2859 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2860 if (aType == VISU::TMESH)
2861 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2863 case VISU::WIREFRAME :
2864 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2865 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2866 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2867 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2868 if (aType == VISU::TMESH)
2869 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2872 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2873 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2874 if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE)
2875 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2876 if (aType == VISU::TMESH)
2877 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2879 case VISU::INSIDEFRAME :
2880 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2881 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2882 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2883 if (aType == VISU::TMESH)
2884 aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe()));
2886 case VISU::SURFACEFRAME :
2887 aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints()));
2888 aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface()));
2889 aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe()));
2890 aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe()));
2893 if(anVISUActor->GetShrinkable())
2894 if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){
2895 if (anVISUActor->IsShrunk())
2896 aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink()));
2898 aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink()));
2900 thePopup->insertItem("Representation", aPresMenu);
2903 QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop());
2904 if(aType == VISU::TMESH){
2905 if(aRepresent == VISU::SURFACEFRAME){
2906 aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor()));
2907 aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor()));
2909 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2910 }else if(aType == VISU::TDEFORMEDSHAPE)
2911 aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor()));
2913 if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES)
2914 aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity()));
2915 if (aType != VISU::TVECTORS){
2916 aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines()));
2917 thePopup->insertItem("Properties", aPropMenu);
2919 thePopup->insertSeparator();
2922 if ( !aIsLocked ) thePopup->insertItem("Rename...", visuGUI, SLOT(Rename()));
2923 if (aType != VISU::TMESH) {
2924 //if (aType != VISU::TSCALARMAP)
2925 if ( !aIsLocked ) thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs()));
2927 if (aType == VISU::TCUTLINES) {
2928 // Check: Does it has living children (tables)
2929 SALOMEDS::ChildIterator_var aIter =
2930 GetActiveStudy()->getStudyDocument()->NewChildIterator( aSObject );
2931 bool isPresent = false;
2932 for ( ;aIter->More(); aIter->Next()) {
2933 SALOMEDS::SObject_var aTblObj = aIter->Value();
2934 isPresent = !aTblObj->_is_nil();
2936 SALOMEDS::GenericAttribute_var anAttr;
2937 isPresent = aTblObj->FindAttribute(anAttr, "AttributeName");
2938 if (isPresent) break; // We have at least a one child
2941 if ((!isPresent) && (!aIsLocked) )
2942 thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) );
2944 thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep()));
2948 if ( theParent == "Viewer" &&
2949 ( aType == VISU::TMESH ||
2950 aType == VISU::TSCALARMAP ||
2951 aType == VISU::TDEFORMEDSHAPE ) ) {
2952 thePopup->insertSeparator();
2953 thePopup->insertItem("Selection info...", visuGUI, SLOT(SelectionInfo()));
2955 thePopup->insertSeparator();
2957 if (visuGUI->IsDisplayed(aPrsObject) ){
2958 thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs()));
2961 thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs()));
2963 thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs()));
2965 thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs()));
2966 if ((aType != VISU::TMESH) && (!aIsLocked)) {
2967 thePopup->insertSeparator();
2968 thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation()));
2977 // possibly this is the MED field/mesh and support objects
2978 SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject );
2979 if(!CORBA::is_nil(aMED))
2980 thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) );
2981 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject );
2982 if(!CORBA::is_nil(aField))
2983 thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) );
2987 SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry());
2988 if(!aSObject->_is_nil()){
2990 VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
2996 if ( !aIsLocked )thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh()));
3000 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) {
3001 // Available only for VTK viewer
3002 thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) );
3003 thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) );
3005 thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) );
3006 thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams()));
3010 if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer)
3011 thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) );
3013 case VISU::TTIMESTAMP: {
3014 int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt();
3015 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ),
3016 "Scalar Map...", visuGUI, SLOT(CreateScalarMap()));
3017 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ),
3018 "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces()));
3019 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ),
3020 "Cut Planes...", visuGUI, SLOT(CreateCutPlanes()));
3021 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ),
3022 "Cut Lines...", visuGUI, SLOT(CreateCutLines()));
3023 if(aNunComponent > 1){
3024 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ),
3025 "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape()));
3026 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ),
3027 "Vectors...", visuGUI, SLOT(CreateVectors()));
3028 thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ),
3029 "Stream lines...", visuGUI, SLOT(CreateStreamLines()));
3036 SALOMEDS::GenericAttribute_var anAttr;
3037 if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) ||
3038 aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){
3039 thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable()));
3040 thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData()));
3041 thePopup->insertItem( "Export Table", visuGUI, SLOT( ExportTableToFile() ) );
3044 aSObject = aSObject->GetFather();
3045 if(aSObject->_is_nil()) return false;
3046 aSObject->FindAttribute(anAttr, "AttributeName");
3047 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
3048 if(aName->_is_nil()) return false;
3049 CORBA::String_var aValue = aName->Value();
3050 //if(strcmp(aValue.in(),"MEDMESH") == 0)
3051 // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) );
3052 if(strcmp(aValue.in(),"MEDFIELD") == 0)
3053 thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) );
3060 //===========================================================================
3061 // BuildPresentation
3062 //===========================================================================
3063 void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO)
3065 BEGIN_OF("VisuGUI::BuildPresentation");
3067 if (theIO.IsNull()) {
3068 if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed");
3072 SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3073 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
3075 if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return;
3077 vtkRenderer *Renderer = GetRenderer();
3079 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() );
3081 if (aSObj -> _is_nil() ) {
3082 if(MYDEBUG) MESSAGE("No SObject for interacative object is found");
3086 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3087 if(!CORBA::is_nil(anObject)) {
3088 VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
3089 if ( !aPrsObject ) {
3090 if(MYDEBUG) MESSAGE("The object is not VISU::Prs3d_i");
3093 VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject);
3096 SelectedActor = aPrsObject -> CreateActor();
3097 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame())
3098 vf->AddActor(SelectedActor);
3099 }catch(std::runtime_error& exc){
3103 if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true");
3104 END_OF("VisuGUI::BuildPresentation");
3110 bool OnGUIEvent(int theCommandID, QAD_Desktop* parent)
3112 //if(MYDEBUG) MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID);
3113 return VisuGUI::OnGUIEvent(theCommandID, parent);
3116 bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3118 if(MYDEBUG) MESSAGE("VisuGUI::OnKeyPress ");
3119 return VisuGUI::OnKeyPress (pe, parent, studyFrame);
3122 bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3124 //if(MYDEBUG) MESSAGE("VisuGUI::OnMousePress ");
3125 return VisuGUI::OnMousePress (pe, parent, studyFrame);
3128 bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame)
3130 //if(MYDEBUG) MESSAGE("VisuGUI::OnMouseMove ");
3131 return VisuGUI::OnMouseMove (pe, parent, studyFrame);
3134 bool SetSettings ( QAD_Desktop* parent )
3136 return VisuGUI::setSettings( parent );
3139 bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext,
3140 const QString & theParent, const QString & theObject )
3142 return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject );
3145 void definePopup ( QString & theContext, QString & theParent, QString & theObject )
3147 VisuGUI::DefinePopup( theContext, theParent, theObject );
3150 bool activeStudyChanged ( QAD_Desktop* parent )
3152 //VisuGUI::activeStudyChanged( parent );
3154 void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO )
3156 VisuGUI::BuildPresentation(theIO);
3159 void supportedViewType(int* buffer, int bufferSize)
3161 if (!buffer || !bufferSize) return;
3162 buffer[0] = (int)VIEW_VTK;
3163 if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D;
3168 //////////////////////////////////////////////////////////////////////////////////
3169 //////////////// CHANGE ACTOR COLOR ////////////////////////
3170 //////////////////////////////////////////////////////////////////////////////////
3171 ///////////////// /////////////////////////////////////////////////////////////////
3172 // change actor color
3173 // In : Name of Actor
3177 void VisuGUI::NewColor(VISU_Actor *theActor){
3178 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3179 VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
3180 VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
3181 SALOMEDS::Color anOldColor, aNewColor;
3182 int aRepresent = theActor->GetRepresentation();
3186 anOldColor = aMesh->GetNodeColor();
3188 case VISU::WIREFRAME :
3189 case VISU::INSIDEFRAME :
3190 anOldColor = aMesh->GetLinkColor();
3193 case VISU::SURFACEFRAME :
3194 anOldColor = aMesh->GetCellColor();
3197 else if(aDeformedShape)
3198 anOldColor = aDeformedShape->GetColor();
3201 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3202 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3203 if(aColorNew.isValid()){
3204 aNewColor.R = aColorNew.red()/255.;
3205 aNewColor.G = aColorNew.green()/255.;
3206 aNewColor.B = aColorNew.blue()/255.;
3210 aMesh->SetNodeColor(aNewColor);
3212 case VISU::WIREFRAME :
3213 case VISU::INSIDEFRAME :
3214 aMesh->SetLinkColor(aNewColor);
3217 case VISU::SURFACEFRAME :
3218 aMesh->SetCellColor(aNewColor);
3222 aDeformedShape->SetColor(aNewColor);
3223 RecreateActor(aPrs3d);
3228 void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){
3229 if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){
3230 if(VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)){
3231 SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
3232 QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B));
3233 QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop());
3234 if(aColorNew.isValid()){
3235 aNewColor.R = aColorNew.red()/255.;
3236 aNewColor.G = aColorNew.green()/255.;
3237 aNewColor.B = aColorNew.blue()/255.;
3238 aMesh->SetLinkColor(aNewColor);
3239 VisuGUI::RecreateActor(aMesh);
3245 //////////////////////////////////////////////////////////////////////////////////
3246 //////////////// CHANGE ACTOR OPACITY ////////////////////////
3247 //////////////////////////////////////////////////////////////////////////////////
3248 //////////////////////////////////////////////////////////////////////////////////
3249 // change actor opacity
3250 // In : Name of Actor
3252 // Use CursorDlg to select a value between 0 and 100
3255 void VisuGUI::NewOpacity(VISU_Actor *Actor)
3258 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE );
3260 float oldopac,newopac;
3262 CursorDlg->Comment1->setText( tr( "Set value between") );
3263 CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) );
3264 oldopac=Actor->GetProperty()->GetOpacity();
3265 intopac=int(oldopac*100.);
3266 CursorDlg->SpinBox1->setMinValue(0);
3267 CursorDlg->SpinBox1->setMaxValue(100);
3268 CursorDlg->SpinBox1->setValue(intopac);
3270 int ret = CursorDlg->exec();
3273 intopac = CursorDlg->SpinBox1->value() ;
3274 newopac = intopac/100.;
3275 Actor->GetProperty()->SetOpacity(newopac);
3280 //////////////////////////////////////////////////////////////////////////////////
3281 //////////////// CHANGE ACTOR LINEWIDTH ////////////////////////
3282 //////////////////////////////////////////////////////////////////////////////////
3283 //////////////////////////////////////////////////////////////////////////////////
3284 // change actor linewidth
3285 // In : Name of Actor
3287 // Use CursorDlg to select a value between 0 and 10
3290 void VisuGUI::NewLinewidth(VISU_Actor *Actor)
3293 VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE );
3295 float oldlwid,newlwid;
3297 CursorDlg->Comment1->setText("Set value between");
3298 CursorDlg->Comment2->setText("1 (thin) and 10 (thick)");
3299 oldlwid=Actor->GetLineWidth();
3300 intlwid=int(oldlwid);
3301 CursorDlg->SpinBox1->setMinValue(1);
3302 CursorDlg->SpinBox1->setMaxValue(10);
3303 CursorDlg->SpinBox1->setValue(intlwid);
3305 int ret = CursorDlg->exec();
3307 intlwid = CursorDlg->SpinBox1->value() ;
3309 Actor->SetLineWidth(newlwid);
3314 /* ======================================================================================== */
3315 /* Setting parameters for Scalar Bar */
3316 /* ======================================================================================== */
3317 void VisuGUI::ChangeScalarBar()
3319 VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE);
3320 Scbar->initFromResources();
3321 int ret = Scbar->exec();
3323 Scbar->storeToResources();
3328 /* ======================================================================================== */
3329 /* Setting parameters for Sweeping */
3330 /* ======================================================================================== */
3331 void VisuGUI::SetSweepingPreferences()
3337 QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo");
3338 if ( !Tempo.isEmpty() )
3339 tempo = Tempo.toFloat();
3341 QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles");
3342 if ( !Cycles.isEmpty() )
3343 cycles = Cycles.toInt();
3345 QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps");
3346 if ( !Steps.isEmpty() )
3347 steps = Steps.toInt();
3349 VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0);
3351 Sweep->setTimeStep( tempo );
3352 Sweep->setNbCycles( cycles );
3353 Sweep->setNbSteps ( steps );
3355 if ( Sweep->exec() )
3357 tempo = Sweep->getTimeStep();
3358 cycles = Sweep->getNbCycles();
3359 steps = Sweep->getNbSteps();
3361 QAD_CONFIG->addSetting("Visu:SweepTempo", tempo);
3362 QAD_CONFIG->addSetting("Visu:SweepCycles", cycles);
3363 QAD_CONFIG->addSetting("Visu:SweepSteps", steps);
3368 /* ======================================================================================== */
3369 /* Returns Visu input files directory (default is CSF_PATHData) */
3370 /* ======================================================================================== */
3371 QString VisuGUI::getVisuInputDir()
3373 QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir");
3374 if ( Tmp.isEmpty() )
3375 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3376 Tmp = QAD_Tools::addSlash(Tmp);
3380 /* ======================================================================================== */
3381 /* Returns Visu output files directory (default is InputDir) */
3382 /* ======================================================================================== */
3383 QString VisuGUI::getVisuOutputDir()
3385 QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir");
3386 if ( Tmp.isEmpty() )
3388 QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir");
3389 if ( Tmp2.isEmpty() )
3390 Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData"));
3394 Tmp = QAD_Tools::addSlash(Tmp);
3399 /* ======================================================================================== */
3400 /* Global Method for Scalar Map */
3401 /* ======================================================================================== */
3402 VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){
3403 if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent");
3404 SALOMEDS::SObject_var aSObj = theField->GetFather();
3405 if (CORBA::is_nil(aSObj)) return NULL;
3406 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3407 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3408 aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL;
3409 CORBA::Object_var anObject = VISU::SObjectToObject(aSObj);
3410 if(CORBA::is_nil(anObject)) return NULL;
3411 theResult = VISU::Result::_narrow(anObject);
3412 VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(VISU::GetServant(anObject).in());
3414 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3415 tr ("WRN_NO_AVAILABLE_DATA"),
3416 tr ("VISU_BUT_OK"));
3420 #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \
3421 PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \
3422 const char* theMeshName, VISU::Entity theEntity, \
3423 const char* theFieldName, int theTimeId) {\
3424 VISU::Result_var aResult; \
3425 VISU::Result_i* pResult = CreatePresent(theField,aResult); \
3426 if(pResult != NULL){ \
3427 QApplication::setOverrideCursor( Qt::waitCursor ); \
3428 CORBA::Object_var anObject = \
3429 GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \
3430 QApplication::restoreOverrideCursor(); \
3431 if(!CORBA::is_nil(anObject)) \
3432 return dynamic_cast<PRSTYPE*>(VISU::GetServant(anObject).in()); \
3434 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \
3435 tr ("ERR_CANT_BUILD_PRESENTATION"), \
3436 tr ("VISU_BUT_OK") ); \
3440 CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField);
3441 CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField);
3442 CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField);
3443 CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField);
3444 CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField);
3445 CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField);
3446 CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField);
3449 #define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \
3450 bool FNAME(SALOMEDS::SObject_var theField) { \
3451 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \
3453 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \
3454 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \
3455 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \
3456 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \
3457 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \
3458 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \
3459 Utils_Timer timer; \
3460 if(MYCHECKTIME) timer.Start(); \
3461 TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \
3464 cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n"; \
3468 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \
3469 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \
3470 DLGNAME* aDlg = new DLGNAME(); \
3471 aDlg->initFromPrsObject(pPresent); \
3472 if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) { \
3475 DeletePresentation(pPresent); \
3480 CreateActor(pPresent); \
3486 BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg);
3487 BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg);
3488 BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg);
3489 BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg);
3490 //BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg);
3491 //BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg);
3492 BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg);
3495 bool VisuGUI::CreateCutPlanes(SALOMEDS::SObject_var theField) {
3496 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3498 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3499 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3500 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3501 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3502 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3503 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3505 if(MYCHECKTIME) timer.Start();
3506 VISU::CutPlanes_i* pPresent =
3507 CreateCutPlanesPrs(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt());
3510 cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n";
3514 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3515 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3516 VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(true, false);
3517 aDlg->initFromPrsObject(pPresent);
3519 myActiveDialogBox = aDlg;
3520 // if (aDlg->exec() && (aDlg->storeToPrsObject(pPresent))) {
3523 // DeletePresentation(pPresent);
3528 // CreateActor(pPresent);
3535 bool VisuGUI::CreateCutLines(SALOMEDS::SObject_var theField) {
3536 VISU::Storable::TRestoringMap aMap = getMapOfValue(theField);
3538 QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist);
3539 if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false;
3540 QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
3541 QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
3542 QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1();
3543 QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1();
3545 if(MYCHECKTIME) timer.Start();
3546 VISU::CutLines_i* pPresent = CreateCutLinesPrs(theField,aMeshName,
3547 (VISU::Entity)anEntity.toInt(),
3548 aFieldName,aTimeStampId.toInt());
3551 cout<<"BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg) - CREATE PRSOBJECT\n";
3555 QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d");
3556 if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){
3557 VisuGUI_CutLinesDlg* aDlg = new VisuGUI_CutLinesDlg(true);
3558 aDlg->initFromPrsObject(pPresent);
3560 myActiveDialogBox = aDlg;
3562 // if (aDlg->exec()) {
3563 // aDlg->storeToPrsObject(pPresent);
3564 // if (aDlg->isGenerateTable()) {
3565 // GetVisuGen()->CreateTable(pPresent->GetEntry());
3566 // if (aDlg->isGenerateCurves()) {
3567 // SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument();
3568 // SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(pPresent->GetEntry());
3569 // if(!aSObject->_is_nil()) {
3570 // SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
3571 // SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
3572 // for ( ;aIter->More(); aIter->Next()) {
3573 // SALOMEDS::SObject_var aTblObj = aIter->Value();
3574 // if (!aTblObj->_is_nil()) {
3575 // SALOMEDS::GenericAttribute_var anAttr;
3576 // if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
3577 // CreatePlot(aTblObj);
3583 // GetActiveStudy()->updateObjBrowser();
3586 // DeletePresentation(pPresent);
3592 // CreateActor(pPresent);
3601 /* ======================================================================================== */
3602 /* Global Method to import tables from file */
3603 /* ======================================================================================== */
3604 void VisuGUI::ImportTablesFromFile(){
3605 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3607 flt.append( "Files (*.xls *.txt *.tab)" );
3608 flt.append( "All Files (*.*)" );
3609 QString aDir = getVisuInputDir();
3610 QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3611 aDir,flt,tr("Import From File"),true);
3613 if(aFileInfo.exists()){
3614 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3615 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3616 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3619 CORBA::Object_var anObject;
3625 anObject=GetVisuGen()->ImportTables(aFileInfo.filePath());
3629 cout<<"VisuGUI::ImportTablesFromFile() - IMPORT FILE\n";
3633 if(CORBA::is_nil(anObject)) {
3635 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3636 tr ("ERR_ERROR_IN_THE_FILE"),
3637 tr ("VISU_BUT_OK") );
3641 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3643 GetActiveStudy()->updateObjBrowser(); //update Object browser
3647 void VisuGUI::ExportTableToFile()
3649 QAD_Study *aQADStudy = VisuGUI::GetActiveStudy();
3650 SALOME_Selection* aSel = SALOME_Selection::Selection ( aQADStudy -> getSelection() );
3652 if( aSel->IObjectCount() > 0 ) {
3653 const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject();
3654 if(anIO->hasEntry()){
3655 SALOMEDS::Study_var aStudy = aQADStudy->getStudyDocument();
3656 SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID(anIO->getEntry());
3657 if(CORBA::is_nil(aSObj)) return;
3660 SALOMEDS::GenericAttribute_var anAttr;
3662 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3663 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger")) {
3664 aSObj = aSObj->GetFather(); //if the current SObject is a table title
3665 // we take a father contaning the table
3666 if (!CORBA::is_nil(aSObj)) {
3667 if (!aSObj->FindAttribute(anAttr, "AttributeTableOfReal") &&
3668 !aSObj->FindAttribute(anAttr, "AttributeTableOfInteger"))
3673 if (CORBA::is_nil(anAttr)) return;
3675 SALOMEDS::AttributeTableOfReal_var aTabAttr = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
3676 if (!CORBA::is_nil(aTabAttr))
3677 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3679 SALOMEDS::AttributeTableOfInteger_var aTabAttr = SALOMEDS::AttributeTableOfInteger::_narrow(anAttr);
3680 if (!CORBA::is_nil(aTabAttr))
3681 aTitle = aTabAttr->GetTitle(); //get table title in order to have default name of the file
3684 aTitle.simplifyWhiteSpace();
3686 flt.append("Table Files (*.xls)");
3688 QAD_FileDlg *aDlg = new QAD_FileDlg(QAD_Application::getDesktop(), false, true, true);
3689 aDlg -> setCaption("Export Table To File");
3690 aDlg -> setDir( getVisuOutputDir() );
3691 aDlg -> setFilters(flt);
3692 aDlg -> setSelection(aTitle.replace(QRegExp(" "), "_"));
3694 QString aFile = aDlg -> selectedFile();
3697 if(!aFile.isEmpty()){
3698 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3699 QString aDir = QAD_Tools::getDirFromPath(aFile);
3700 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3703 GetVisuGen() -> ExportTableToFile(aSObj, aFile.latin1());
3704 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3706 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3707 tr ("ERR_ERROR_DURING_EXPORT"),
3708 tr ("VISU_BUT_OK") );
3714 /* ======================================================================================== */
3715 /* Global Method to import mesh results in MED and DAT format */
3716 /* ======================================================================================== */
3717 void VisuGUI::ImportFile(){
3718 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::ImportFile);
3720 void VisuGUI::CopyAndImportFile(){
3721 VisuGUI::ImportFromFile(&VISU::VISU_Gen_i::CopyAndImportFile);
3723 void VisuGUI::ImportFromFile(TImportFun theImportFun){
3724 if (checkLock(GetActiveStudy()->getStudyDocument())) return;
3726 //flt.append( "Exportable Files (*.med *.dat)" );
3727 //flt.append( "Dat Files (*.dat)" );
3728 flt.append( "Med Files (*.med)" );
3729 QString aDir = getVisuInputDir();
3730 QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(),
3731 aDir,flt,tr("Import From File"),true);
3733 if(aFileInfo.exists()){
3734 QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." );
3735 aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath());
3736 QAD_CONFIG->addSetting("Visu:InputDir",aDir);
3739 VISU::Result_var aResult;
3745 if(aFileInfo.extension(false) == "med"){
3746 QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult");
3747 bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt());
3748 if (VisuGUI_FileDlg::IsBuild){
3749 aResult = GetVisuGen()->ImportFile(aFileInfo.filePath());
3750 if(!CORBA::is_nil(aResult.in()))
3751 if(VISU::Result_i* pResult = dynamic_cast<VISU::Result_i*>(GetServant(aResult).in())){
3752 if(!pResult->IsPossible())
3753 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3754 tr ("ERR_CANT_BUILD_PRESENTATION"),
3755 tr ("VISU_BUT_OK") );
3757 aResult->BuildAll();
3760 QAD_CONFIG->addSetting( "Visu:BuildResult", false );
3761 //aResult=(GetVisuGen()->*theImportFun)(aFileInfo.filePath()); APO: 18/12/03 - fix crash on Linux RedHat 7.1
3762 aResult=GetVisuGen()->ImportFile(aFileInfo.filePath()); // APO: 18/12/03 - fix crash on Linux RedHat 7.1
3763 QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild );
3768 cout<<"VisuGUI::ImportFromFile() - IMPORT FILE\n";
3772 if(CORBA::is_nil(aResult.in())) {
3774 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3775 tr ("ERR_ERROR_IN_THE_FILE"),
3776 tr ("VISU_BUT_OK") );
3780 QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported.");
3782 GetActiveStudy()->updateObjBrowser(); //update Object browser
3786 void VisuGUI::ExportToFile(){
3787 CORBA::Object_var anObject = GetSelectedObj();
3788 if(CORBA::is_nil(anObject)) return;
3789 VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
3790 if(aBase != NULL && aBase->GetType() == VISU::TRESULT){
3792 flt.append( "Dat Files (*.dat)" );
3793 flt.append( "Med Files (*.med)" );
3794 QString aDir = getVisuOutputDir();
3795 QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(),
3796 aDir,flt,tr("Export To File"),false);
3797 if(!aFile.isEmpty()){
3798 QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." );
3799 aDir = QAD_Tools::getDirFromPath(aFile);
3800 QAD_CONFIG->addSetting("Visu:OutputDir",aDir);
3801 if(VISU::Result_i* aResult = dynamic_cast<VISU::Result_i*>(aBase)){
3803 //APO - aResult->GetInput()->ToFile(aFile.latin1());
3804 QAD_Application::getDesktop()->putInfo(aFile+" exported.");
3806 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3807 tr ("ERR_ERROR_DURING_EXPORT"),
3808 tr ("VISU_BUT_OK") );
3813 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3814 tr ("WRN_NO_AVAILABLE_DATA"),
3815 tr ("VISU_BUT_OK"));
3818 /* ======================================================================================== */
3819 /* Test and Read Object Browser before display */
3820 /* ======================================================================================== */
3821 bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){
3822 if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser");
3823 Handle(SALOME_InteractiveObject) anIO;
3824 CORBA::Object_var anObject = GetSelectedObj(&anIO);
3825 if(!anIO.IsNull() && anIO->hasEntry()){
3826 objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry());
3827 QString aValue = getValue(objVisu,"myType");
3828 if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true;
3830 QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3831 tr("WRN_NO_AVAILABLE_DATA"),
3832 tr("VISU_BUT_OK") );
3837 * Returns Actor of presentation if it exists
3839 VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){
3840 VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame();
3841 if (!vf) return NULL;
3843 vtkActorCollection *anActColl = vf->getRenderer()->GetActors();
3844 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;)
3845 if(VISU_Actor* anVISUActor = dynamic_cast<VISU_Actor*>(anActor))
3846 if(thePrs == anVISUActor->GetPrs3d())
3847 return anVISUActor->GetParent();
3852 * Displays only actor of given presentation
3853 * Creates it if it is abcent
3855 VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){
3856 VTKViewer_ViewFrame* vf = GetVtkViewFrame();
3857 if (!vf) return NULL;
3859 vtkRenderer *aRen = vf->getRenderer();
3860 vtkActorCollection *anActColl = aRen->GetActors();
3863 VISU_Actor* anVISUActor = NULL;
3864 VISU_Actor* aResActor = NULL;
3865 VISU::Prs3d_i* aSrcAddr = thePrs;
3866 for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){
3867 if(anActor->IsA("VISU_Actor")){
3868 anVISUActor = VISU_Actor::SafeDownCast(anActor);
3869 VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d();
3870 if(aPrs == NULL) continue;
3871 if (thePrs == aPrs) {
3872 aResActor = anVISUActor->GetParent();
3873 thePrs->UpdateActor(aResActor);
3874 aResActor->VisibilityOn();
3876 } else if (theDispOnly) {
3877 anVISUActor->GetParent()->VisibilityOff();
3881 if (aResActor) return aResActor;
3883 anVISUActor = thePrs->CreateActor();
3884 vf->AddActor(anVISUActor);
3885 }catch(std::runtime_error& exc){
3887 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3888 tr ("ERR_CANT_VISUALIZE_OBJECT"),
3889 tr ("VISU_BUT_OK") );
3897 * Returns TRUE if Presentation is displayed
3899 bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) {
3900 VISU_Actor* anVISUActor = GetActor(thePrs);
3901 return (anVISUActor)? anVISUActor->GetVisibility() : false;
3905 * Erases Presentation
3907 void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) {
3908 GetActiveStudy()->unHighlightAll();
3909 VISU_Actor* anVISUActor = GetActor(thePrs);
3911 anVISUActor->VisibilityOff();
3916 * Deletes given presentation from Data structure
3918 void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) {
3919 if(checkLock(GetStudyDocument()) || !thePrs) return;
3920 GetActiveStudy()->unHighlightAll();
3921 for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++)
3922 if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){
3923 QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame();
3924 if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast<VTKViewer_ViewFrame*>(aVFrame)){
3925 if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){
3926 aViewFrame->RemoveActor(anActor);
3929 aViewFrame->unHighlightAll();
3932 thePrs->RemoveFromStudy();
3933 GetActiveStudy()->updateObjBrowser(); //update Object browser
3937 * Creates new actor of presentation
3939 void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) {
3940 if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
3941 if (!thePrs) return;
3942 QApplication::setOverrideCursor( Qt::waitCursor );
3943 if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){
3949 VISU_Actor* aActor = thePrs->CreateActor();
3950 vf->AddActor(aActor);
3951 }catch(std::runtime_error& exc){
3953 QApplication::restoreOverrideCursor();
3954 QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"),
3955 tr ("WRN_CANT_VISUALIZE_PRS"),
3956 tr ("VISU_BUT_OK") );
3960 cout<<"VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR\n";
3964 QApplication::restoreOverrideCursor();
3969 /* ======================================================================================== */
3970 /* Functions to State of VisuGUI and Dialog Box */
3971 /* ======================================================================================== */
3973 void VisuGUI::SetState(int aState )
3975 this->myState = aState ;
3980 void VisuGUI::ResetState()
3982 this->myState = -1 ;
3986 void VisuGUI::EmitSignalDeactivateDialog()
3988 emit this->SignalDeactivateActiveDialog() ;
3992 void VisuGUI::EmitSignalCloseAllDialogs()
3994 emit this->SignalCloseAllDialogs() ;
3998 QDialog* VisuGUI::GetActiveDialogBox()
4000 return this->myActiveDialogBox ;
4003 void VisuGUI::SetActiveDialogBox(QDialog* aDlg)
4005 this->myActiveDialogBox = (QDialog*)aDlg ;