From: nri Date: Fri, 16 May 2003 14:05:41 +0000 (+0000) Subject: NRI : First integration. X-Git-Tag: Start-v1_1a~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=59a951f6d25e45e0587e4e97be93743b2e7bf646;p=modules%2Fvisu.git NRI : First integration. --- 59a951f6d25e45e0587e4e97be93743b2e7bf646 diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in new file mode 100644 index 00000000..e134bef1 --- /dev/null +++ b/src/VISUGUI/Makefile.in @@ -0,0 +1,92 @@ +# -* Makefile *- +# +# Author : Marc Tajchman (CEA) +# Date : 5/07/2001 +# $Header$ +# + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:$(top_srcdir)/idl:$(top_builddir)/idl + +@COMMENCE@ + +EXPORT_PYSCRIPTS = \ + VisuGUI.py + +# header files +EXPORT_HEADERS= \ + VisuGUI_NonIsometricDlg.h + +# .po files to transform in .qm +PO_FILES = \ + VISU_msg_en.po VISU_icons.po + +# Libraries targets +LIB = libVISUGUI.la +LIB_SRC = VisuGUI.cxx \ + VisuGUI_CellsResultsDlg.cxx \ + VisuGUI_PointsResultsDlg.cxx \ + VisuGUI_Selection.cxx \ + VisuGUI_PhaseDlg.cxx \ + VisuGUI_PhaseMagnitudeDlg.cxx \ + VisuGUI_MagnitudeDlg.cxx \ + VisuGUI_PartialScaDlg.cxx \ + VisuGUI_IsoSurfacesDlg.cxx \ + VisuGUI_CursorDlg.cxx \ + VisuGUI_VectorsDlg.cxx \ + VisuGUI_CutPlanesDlg.cxx \ + VisuGUI_SelVectCompDlg.cxx \ + VisuGUI_ScalarBarDlg.cxx \ + VisuGUI_SweepPrefDlg.cxx \ + VisuGUI_VisuAsDlg.cxx \ + VisuGUI_NonIsometricDlg.cxx \ + VisuGUI_StreamLinesDlg.cxx \ + VisuGUI_TimeAnimation.cxx + +LIB_MOC = \ + VisuGUI.h \ + VisuGUI_CellsResultsDlg.h \ + VisuGUI_PointsResultsDlg.h \ + VisuGUI_PhaseDlg.h \ + VisuGUI_PhaseMagnitudeDlg.h \ + VisuGUI_MagnitudeDlg.h \ + VisuGUI_PartialScaDlg.h \ + VisuGUI_IsoSurfacesDlg.h \ + VisuGUI_CursorDlg.h \ + VisuGUI_VectorsDlg.h \ + VisuGUI_CutPlanesDlg.h \ + VisuGUI_SelVectCompDlg.h \ + VisuGUI_ScalarBarDlg.h \ + VisuGUI_SweepPrefDlg.h \ + VisuGUI_VisuAsDlg.h \ + VisuGUI_NonIsometricDlg.h \ + VisuGUI_StreamLinesDlg.h \ + VisuGUI_TimeAnimation.h + +LIB_CLIENT_IDL = SALOME_Exception.idl \ + VISU_Gen.idl \ + Med_Gen.idl \ + MED.idl \ + SALOMEDS.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SALOMEDS_Attributes.idl \ + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \ + $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \ + -I${KERNEL_ROOT_DIR}/include/salome +CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS += $(OCC_LIBS) $(MED2_LIBS) $(HDF5_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ + -lVisuObject -lVISUEngine -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome + + +@CONCLUDE@ + diff --git a/src/VISUGUI/VISU_icons.po b/src/VISUGUI/VISU_icons.po new file mode 100644 index 00000000..926d6c6f --- /dev/null +++ b/src/VISUGUI/VISU_icons.po @@ -0,0 +1,32 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +msgid "ICON_OBJBROWSER_Visu" +msgstr "Visu_tree_visu.png" + +msgid "ICON_SCALAR_MAP" +msgstr "Visu_scalars.png" + +msgid "ICON_DEFORMED_SHAPE" +msgstr "Visu_deformed.png" + +msgid "ICON_VECTORS" +msgstr "Visu_vectors.png" + +msgid "ICON_ISO_SURFACES" +msgstr "Visu_isosurfaces.png" + +msgid "ICON_CUT_PLANES" +msgstr "Visu_cutplane.png" + +msgid "ICON_STREAM_LINES" +msgstr "Visu_streamlines.png" diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po new file mode 100644 index 00000000..8df1a336 --- /dev/null +++ b/src/VISUGUI/VISU_msg_en.po @@ -0,0 +1,252 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. translating +# from French to English, "Foo::Bar" would be translated to "Pub", +# not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-02-22 16:56:46 CET\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + +msgid "VISU_BUT_OK" +msgstr "OK" + +msgid "VISU_WARNING" +msgstr "Visu Warning" + +#: isodlg.cxx:20 +msgid "::VISU_MEN_ISOSURFDLG" +msgstr "Iso Surface" + +#: VisuGUI.cxx:1351 +msgid "VisuGUI::BT" +msgstr "Bad Type for Selected Item" + +#: VisuGUI.cxx:1263 +msgid "VisuGUI::II" +msgstr "Input Information not selected" + +#: VisuGUI.cxx:1636 +msgid "VisuGUI::ND" +msgstr "No Data in file selected" + +#: VisuGUI.cxx:1290 +msgid "VisuGUI::NI" +msgstr "No Data in file selected" + +#: VisuGUI.cxx:1644 +msgid "VisuGUI::NO" +msgstr "Nil Objetc" + +#: VisuGUI.cxx:1164 +msgid "VisuGUI::NR" +msgstr "No Results in file selected" + +#: VisuGUI_CursorDlg.cxx:43 +msgid "VisuGUI_CursorDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_CursorDlg.cxx:30 +msgid "VisuGUI_CursorDlg::&Help" +msgstr "Help" + +#: VisuGUI_CursorDlg.cxx:37 +msgid "VisuGUI_CursorDlg::&OK" +msgstr "OK" + +#: VisuGUI_CursorDlg.cxx:49 +msgid "VisuGUI_CursorDlg::Choose a value" +msgstr "Choose a Value" + +#: VisuGUI_CursorDlg.cxx:20 +msgid "VisuGUI_CursorDlg::MyDialog" +msgstr "Change Cursor" + +#: VisuGUI_IsoSurfacesDlg.cxx:87 +msgid "VisuGUI_IsoSurfacesDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_IsoSurfacesDlg.cxx:74 +msgid "VisuGUI_IsoSurfacesDlg::&Help" +msgstr "Help" + +#: VisuGUI_IsoSurfacesDlg.cxx:81 +msgid "VisuGUI_IsoSurfacesDlg::&OK" +msgstr "OK" + +#: VisuGUI_IsoSurfacesDlg.cxx:26 +msgid "VisuGUI_IsoSurfacesDlg::Iso Surfaces Representation" +msgstr "" + +#: VisuGUI_IsoSurfacesDlg.cxx:40 +msgid "VisuGUI_IsoSurfacesDlg::Maximum value" +msgstr "" + +#: VisuGUI_IsoSurfacesDlg.cxx:35 +msgid "VisuGUI_IsoSurfacesDlg::Minimum value" +msgstr "" + +#: VisuGUI_IsoSurfacesDlg.cxx:21 +msgid "VisuGUI_IsoSurfacesDlg::MyDialog" +msgstr "Iso Surface" + +#: VisuGUI_IsoSurfacesDlg.cxx:44 +msgid "VisuGUI_IsoSurfacesDlg::Number of surfaces" +msgstr "" + +#: VisuGUI_MagnitudeDlg.cxx:43 +msgid "VisuGUI_MagnitudeDlg::VISU_BUT_CANCEL" +msgstr "Cancel" + +#: VisuGUI_MagnitudeDlg.cxx:30 +msgid "VisuGUI_MagnitudeDlg::VISU_BUT_HELP" +msgstr "Help" + +#: VisuGUI_MagnitudeDlg.cxx:37 +msgid "VisuGUI_MagnitudeDlg::VISU_BUT_OK" +msgstr "OK" + +#: VisuGUI_MagnitudeDlg.cxx:54 +msgid "VisuGUI_MagnitudeDlg::VISU_MEN_PHASE" +msgstr "Magnitude" + +#: VisuGUI_PartialScaDlg.cxx:43 +msgid "VisuGUI_PartialScaDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_PartialScaDlg.cxx:30 +msgid "VisuGUI_PartialScaDlg::&Help" +msgstr "Help" + +#: VisuGUI_PartialScaDlg.cxx:37 +msgid "VisuGUI_PartialScaDlg::&OK" +msgstr "OK" + +#: VisuGUI_PartialScaDlg.cxx:76 +msgid "VisuGUI_PartialScaDlg::Max :" +msgstr "" + +#: VisuGUI_PartialScaDlg.cxx:81 +msgid "VisuGUI_PartialScaDlg::Min :" +msgstr "" + +#: VisuGUI_PartialScaDlg.cxx:49 +msgid "VisuGUI_PartialScaDlg::Min an Max limits of scalar Display" +msgstr "" + +#: VisuGUI_PartialScaDlg.cxx:20 +msgid "VisuGUI_PartialScaDlg::MyDialog" +msgstr "Partial Scalar" + +#: VisuGUI_PhaseDlg.cxx:43 +msgid "VisuGUI_PhaseDlg::VISU_BUT_CANCEL" +msgstr "Cancel" + +#: VisuGUI_PhaseDlg.cxx:30 +msgid "VisuGUI_PhaseDlg::VISU_BUT_HELP" +msgstr "Help" + +#: VisuGUI_PhaseDlg.cxx:37 +msgid "VisuGUI_PhaseDlg::VISU_BUT_OK" +msgstr "OK" + +#: VisuGUI_PhaseDlg.cxx:54 +msgid "VisuGUI_PhaseDlg::VISU_MEN_PHASE" +msgstr "Phase" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:83 +msgid "VisuGUI_PhaseMagnitudeDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:70 +msgid "VisuGUI_PhaseMagnitudeDlg::&Help" +msgstr "Help" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:77 +msgid "VisuGUI_PhaseMagnitudeDlg::&OK" +msgstr "OK" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:57 +msgid "VisuGUI_PhaseMagnitudeDlg::Magnitude :" +msgstr "" + +#: VisuGUI_PhaseMagnitudeDlg.cxx:52 +msgid "VisuGUI_PhaseMagnitudeDlg::Phase :" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:47 +msgid "VisuGUI_VectorsDlg::&Cancel" +msgstr "Cancel" + +#: VisuGUI_VectorsDlg.cxx:34 +msgid "VisuGUI_VectorsDlg::&Help" +msgstr "Help" + +#: VisuGUI_VectorsDlg.cxx:41 +msgid "VisuGUI_VectorsDlg::&OK" +msgstr "OK" + +#: VisuGUI_VectorsDlg.cxx:68 +msgid "VisuGUI_VectorsDlg::0.1" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:129 +msgid "VisuGUI_VectorsDlg::Arrows" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:124 +msgid "VisuGUI_VectorsDlg::Cones (2)" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:119 +msgid "VisuGUI_VectorsDlg::Cones (6)" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:109 +msgid "VisuGUI_VectorsDlg::Glyph type" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:84 +msgid "VisuGUI_VectorsDlg::Line width" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:97 +msgid "VisuGUI_VectorsDlg::Magnitude coloring" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:24 +msgid "VisuGUI_VectorsDlg::MyDialog" +msgstr "Vectors" + +#: VisuGUI_VectorsDlg.cxx:63 +msgid "VisuGUI_VectorsDlg::Scale factor" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:103 +msgid "VisuGUI_VectorsDlg::Use glyphs" +msgstr "" + +#: VisuGUI_VectorsDlg.cxx:53 +msgid "VisuGUI_VectorsDlg::Vectors Representation" +msgstr "" + +msgid "VisuGUI_BAD_MEDFILE" +msgstr "Med file is not correct" + +msgid "VisuGUI_IMPORT_FROM_MED" +msgstr "Import from med file" + +msgid "MED_MEN_IMPORT" +msgstr "Import" + +msgid "MED_MEN_ALL_FILES" +msgstr "All Files ( * )" + +msgid "MED_MEN_IMPORT_MED" +msgstr "MED Files ( *.med )" + +msgid "BUT_CLOSE" +msgstr "Close" + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx new file mode 100644 index 00000000..573f74b5 --- /dev/null +++ b/src/VISUGUI/VisuGUI.cxx @@ -0,0 +1,3974 @@ +using namespace std; +// File : VisuGUI.cxx +// Created : Wed Aug 01 10:20:18 2001 +// Author : Laurent CORNABE +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI.h" +#include "VisuGUI_PhaseDlg.h" +#include "VisuGUI_MagnitudeDlg.h" +#include "VisuGUI_PhaseMagnitudeDlg.h" +#include "VisuGUI_PartialScaDlg.h" +#include "VisuGUI_CursorDlg.h" +#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_SweepPrefDlg.h" +#include "VisuGUI_CutPlanesDlg.h" +#include "VisuGUI_VectorsDlg.h" +#include "VisuGUI_IsoSurfacesDlg.h" +#include "VisuGUI_StreamLinesDlg.h" +#include "VisuGUI_TimeAnimation.h" + +#include "VisuGUI_Selection.h" +#include "VisuGUI_VisuAsDlg.h" +#include "VisuGUI_SelVectCompDlg.h" +#include "VisuGUI_NonIsometricDlg.h" + +#include "VISU_Gen_i.hh" +#include "VISU_Result_i.hh" +#include "VISU_Extractor.hxx" +#include "VISU_Table_i.hh" +#include "VISU_ViewManager_i.hh" +#include "VISU_LookupTable.hxx" +#include "VISU_ScalarBarActor.hxx" + +#include "SALOMEGUI_ImportOperation.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "utilities.h" + +#include "QAD_Config.h" + +#include "QAD_Settings.h" +#include "QAD_Tools.h" +#include "QAD_LeftFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_MessageBox.h" +#include "QAD_ObjectBrowser.h" +#include "QAD_ObjectBrowserItem.h" +#include "QAD_Menus.h" +#include "QAD_Resource.h" +#include "QAD_ResourceMgr.h" +#include "QAD_FileDlg.h" +#include "SALOME_Selection.h" +#include "SALOMEGUI_NameDlg.h" +#include "SALOMEGUI_TableDlg.h" +#include "SALOMEGUI_SetupCurveDlg.h" +#include "SALOMEGUI_SetValueDlg.h" +#include "Plot2d_SetupPlot2dDlg.h" +#include "Plot2d_ViewFrame.h" +#include "VTKViewer_ViewFrame.h" + +// QT Includes +#define INCLUDE_MENUITEM_DEF +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//VRV: porting on Qt 3.0.5 +#if QT_VERSION >= 0x030005 +#include +#endif +//VRV: porting on Qt 3.0.5 +#include + +#include +#include CORBA_CLIENT_HEADER(Med_Gen) + +#include +#include +//#include +#include +#include +#include +#include +#include +#include + +// Open CASCADE Include +#include + +//#define CHECKTIME +#ifdef CHECKTIME +#include +#endif + +#ifdef DEBUG +static int MYDEBUG = 1; +static int MYDEBUGWITHFILES = 0; +#else +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#endif + +// unique name visu entity +//static bool localContext = false; +static VisuGUI_Selection *Selection; +static int VISU_POINT_SIZE = 5; + +QAD_Study* VisuGUI::myActiveStudy = NULL; +VISU::VISU_Gen_var VisuGUI::myComponent = VISU::VISU_Gen::_nil(); +SALOMEDS::Study_var VisuGUI::myStudy = SALOMEDS::Study::_nil(); +SALOMEDS::StudyBuilder_var VisuGUI::myStudyBuilder = SALOMEDS::StudyBuilder::_nil(); +QAD_Desktop* VisuGUI::myDesktop = NULL; + +QAD_Study* MYActiveStudy = NULL; +SALOMEDS::StudyBuilder_var MYStudyBuilder = SALOMEDS::StudyBuilder::_nil(); +SALOMEDS::Study_var MYStudyDocument = SALOMEDS::Study::_nil(); + +const QString ObjectTypes("FIELD VIEW3D MESH TIMESTAMP ENTITY FAMILY GROUP"); + + +class CustomItem : public QCustomMenuItem +{ +public: + CustomItem( const QString& s, const QFont& f ) + : string( s ), font( f ){}; + ~CustomItem(){} + + void paint( QPainter* p, const QColorGroup& /*cg*/, bool /*act*/, bool /*enabled*/, int x, int y, int w, int h ) + { + p->setFont ( font ); + p->drawText( x, y, w, h, AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string ); + } + + QSize sizeHint() + { + return QFontMetrics( font ).size( AlignHCenter | AlignVCenter | ShowPrefix | DontClip, string ); + } +private: + QString string; + QFont font; +}; + +static VisuGUI *visuGUI = 0; +static QString PREFIX = QString(getenv("USER")) + "-VISU-"; + + + +vtkRenderer* VisuGUI::GetRenderer(QAD_Study* theStudy){ + if (theStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) + return NULL; + + return ((VTKViewer_ViewFrame*)theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); +} + + +/** + * Finds value by given key + */ + +VISU::Storable::TRestoringMap VisuGUI::getMapOfValue(SALOMEDS::SObject_var theSObject) { + VISU::Storable::TRestoringMap aMap; + if(!theSObject->_is_nil()){ + SALOMEDS::GenericAttribute_var anAttr; + if (theSObject->FindAttribute(anAttr, "AttributeComment")) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + CORBA::String_var aString = aComment->Value(); + QString strIn(aString.in()); + VISU::Storable::StrToMap(strIn,aMap); + } + } + return aMap; +} + +QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) { + QString aStr(""); + VISU::Storable::TRestoringMap aMap = getMapOfValue(theSObject); + if(!aMap.empty()) + aStr = VISU::Storable::FindValue(aMap, theKey.latin1()); + return aStr; +} + + +CORBA::Object_var GetSelectedObj(string& theComment, Handle(SALOME_InteractiveObject)& theIO, QAD_Study* theStudy){ + SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection()); + if( Sel->IObjectCount() > 0 ) { + theIO = Sel->firstIObject(); + if (theIO->hasEntry()){ + SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(theIO->getEntry()); + if(!aSObject->_is_nil()){ + SALOMEDS::GenericAttribute_var anAttr; + if (aSObject->FindAttribute(anAttr, "AttributeComment")) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + theComment = aComment->Value(); + QString strIn(theComment.c_str()); + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StrToMap(strIn,aMap); + bool isExist; + theComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); + if(!isExist) theComment = "NONE"; + } else { + theComment = "NONE"; + } + aSObject->FindAttribute(anAttr, "AttributeIOR"); + if(!anAttr->_is_nil()){ + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + if(!anIOR->_is_nil()){ + CORBA::String_var aValue = anIOR->Value(); + if(strcmp(aValue,"") != 0){ + CORBA::ORB_ptr anORB = VISU::Base_i::GetORB(); + CORBA::Object_var anObject = anORB->string_to_object(aValue); + return anObject; + } + } + } + } + } + } + return CORBA::Object::_nil(); +} + +CORBA::Object_var GetSelectedObj(QAD_Study* theStudy, Handle(SALOME_InteractiveObject)* pIO = NULL, + VISU::Storable::TRestoringMap* pMap = NULL) +{ + SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection()); + if( Sel->IObjectCount() > 0 ) { + Handle(SALOME_InteractiveObject)& anIO = (*pIO) = Sel->firstIObject(); + if (anIO->hasEntry()){ + SALOMEDS::Study_var aStudy = theStudy->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()){ + SALOMEDS::GenericAttribute_var anAttr; + if (pMap != NULL && aSObject->FindAttribute(anAttr, "AttributeComment")) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + string aComm = aComment->Value(); + QString strIn(aComm.c_str()); + VISU::Storable::StrToMap(strIn,*pMap); + } + return VISU::SObjectToObject(aSObject); + } + } + } + return CORBA::Object::_nil(); +} + +int IsTrihedronDisplayed(){ + QAD_ViewFrame* aViewFrame = MYActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + VTKViewer_ViewFrame* aVTKViewFrame = dynamic_cast(aViewFrame); + return aVTKViewFrame->isTrihedronDisplayed(); +} + + +VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){ + QAD_ViewFrame* aViewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + return dynamic_cast(aViewFrame); +} + + +void RepaintCurrentView(){ + VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame(); + if (vf) + vf->Repaint(); +} + + +VISU_Actor* GetActorByIO(const Handle(SALOME_InteractiveObject)& theIO, vtkRenderer* theRen) { + vtkActorCollection* aActors = theRen->GetActors(); + vtkActor* anActor; + VISU_Actor* aVisuActor; + for (aActors->InitTraversal(); (anActor = aActors->GetNextActor())!=NULL;) { + if (anActor->IsA("VISU_Actor")) { + aVisuActor = VISU_Actor::SafeDownCast(anActor); + if (aVisuActor->hasIO()) { + if (theIO->isSame(aVisuActor->getIO())) + return aVisuActor; + } + } + } + return 0; +} + +VISU::Base_i* GetSelectedVisuObj(){ + SALOME_Selection* Sel = SALOME_Selection::Selection(MYActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + if(It.More()){ + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if (IObject->hasEntry()){ + SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(IObject->getEntry()); + if(!aSObject->_is_nil()){ + SALOMEDS::SComponent_var comp = aSObject->GetFatherComponent(); + if ( !comp->_is_nil() ) { + SALOMEDS::GenericAttribute_var anAttr; + if (comp->FindAttribute(anAttr, "AttributeName")) { + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + if (QString(aName->Value()) == QString("Visu")) { + CORBA::Object_var aObject = VISU::SObjectToObject(aSObject); + if(!CORBA::is_nil(aObject)) { + PortableServer::Servant aServant = VISU::GetServant(aObject); + if (aServant) + return dynamic_cast(aServant); + } + } + } + } + } + } + } + return NULL; +} + +/** + * Returns selected sclalar mode or -1 if it was cancelled + */ +int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){ + int aScalarMode = 0; +// const VISU::TField* aField = theResult->GetInput()->GetField(theFieldName); +// if(aField->myNbComp > 1){ +// VisuGUI_SelVectCompDlg* SelCompDlg = new VisuGUI_SelVectCompDlg(QAD_Application::getDesktop(), 0, TRUE, 0); +// if(SelCompDlg->exec()){ +// aScalarMode = SelCompDlg->whatIsChecked(); +// } else { +// aScalarMode = -1; +// } +// delete SelCompDlg; +// } + return aScalarMode; +} + + +VisuGUI::VisuGUI(){ +} + + +VisuGUI* VisuGUI::GetOrCreateVisuGUI( QAD_Desktop* desktop ){ + if(!visuGUI){ + static VisuGUI VISUGUI; + visuGUI = &VISUGUI; + Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Visu"); + myComponent = VISU::VISU_Gen::_narrow(comp); + } + /* study may have changed */ + myDesktop = desktop; + myActiveStudy = myDesktop->getActiveStudy(); + myStudy = myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active + myComponent->SetCurrentStudy(myStudy); + myStudyBuilder = myStudy->NewBuilder(); + + MYActiveStudy = myActiveStudy; + MYStudyDocument = myStudy; + MYStudyBuilder = myStudyBuilder; + return visuGUI; +} + +/* ********************************************************************************* */ +/* Function to return VisuGUI object */ +/* ********************************************************************************* */ +VisuGUI* VisuGUI::GetVisuGUI( ) +{ + return VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); +} + +/* ==================================================================================== */ +/* ==================================================================================== */ +/* ONGUI EVENT */ +/* ==================================================================================== */ +/* ==================================================================================== */ + +static int isStudyLocked(const SALOMEDS::Study_var& theStudy){ + return theStudy->GetProperties()->IsLocked(); +} + +static int checkLock(const SALOMEDS::Study_var& theStudy) { + if (isStudyLocked(theStudy)) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return true; + } + return false; +} + + + +bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) +{ + try{ + VisuGUI::GetOrCreateVisuGUI(parent); +// get Visu directories from configuration file. Default values are enabled. +/* if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) { // BugID: SAL931 + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("Not available in Non-VTK viewers"), + tr ("VISU_BUT_OK") ); + }*/ + QString VisuInputDir = getVisuInputDir(); + QString VisuOutputDir = getVisuOutputDir(); + vtkRenderer *theRenderer = GetRenderer(visuGUI->myActiveStudy); + + //vtkActorCollection* aActors = theRenderer->GetActors(); + //cout<<"### Actors Nb="<GetNumberOfItems()<myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + switch (theCommandID) + { + /* ======================================================================================== */ + /* Define Selection Mode */ + /* ======================================================================================== */ + case 101: + case 102: + case 103: + case 104: + { + QApplication::setOverrideCursor( Qt::waitCursor ); + int mode = theCommandID - 100; // Point, Edge, Cell, Actor + parent->SetSelectionMode( mode ); + QApplication::restoreOverrideCursor(); + } + break; + + /* ======================================================================================== */ + /* Import Table from file */ + /* ======================================================================================== */ + + case 199: + { + if(checkLock(aStudy)) break; + visuGUI->ImportTablesFromFile(); + break; + } + + /* ======================================================================================== */ + /* Import Mesh from MED, DAT file */ + /* ======================================================================================== */ + + case 112: + { + visuGUI->ImportFromFile(); + break; + } + + /* ======================================================================================== */ + /* Export results and mesh into a file format */ + /* ======================================================================================== */ + + case 122: + { + //visuGUI->ExportToFile(); + break; + } + + /* ========================================================================================================================= */ + /* Print to printer (132) or in file (131) */ + /* ========================================================================================================================= */ + + case 131 : + case 132 : + { + QString prFile; + if (theCommandID == 131) { // save the file + prFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + VisuOutputDir, + filters[9], + tr("TIFF File"), + false); + if ( prFile.isEmpty() ) + break; + + VisuOutputDir = QAD_Tools::getDirFromPath(prFile); // set VisuOutputDir + QAD_CONFIG->addSetting("Visu:OutputDir",VisuOutputDir); + + visuGUI->PrintRW(prFile, false); + } else { + prFile=VisuOutputDir+"SalomeVisu.tif"; + visuGUI->PrintRW(prFile, true); + } + break; + } + + /* ========================================================================== */ + /* Visualization of Results : */ + /* 4011 : Scalar Map */ + /* 4012 : Deformed Shape */ + /* 4013 : Vectors */ + /* 4014 : Iso-Surfaces */ + /* 4015 : Cut Planes */ + /* 4016 : Stream Lines */ + /* ========================================================================== */ + + case 4011 : + visuGUI->CreateScalarMap(); + break; + case 4012 : + visuGUI->CreateDeformedShape(); + break; + case 4013 : + visuGUI->CreateVectors(); + break; + case 4014 : + visuGUI->CreateIsoSurfaces(); + break; + case 4015 : + visuGUI->CreateCutPlanes(); + break; + case 4016 : + visuGUI->CreateStreamLines(); + break; + + /* ======================================================================================================================= */ + /* View Scalar Animation (Animation/scalar) */ + /* With Phase */ + /* ======================================================================================================================= */ + + //case 4021 : + //case 4022 : + //case 4023 : + + /* ========================================================================================================================= */ + /* Selection - Cell by number */ + /* ========================================================================================================================= */ + + case 4111 : + { + visuGUI->SelectCell(); + break; +/* VSR 12/03/03: see VisuGUI::SelectCell() + int TypeMode; + VISU_Actor *ActorTmp; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); + //srn: Added check if anObject is Null, then break +// if(CORBA::is_nil(anObject)) break; + + VISU::ScalarMap_i* aPrsObject = NULL; + if(!CORBA::is_nil(anObject)) + aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if(aPrsObject){ + //aPrsObject->SetIO(anIO); + //ActorTmp = aPrsObject->GetActor(); + //UpdateViewer(ActorTmp); + ActorTmp = visuGUI->UpdateViewer(aPrsObject); + } else { + ActorTmp = ActorSelected(parent,true,&TypeMode); + } + if (ActorTmp==NULL) + break; + + bool ok=FALSE; + vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); + Mapper->SetInput(ActorTmp->DataSource); + vtkDataSet *Data=Mapper->GetInput(); + int nbCells=Data->GetNumberOfCells(); + int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,""); + if (ok && theRenderer) + Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); + break; +*/ + } + + /* ========================================================================================================================= */ + /* Selection - Cell - information attribute */ + /* ========================================================================================================================= */ + + case 4112 : + { + visuGUI->InfoOnCell(); + break; +/* VSR 12/03/03: see VisuGUI::InfoOnCell() + int TypeMode; + VISU_Actor *ActorTmp; + ActorTmp = ActorSelected(parent,true,&TypeMode); + if (ActorTmp==NULL) + break; + + if ((TypeMode == SelectionCell) || (TypeMode == SelectionEdge)) + Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); + else + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"), + tr ("Not Selected View - Cell Selection Mode"), + tr ("VISU_BUT_OK") ); + break; +*/ + } + + /* ========================================================================================================================= */ + /* Selection - Point - information number */ + /* ========================================================================================================================= */ + + case 4121 : + { + visuGUI->SelectPoint(); + break; +/* VSR 12/03/03: see VisuGUI::SelectPoint() + int TypeMode; + VISU_Actor *ActorTmp; + ActorTmp = ActorSelected(parent,true,&TypeMode); + if (ActorTmp==NULL) + break; + + bool ok=FALSE; + vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); + Mapper->SetInput(ActorTmp->DataSource); + vtkDataSet *Data=Mapper->GetInput(); + int nbPoints=Data->GetNumberOfPoints(); + int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,""); + if (ok && theRenderer) + Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer); + break; +*/ + } + + /* ========================================================================================================================= */ + /* Selection - Point - information attribute */ + /* ========================================================================================================================= */ + + case 4122 : + { + visuGUI->InfoOnPoint(); + break; +/* VSR 12/03/03: see VisuGUI::InfoOnPoint() + int TypeMode; + VISU_Actor *ActorTmp; + ActorTmp = ActorSelected(parent,true,&TypeMode); + if (ActorTmp==NULL) + break; + + if (TypeMode == SelectionPoint) + Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); + else + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"), + tr ("Not Selected View - Point Selection Mode"), + tr ("VISU_BUT_OK") ); + break; +*/ + } + + /* ========================================================================================================================= */ + /* Selection - Shape */ + /* ========================================================================================================================= */ + + //case 413 : + + /* ========================================================================================================================= */ + /* Visualization - Wireframe */ + /* ========================================================================================================================= */ + + case 4211 : + ChangeViewer(parent, theRenderer, true, 1); + break; + + /* ========================================================================================================================= */ + /* Visualization - Surface */ + /* ========================================================================================================================= */ + + case 4212 : + ChangeViewer(parent, theRenderer, true, 2); + break; + + /* ========================================================================================================================= */ + /* Visualization - Points */ + /* ========================================================================================================================= */ + + case 4213 : + ChangeViewer(parent, theRenderer, true, 0); + break; + + /* ========================================================================================================================= */ + /* Visualization - Erase */ + /* ========================================================================================================================= */ + + case 422 : + if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) + ClearViewer(parent, theRenderer, -1); + break; + + /* ========================================================================================================================= */ + /* Visualization - Global */ + /* ========================================================================================================================= */ + + //case 423 : + + /* ========================================================================================================================= */ + /* Visualization - Partial */ + /* ========================================================================================================================= */ + + //case 424 : + + case 430 : + { + //Show dialog that allows to select scale function and corresponding scale factor + VisuGUI_NonIsometricDlg* m_NonIsoDlg = new VisuGUI_NonIsometricDlg ( QAD_Application::getDesktop(), "m_NonIsoDlg", + FALSE, Qt::WDestructiveClose ); + m_NonIsoDlg->show(); + break; + } + + /* ============================ */ + /* POP-UP OBJECTS BROWSER */ + /* ============================ */ + + case 900 : // Rename object + visuGUI->Rename(); + break; + + // ---------------- For Popup in Viewer + case 802 : // Erase + case 902 : // Erase + visuGUI->ErasePrs(); + break; + + case 803 : // Display only + case 903 : // Display only + visuGUI->DisplayOnlyPrs(); + break; + + case 901 : // Display + visuGUI->DisplayPrs(); + break; + + case 8041 : // Object representation : Wireframe + case 9041 : // Object representation : Wireframe + visuGUI->ChangeRepresentation(WIREFRAME); + break; + + case 8042 : // Object representation : Surface + case 9042 : // Object representation : Surface + visuGUI->ChangeRepresentation(SURFACE); + break; + + case 8043 : // Object representation : Points + case 9043 : // Object representation : Points + visuGUI->ChangeRepresentation(POINTS); + break; + + case 8044 : // Object representation : Shrink/Unshrink + case 9044 : // Object representation : Shrink/Unshrink + visuGUI->ChangeRepresentation(SHRINK); + break; + + case 8051 : // Change object color + case 9051 : // Change object color + visuGUI->ChageColor(); + break; + + case 8052 : // Change object opacity + case 9052 : // Change object opacity + visuGUI->ChangeOpacity(); + break; + + case 8053 : // Change object line width + case 9053 : // Change object line width + visuGUI->ChangeLines(); + break; + + case 808 : // Sweep IsoSurfaces or Cutplanes + case 908 : // Sweep IsoSurfaces or Cutplanes + visuGUI->Sweep(); + break; + + case 807 : // Modify visualization + case 809 : // Return Cell Id + case 810 : // Highlight Cell parameter + // ---------------- For Popup in ObjectBrowser + case 907 : // Modify visualization + + { + int TypeMode; + bool InViewer; + VISU_Actor *ActorTmp; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); + VISU::ScalarMap_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if(aPrsObject){ + ActorTmp = visuGUI->UpdateViewer(aPrsObject); + } else { + if ( ((theCommandID >= 801) && (theCommandID <= 809)) || ((theCommandID >= 8041) && (theCommandID <= 8059)) ) + InViewer= true; + else if ( ((theCommandID >= 901) && (theCommandID <= 909)) || ((theCommandID >= 9041) && (theCommandID <= 9059)) ) + InViewer = false; + + ActorTmp = ActorSelected(parent,InViewer,&TypeMode); + } + if (ActorTmp==NULL) + break; + + + if (theCommandID == 809) // return results of object picked, in the message box + { + Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); + MESSAGE("Valeur : " << Selection->getId()) + } + + if (theCommandID == 810) // Highlight Cell or point with parameter + { + bool ok=FALSE; + vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); + Mapper->SetInput(ActorTmp->DataSource); + vtkDataSet *Data=Mapper->GetInput(); + if (TypeMode == SelectionPoint) + { + int nbPoints=Data->GetNumberOfPoints(); + int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,""); + if (ok) + Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer); + } + if ( (TypeMode == SelectionCell) || (TypeMode == SelectionEdge) ) + { + int nbCells=Data->GetNumberOfCells()-1; + int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,""); + if (ok) + Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); + } + } + + break; + } + +/* ======================================================================================== */ +/* Preferences for Scalar Bar */ +/* ======================================================================================== */ + case 51: + { + ChangeScalarBar(); + + break; + } + +/* ======================================================================================== */ +/* Preferences for Sweeping */ +/* ======================================================================================== */ + case 52: + { + SetSweepingPreferences(); + } + break; + + + case 113: // Load MED using MED component + { + if (checkLock(myStudy)) break; + + Engines::Component_var aMedComp = myDesktop->getEngine("FactoryServer", "Med"); + if (CORBA::is_nil(aMedComp)) return false; + Engines::Med_Gen_var aMedGen = Engines::Med_Gen::_narrow(aMedComp); + if (CORBA::is_nil(aMedGen)) return false; + + QStringList filtersList ; + + filtersList.append( tr("MED_MEN_IMPORT_MED") ); + filtersList.append( tr("MED_MEN_ALL_FILES") ) ; + QString aFileName = QAD_FileDlg::getFileName(myDesktop, + "", + filtersList, + tr("MED_MEN_IMPORT"), + true); + if (!aFileName.isEmpty()) { + QApplication::setOverrideCursor( Qt::waitCursor ); + aMedGen->readStructFileWithFieldType(aFileName.latin1(), myActiveStudy->getTitle()); + myActiveStudy->updateObjBrowser(); + QApplication::restoreOverrideCursor(); + } + } + break; + + default: + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("Not Yet Implemented"), + tr ("VISU_BUT_OK") ); + break; + } + } +/* + catch(SALOMEDS::GenericAttribute::LockProtection&) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return false; + } +*/ + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + return false; + } + catch(...) { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr("Unknown exception was caught in VISU module"), + tr("VISU_BUT_OK") ); + return false; + } + return true; +} + + +/* ********************************************************************************* */ +/* Function to find Actor in ObjectBrowser */ +/* ********************************************************************************* */ + +VISU_Actor *VisuGUI::GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren) +{ + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( objVisu->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow(anAttr); + + MESSAGE("GetActor == > Name : " << aName->Value()); + + vtkActorCollection *ac; + vtkActor *actor; + ac = ren->GetActors(); + + for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) { + if (actor->IsA("VISU_Actor")) { + VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(actor); + if (strcmp(VISUActor->getName(), aName->Value()) == 0) + return VISUActor; + } + } + } + return NULL; +} + + +/* ********************************************************************************* */ +/* Function to find Actor in Viewer */ +/* ********************************************************************************* */ + + +VISU_Actor *VisuGUI::GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren) +{ + VisuGUI::GetOrCreateVisuGUI(parent); + + QString theEntry = IO->getEntry(); + Standard_CString aComment; + Standard_CString Persistent; + //Standard_CString aName = IO->getName(); + VISU_Actor *anActor; + result Test; + + SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); + + SALOMEDS::SObject_var objlocal = aStudy->FindObjectID(theEntry.latin1()); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeComment_var aCmnt; + SALOMEDS::AttributePersistentRef_var aPRef; + + if (objlocal->FindAttribute(anAttr, "AttributeComment")) { + aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr); + aComment = aCmnt->Value(); + } + if (objlocal->FindAttribute(anAttr, "AttributePersistentRef")) { + aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); + Persistent = aPRef->Value(); + } + + vtkActorCollection *aclocal; + vtkActor *actorlocal; + aclocal = ren->GetActors(); + + // ============================================================================= + // Test if Actor exists in theRenderer + for (aclocal->InitTraversal();(actorlocal = aclocal->GetNextActor())!=NULL;) + { + if (actorlocal->IsA("VISU_Actor")) + { + anActor = VISU_Actor::SafeDownCast(actorlocal); + MESSAGE(" getIO de anActor : " << anActor->getIO()) + if (anActor->hasIO()) + { + if (IO->isSame(anActor->getIO())) + { + MESSAGE("isSame IO") + return anActor; + } + } + } + } + + // ============================================================================= + // If Actor doesn't exist in theRenderer => create same actor in new renderer + /* int nbSf = visuGUI->myActiveStudy->getStudyFramesCount(); + SALOMEDS::SObject_var TheMeshObject= objlocal->GetFather(); + for ( int i = 0; i < nbSf; i++ ) + { + QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) + { + vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* ac = aRenderer->GetActors(); + vtkActor *actor; + for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) + { + if (actor->IsA("VISU_Actor")) + { + anActor = VISU_Actor::SafeDownCast(actor); + if (anActor->hasIO()) + { + if (IO->isSame(anActor->getIO())) + { + if (aRenderer != ren) + { + return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment)); + } + } + } + } + } + } + }*/ + return NULL; + //return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment)); +} + +/* ********************************************************************************** */ +/* Function ActorSelected */ +/* To return the Actor selected in Viewer or in ObjectBrowser */ +/* ********************************************************************************** */ + +VISU_Actor *VisuGUI::ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode) +{ + VisuGUI::GetOrCreateVisuGUI(parent); + SALOME_Selection *Sel; + QAD_ObjectBrowserItem* item; + VISU_Actor *ActorTmp; + Standard_CString PersRef = ""; + Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection()); + vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); + + + + *Mode=Sel->SelectionMode(); + + SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + //SALOMEDS::SComponent_var father = aStudy->FindComponent("VISU"); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributePersistentRef_var aPRef; + if ( InViewer ) + { + if (Sel->IObjectCount()==0) + return NULL; + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + Handle(SALOME_InteractiveObject) IObject = It.Value(); + ActorTmp=GetActor(parent,IObject,theRenderer); + } + else + { + item = (QAD_ObjectBrowserItem*)(visuGUI->myActiveStudy->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser()->getListView()->currentItem()); + if ( item != NULL ) + { + // Test if a selected visu object + QString theEntry = item->getEntry(); + + MESSAGE("==================== TheEntry : " << theEntry) + if ( theEntry.isEmpty() ) + { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("Bad Type for Selected Item in Popup Menu"), + tr ("VISU_BUT_OK") ); + return NULL; + } + + SALOMEDS::SObject_var objVisu = aStudy->FindObjectID(theEntry.latin1()); + if (objVisu->FindAttribute(anAttr, "AttributePersistentRef")) { + aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); + PersRef = aPRef->Value(); + } + + if ( objVisu->_is_nil() ) + { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("nil object"), + tr ("VISU_BUT_OK") ); + return NULL; + } + ActorTmp=GetActorObjBrowser(objVisu,theRenderer); + } + else + return NULL; + } + return (ActorTmp); +} + +/* ********************************************************************************** */ +/* Function ClearViewer - Erase the actors displayed on the viewer */ +/* ********************************************************************************** */ + +void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor) +{ + // TypeOfActor = -1 : All + // = 1 : VisuActor + // = 2 : ScalarBarActor + // = 4 : Other Actor2D + + vtkActorCollection *ac; + vtkActor2DCollection *ac2D; + vtkActor *actor; + vtkActor2D *actor2D; + ac = ren->GetActors(); + ac2D = ren->GetActors2D(); + + if(TypeOfActor == -1 || TypeOfActor == 1) { + bool TrhVisible = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy-> + getActiveStudyFrame()->getRightFrame()->getViewFrame())->isTrihedronDisplayed(); + for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) { + if (actor->IsA("VISU_Actor") || actor->IsA("vtkActor") ) + actor->VisibilityOff(); + } + if (TrhVisible) ShowTrihedron(false); + } + + if(TypeOfActor == -1 || TypeOfActor == 2) { + for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;) + if (actor2D->IsA("vtkScalarBarActor")) + actor2D->VisibilityOff(); + } + + if(TypeOfActor == -1 || TypeOfActor == 4) { + for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;) + if (!(actor2D->IsA("vtkScalarBarActor"))) // it's a plot2d + { + actor2D->VisibilityOff(); + //actor2D->Delete(); + } + } +} + +/* ********************************************************************************** */ +/* Function ShowTrihedron */ +/* ********************************************************************************** */ + +void VisuGUI::ShowTrihedron(bool ShowThd){ + bool ThdIsVisible = true; + if( ShowThd && !ThdIsVisible) + ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); + if( !ShowThd && ThdIsVisible) + ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); +} + +/* ********************************************************************************** */ +/* Destructor */ +/* Clear all tmp files used in VISU */ +/* ********************************************************************************** */ + +VisuGUI::~VisuGUI(){ + MESSAGE("VisuGUI::~VisuGUI"); +} + +/* ********************************************************************************** */ +/* Function ChangeViewer */ +/* Change representation of all actors */ +/* ********************************************************************************** */ + +void VisuGUI::ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type) +{ + if (!ren) return; + VisuGUI::GetOrCreateVisuGUI(parent); + vtkActorCollection *ac; + vtkActor *actor; + ac = ren->GetActors(); + + for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) + actor->GetProperty()->SetRepresentation(Type); +} + + +// ----------------------------------------------------------------------------------------- +// EVENTS +// ----------------------------------------------------------------------------------------- + +bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + VisuGUI::GetOrCreateVisuGUI(parent); + return true; +} + +// ==================================================================================================================== + +bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + VisuGUI::GetOrCreateVisuGUI(parent); + return true; +} + +// =================================================================================================================== + +bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) +{ + VisuGUI::GetOrCreateVisuGUI(parent); + if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC + return false; + + MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() ) + + switch ( pe->key() ) + { + case Key_Escape : + { + MESSAGE("--> Key : Escape") + return true; + } + default : + return true; + break; + } + return true; +} + + + +//===================================================================================== +// Slot-functions for presentations creation +//===================================================================================== + + +#define CREATEPRESENTATION(FunctionName) \ + void FunctionName() { \ + if (checkLock(myStudy)) return; \ + SALOMEDS::SObject_var objVisu; \ + if (!TestObjectBrowser(&objVisu)) return; \ + if(!FunctionName(objVisu)) return; \ + visuGUI->myActiveStudy->updateObjBrowser(); \ + myDesktop->putInfo("Ready"); \ + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \ + if (vf) { \ + /*vf->getRenderer()->ResetCameraClippingRange();*/ \ + vf->onViewFitAll(); \ + } \ + } + + +CREATEPRESENTATION(VisuGUI::CreateScalarMap); +CREATEPRESENTATION(VisuGUI::CreateDeformedShape); +CREATEPRESENTATION(VisuGUI::CreateVectors); +CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces); +CREATEPRESENTATION(VisuGUI::CreateCutPlanes); +CREATEPRESENTATION(VisuGUI::CreateStreamLines); + + + + +//===================================================================================== +// function : setSettings() +// purpose : +//===================================================================================== +bool VisuGUI::setSettings(QAD_Desktop* parent) +{ + VisuGUI::GetOrCreateVisuGUI(parent); + return true; +} + +//===================================================================================== +// function : DisplayPrs() +// purpose : +//===================================================================================== +void VisuGUI::DisplayPrs() { + MESSAGE("VisuGUI::DisplayPrs"); + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + if ( !CORBA::is_nil( anObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if(aPrsObject){ + MESSAGE("VisuGUI::DisplayPrs : Prs3d object"); + UpdateViewer(aPrsObject); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->getRenderer()->ResetCameraClippingRange(); +#ifdef CHECKTIME + OSD_Timer timer; + timer.Start(); +#endif + vf->Repaint(); + vf->highlight(anIO, 1); +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("Check time on VisuGUI::DisplayPrs - vf->Repaint + vf->highlight"); + timer.Show(); +#endif + } + return; + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); + if(aCurve){ + MESSAGE("VisuGUI::DisplayPrs : Curve object"); + PlotCurve(aCurve, VISU::eDisplay ); + return; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); + if(aContainer){ + MESSAGE("VisuGUI::DisplayPrs : Container object"); + PlotContainer(aContainer, VISU::eDisplay ); + return; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); + if(aTable){ + MESSAGE("VisuGUI::DisplayPrs : Table object"); + PlotTable(aTable, VISU::eDisplay ); + return; + } + } +} + +//===================================================================================== +// function : DisplayOnlyPrs() +// purpose : +//===================================================================================== +void VisuGUI::DisplayOnlyPrs() { + MESSAGE("VisuGUI::DisplayOnlyPrs"); + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + if ( !CORBA::is_nil( anObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if(aPrsObject){ + MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object"); + UpdateViewer(aPrsObject, true); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->Repaint(); + } + return; + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); + if(aCurve){ + MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object"); + PlotCurve(aCurve, VISU::eDisplayOnly ); + return; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); + if(aContainer){ + MESSAGE("VisuGUI::DisplayOnlyPrs : Container object"); + PlotContainer(aContainer, VISU::eDisplayOnly ); + return; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); + if(aTable){ + MESSAGE("VisuGUI::DisplayOnlyPrs : Table object"); + PlotTable(aTable, VISU::eDisplayOnly ); + return; + } + } +} + +//===================================================================================== +// function : ErasePrs() +// purpose : +//===================================================================================== +void VisuGUI::ErasePrs() { + MESSAGE("VisuGUI::ErasePrs"); + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + if ( !CORBA::is_nil( anObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if(aPrsObject){ + MESSAGE("VisuGUI::ErasePrs : Prs3d object"); + ErasePrs(aPrsObject); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->Repaint(); + } + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); + if(aCurve){ + MESSAGE("VisuGUI::ErasePrs : Curve object"); + PlotCurve(aCurve, VISU::eErase ); + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); + if(aContainer){ + MESSAGE("VisuGUI::ErasePrs : Container object"); + PlotContainer(aContainer, VISU::eErase ); + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); + if(aTable){ + MESSAGE("VisuGUI::ErasePrs : Table object"); + PlotTable(aTable, VISU::eErase ); + } + } +} + + +//===================================================================================== +// function : RecreateActor() +// purpose : +//===================================================================================== +void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { + /* BEGIN_OF("VisuGUI::RecreateActor"); + + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (!vf) return; + QApplication::setOverrideCursor( Qt::waitCursor ); + vtkRenderer *aRen = vf->getRenderer(); + VISU_Actor* anVISUActor = GetActor(thePrs); + + if(anVISUActor == NULL){ + anVISUActor= thePrs->CreateActor(); + anVISUActor->SetVisibility(true); + vf->AddActor(anVISUActor); + if (anVISUActor->HasScalarBar()) { + anVISUActor->getScalarBar()->SetVisibility(true); + aRen->AddActor2D(anVISUActor->getScalarBar()); + } + } + vf->Repaint(); + + QApplication::restoreOverrideCursor(); + + END_OF("VisuGUI::RecreateActor") */ + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (!vf) return; + + VISU_Actor* anVISUActor = GetActor(thePrs); + int isVisible = false; + + QApplication::setOverrideCursor( Qt::waitCursor ); + vtkRenderer *aRen = vf->getRenderer(); + if (anVISUActor) { + isVisible = anVISUActor->GetVisibility(); + Handle(SALOME_InteractiveObject) anIO = anVISUActor->getIO(); + if (anVISUActor->HasScalarBar()) + aRen->RemoveActor(anVISUActor->getScalarBar()); + aRen->RemoveActor(anVISUActor); + anVISUActor->Delete(); + anVISUActor = thePrs->CreateActor(anIO); + } else + anVISUActor = thePrs->CreateActor(); + QApplication::restoreOverrideCursor(); + + if (!anVISUActor) return; + anVISUActor->SetVisibility(isVisible); + aRen->AddActor(anVISUActor); + if (anVISUActor->HasScalarBar()) { + anVISUActor->getScalarBar()->SetVisibility(isVisible); + aRen->AddActor2D(anVISUActor->getScalarBar()); + } +} + + +//===================================================================================== +// function : EditPrs() +// purpose : +//===================================================================================== +#define EDITPRS(PrsName, DlgName) \ + { \ + PrsName* aPrsObject = dynamic_cast(aPrs3d); \ + if (aPrsObject) { \ + DlgName* aDlg = new DlgName(); \ + aDlg->initFromPrsObject(aPrsObject); \ + if ( aDlg->exec() ) { \ + aDlg->storeToPrsObject(aPrsObject); \ + RecreateActor(aPrsObject); \ + /*RepaintCurrentView();*/ \ + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \ + if (vf) { \ + if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \ + vf->getRenderer()->ResetCameraClippingRange(); \ + vf->onViewFitAll(); \ + }\ + } \ + } \ + delete aDlg; \ + } \ + } + + +void VisuGUI::EditPrs() { + VISU::Prs3d_i* aPrs3d = GetSelectedPrs(); + + switch (aPrs3d->GetType()) { + case VISU::TMESH: // Mesh 13 + break; + + case VISU::TSCALARMAP: // ScalarMap 18 + EDITPRS(VISU::ScalarMap_i, VisuGUI_ScalarBarDlg); + break; + + case VISU::TDEFORMEDSHAPE: // Deformed Shape 28 + EDITPRS(VISU::DeformedShape_i, VisuGUI_MagnitudeDlg); + break; + + case VISU::TCUTPLANES: // Cut planes 42 + EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg); + break; + + case VISU::TISOSURFACE: // Iso surfaces + EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg); + break; + case VISU::TVECTORS: // Vectors 64 + EDITPRS(VISU::Vectors_i, VisuGUI_VectorsDlg); + break; + + case VISU::TSTREAMLINES: + EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg); + } +} + + +//===================================================================================== +// function : EditScalarBar() +// purpose : +//===================================================================================== +void VisuGUI::EditScalarBar() { + VISU::Prs3d_i* aPrs3d = GetSelectedPrs(); + VISU::ScalarMap_i* aPrsObject = dynamic_cast(aPrs3d); + if (aPrsObject) { + VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false); + aDlg->initFromPrsObject(aPrsObject); + if ( aDlg->exec() ) { + aDlg->storeToPrsObject(aPrsObject); + RecreateActor(aPrsObject); + + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) + vf->Repaint(); + + if (aDlg->isToSave()) + aDlg->storeToResources(); + } + delete aDlg; + } + +} + + +//===================================================================================== +// function : CreateMesh() +// purpose : +//===================================================================================== +void VisuGUI::CreateMesh() { + + //string aComment; + //Handle(SALOME_InteractiveObject) anIO; + //CORBA::Object_var anObject = GetSelectedObj(aComment,anIO, VisuGUI::myActiveStudy); + SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SALOMEDS::SObject_var aSObject = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + + if (checkLock(myStudy)) return; + + SALOMEDS::SObject_var aSObj = aSObject->GetFather(); + aSObj = aSObj->GetFather(); + aSObj = aSObj->GetFather(); + CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); + if(CORBA::is_nil(anObject)) { + aSObj = aSObj->GetFather(); + anObject = VISU::SObjectToObject(aSObj); + if(CORBA::is_nil(anObject)) return; + } + VISU::Result_var aResult = VISU::Result::_narrow(anObject); + if(CORBA::is_nil(aResult)) return; + + VISU::Storable::TRestoringMap aMap; + SALOMEDS::GenericAttribute_var anAttr; + if(aSObject->FindAttribute(anAttr, "AttributeComment")) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + string aComm = aComment->Value(); + QString strIn(aComm.c_str()); + VISU::Storable::StrToMap(strIn,aMap); + } + bool isExist; + string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); + if(!isExist) return; + CORBA::Object_var aMesh; + string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1(); + if(aComment == "ENTITY"){ + VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt(); + aMesh = myComponent->MeshOnEntity(aResult,aMeshName.c_str(),anEntity); + }else if(aComment == "FAMILY"){ + VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt(); + string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1(); + aMesh = myComponent->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()); + }else if(aComment == "GROUP"){ + string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1(); + aMesh = myComponent->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str()); + } + QApplication::restoreOverrideCursor(); + if(CORBA::is_nil(aMesh)) return; + + VISU::Mesh_i* pPresent = dynamic_cast(VISU::GetServant(aMesh)); +#ifdef CHECKTIME + OSD_Timer timer; + timer.Start(); +#endif + VISU_Actor *anActor = pPresent->CreateActor(); + if (! anActor ) return; +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("Check time on VisuGUI::CreateMesh - pPresent->CreateActor"); + timer.Show(); +#endif + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ + //vtkRenderer *aRenderer = vf->getRenderer(); + //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1); + //visuGUI->ShowTrihedron(true); +#ifdef CHECKTIME + OSD_Timer timer; + timer.Start(); +#endif + vf->AddActor(anActor); + vf->AddActor(anActor->EdgeDevice); + // vf->getRenderer()->AddActor(anActor->EdgeDevice); + vf->getRenderer()->ResetCameraClippingRange(); + vf->onViewFitAll(); +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("Check time on VisuGUI::CreateMesh - vf->AddActor + vf->onViewFitAll"); + timer.Show(); +#endif + } + //myActiveStudy->updateObjBrowser(); //not necessary + myDesktop->putInfo("Ready"); +} + + +//===================================================================================== +// function : ChangeRepresentation() +// purpose : +//===================================================================================== + +static void ShrinkMesh(VISU_Actor *Actor){ + if (!(Actor->IsShrunk)){ + vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); + vtkShrinkFilter *shrink = vtkShrinkFilter::New(); + shrink->SetInput(mapper->GetInput()); + shrink->SetShrinkFactor(0.8); + mapper->SetInput(shrink->GetOutput()); + Actor->IsShrunk = true; + shrink->Delete(); + Actor->EdgeDevice->VisibilityOff(); + }else{ + vtkDataSetMapper* aMapper = vtkDataSetMapper::SafeDownCast(Actor->GetInitialMapper()); + if (aMapper) { + vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); + aTransformFilter->SetInput(aMapper->GetPolyDataMapper()->GetInput()); + aTransformFilter->SetTransform (VisuGUI::GetVtkViewFrame()->getNonIsometricTransform()); + + //create new mapper + aMapper = vtkDataSetMapper::New(); + aMapper->SetInput (aTransformFilter->GetOutput()); + aMapper->ShallowCopy ( Actor->GetMapper()); + Actor->SetMapper (aMapper); + + aTransformFilter->Delete(); + aMapper->Delete(); + } else { + vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); + mapper->SetInput(Actor->DataSource); + } + //Actor->GetMapper()->Update(); + Actor->IsShrunk = false; + if ( Actor->GetProperty()->GetRepresentation() == 2 ) + Actor->EdgeDevice->VisibilityOn(); + } +} + +void VisuGUI::ChangeRepresentation(RepresentType theType) { + VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if(!aPrsObject) return; + +#ifdef CHECKTIME + OSD_Timer timer; + timer.Start(); +#endif + VISU_Actor* anActor = GetActor(aPrsObject); + if (!anActor) return; + switch (theType) { + case POINTS: + anActor->EdgeDevice->VisibilityOff(); + anActor->GetProperty()->SetRepresentation(0); + anActor->GetProperty()->SetPointSize(VISU_POINT_SIZE); + break; + case WIREFRAME: + anActor->EdgeDevice->VisibilityOff(); + anActor->GetProperty()->SetRepresentation(1); + break; + case SURFACE: + if ( !anActor->IsShrunk ) + anActor->EdgeDevice->VisibilityOn(); + anActor->GetProperty()->SetRepresentation(2); + break; + case SHRINK: + ShrinkMesh(anActor); + break; + } + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) + vf->Repaint(); +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("Cheking time in VisuGUI::ChangeRepresentation - anActor->GetProperty()->SetRepresentation + vf->Repaint"); + timer.Show(); +#endif +} + +void VisuGUI::MakeWireframe() { + ChangeRepresentation(WIREFRAME); +} + + +void VisuGUI::MakeSurface() { + ChangeRepresentation(SURFACE); +} + + +void VisuGUI::MakePoints() { + ChangeRepresentation(POINTS); +} + + +void VisuGUI::MakeShrink() { + ChangeRepresentation(SHRINK); +} + + + +//===================================================================================== +// functions : Change Propertise +// purpose : +//===================================================================================== +VISU::Prs3d_i* VisuGUI::GetSelectedPrs() { + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + return dynamic_cast(VISU::GetServant(anObject)); +} + +void VisuGUI::ChageColor() { + VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if(!aPrsObject) return; + + VISU_Actor* anActor = GetActor(aPrsObject); + if (!anActor) return; + NewColor(anActor); +} + +void VisuGUI::ChangeOutlineColor() { + VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if(!aPrsObject) return; + + VISU_Actor* anActor = GetActor(aPrsObject); + if (!anActor) return; + NewOutlineColor(anActor); +} + + +void VisuGUI::ChangeOpacity() { + VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if(!aPrsObject) return; + + VISU_Actor* anActor = GetActor(aPrsObject); + if (!anActor) return; + NewOpacity(anActor); +} + + +void VisuGUI::ChangeLines() { + VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if(!aPrsObject) return; + + VISU_Actor* anActor = GetActor(aPrsObject); + if (!anActor) return; + NewLinewidth(anActor); +} +void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) +{ + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + if ( table && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( theDisplaying == VISU::eDisplayOnly ) + aPlot->EraseAll(); + QList clist; + aPlot->getCurves( clist ); + SALOMEDS::SObject_var TableSO = visuGUI->myActiveStudy->getStudyDocument()->FindObjectID( table->GetEntry() ); + if ( !TableSO->_is_nil() ) { + SALOMEDS::ChildIterator_var Iter = visuGUI->myActiveStudy->getStudyDocument()->NewChildIterator( TableSO ); + for ( ; Iter->More(); Iter->Next() ) { + CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() ); + if( !CORBA::is_nil( childObject ) ) { + CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject ); + if( !CORBA::is_nil( aCurve ) ) { + VISU::Curve_i* theCurve = dynamic_cast( VISU::GetServant( aCurve ) ); + Plot2d_Curve* plotCurve = 0; + for ( int i = 0; i < clist.count(); i++ ) { + if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) { + plotCurve = clist.at( i ); + break; + } + } + if ( theDisplaying == VISU::eErase ) { + if ( plotCurve ) { + aPlot->eraseCurve( plotCurve, false ); + clist.remove( plotCurve ); + } + } + else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { + if ( plotCurve ) { + plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); + //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); + plotCurve->setVerTitle( strdup( theCurve->GetName() ) ); + plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); + plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); + /* - DATA NOT UPDATED */ + if ( !plotCurve->isAutoAssign() ) { + plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); + plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); + SALOMEDS::Color color = theCurve->GetColor(); + plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); + plotCurve->setAutoAssign( theCurve->IsAuto() ); + } + aPlot->displayCurve( plotCurve, false ); + } + else { + Plot2d_Curve* crv = theCurve->CreatePresentation(); + if ( crv ) + aPlot->displayCurve( crv, false ); + } + } + } + } + } + aPlot->Repaint(); + } + } +} +void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) +{ + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + if ( theCurve && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); +// if ( theDisplaying == VISU::eDisplayOnly ) +// aPlot->EraseAll(); + QList clist; + aPlot->getCurves( clist ); + Plot2d_Curve* plotCurve = 0; + for ( int i = 0; i < clist.count(); i++ ) { + if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) { + plotCurve = clist.at( i ); + } + else if ( theDisplaying == VISU::eDisplayOnly ) { + aPlot->eraseCurve( clist.at( i ) ); + } + } + if ( theDisplaying == VISU::eErase ) { + if ( plotCurve ) + aPlot->eraseCurve( plotCurve, false ); + } + else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { + if ( plotCurve ) { + plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); + //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); + plotCurve->setVerTitle( strdup( theCurve->GetName() ) ); + plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); + plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); + /* DATA NOT UPDATED */ + if ( !plotCurve->isAutoAssign() ) { + plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); + plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); + SALOMEDS::Color color = theCurve->GetColor(); + plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); + plotCurve->setAutoAssign( theCurve->IsAuto() ); + } + aPlot->displayCurve( plotCurve, false ); + } + else { + Plot2d_Curve* crv = theCurve->CreatePresentation(); + if ( crv ) { + aPlot->displayCurve( crv, false ); + } + } + } + aPlot->Repaint(); + } +} +void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) +{ + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + if ( container && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( theDisplaying == VISU::eDisplayOnly ) + aPlot->EraseAll(); + QList clist; + aPlot->getCurves( clist ); + if ( container->GetNbCurves() > 0 ) { + int nbCurves = container->GetNbCurves(); + for ( int k = 1; k <= nbCurves; k++ ) { + VISU::Curve_i* theCurve = container->GetCurve( k ); + if ( theCurve && theCurve->IsValid() ) { + Plot2d_Curve* plotCurve = aPlot->getCurveByIO( new SALOME_InteractiveObject( strdup(theCurve->GetEntry()), "", "" ) ); +// for ( int i = 0; i < clist.count(); i++ ) { +// if ( clist.at( i )->hasIO() && !strcmp( clist.at( i )->getIO()->getEntry(), theCurve->GetEntry() ) ) { +// plotCurve = clist.at( i ); +// break; +// } +// } + if ( theDisplaying == VISU::eErase ) { + if ( plotCurve ) { + aPlot->eraseCurve( plotCurve, false ); + clist.remove( plotCurve ); + } + } + else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { + if ( plotCurve ) { + plotCurve->setHorTitle( strdup( theCurve->GetHorTitle().c_str() ) ); + //plotCurve->setVerTitle( strdup( theCurve->GetVerTitle().c_str() ) ); + plotCurve->setVerTitle( strdup( theCurve->GetName() ) ); + plotCurve->setHorUnits( strdup( theCurve->GetHorUnits().c_str() ) ); + plotCurve->setVerUnits( strdup( theCurve->GetVerUnits().c_str() ) ); + /* - DATA NOT UPDATED */ + if ( !plotCurve->isAutoAssign() ) { + plotCurve->setLine( (Plot2d_Curve::LineType)theCurve->GetLine(), theCurve->GetLineWidth() ); + plotCurve->setMarker( (Plot2d_Curve::MarkerType)theCurve->GetMarker() ); + SALOMEDS::Color color = theCurve->GetColor(); + plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); + plotCurve->setAutoAssign( theCurve->IsAuto() ); + } + aPlot->displayCurve( plotCurve, false ); + } + else { + Plot2d_Curve* crv = theCurve->CreatePresentation(); + if ( crv ) + aPlot->displayCurve( crv, false ); + } + } + } + } + } + aPlot->Repaint(); + } +} +/*! + Slot : opens Table view : for Table object or SObject with table attribute selected +*/ +void VisuGUI::ShowTable() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if( Sel->IObjectCount() !=1 ) + return; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + SALOMEDS::SObject_var SO; + if ( !CORBA::is_nil( anObject ) ) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) { + CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject ); + if( !CORBA::is_nil( aTable ) ) { + VISU::Table_i* table = dynamic_cast( VISU::GetServant( aTable ) ); + if ( table ) { + SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); + } + } + } + } else { + // possibly this is Table SObject + SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( anIO->getEntry() ); + } + SALOMEDS::GenericAttribute_var anAttr; + if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) + && !SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) + return; + SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(), + SO, + false ); + dlg->show(); +} +/*! + Opens dialog box for curves creation. Acts only for selected SObject with table attribute. +*/ +void VisuGUI::PlotData() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if( Sel->IObjectCount() !=1 ) + return; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + SALOMEDS::SObject_var SO; + if ( !CORBA::is_nil( anObject ) ) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) { + // Table (VISU object) is selected + CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject ); + if( !CORBA::is_nil( aTbl ) ) { + VISU::Table_i* table = dynamic_cast( VISU::GetServant( aTbl ) ); + if ( table ) { + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + QString SOName; + SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); + if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || + SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { + // get name of SObject + if ( SO->FindAttribute( anAttr, "AttributeName" ) ) { + aName = SALOMEDS::AttributeName::_narrow( anAttr ); + SOName = strdup( aName->Value() ); + } + Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); + if ( dlg->exec() == QDialog::Accepted ) { + if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + // if study is not locked - create new container, create curves + // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type + int horIndex; + QValueList verIndices; + dlg->getCurvesSource( horIndex, verIndices ); + if ( horIndex >= 0 && verIndices.count() > 0 ) { + CORBA::Object_var aContainer = myComponent->CreateContainer(); + if( !CORBA::is_nil( aContainer ) ) { + VISU::Container_i* pContainer = dynamic_cast( VISU::GetServant( aContainer ) ); + if ( pContainer ) { + for ( int i = 0; i < verIndices.count(); i++ ) { + CORBA::Object_var aNewCurve = myComponent->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 ); + if( !CORBA::is_nil( aNewCurve ) ) { + VISU::Curve_i* pCrv = dynamic_cast( VISU::GetServant( aNewCurve ) ); + if ( pCrv ) { + bool isAuto; + int marker, line, lineWidth; + QColor color; + if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) { + SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.; + pCrv->SetColor( c ); + pCrv->SetMarker( ( VISU::Curve::MarkerType )marker ); + pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth ); + } + pContainer->AddCurve( pCrv->_this() ); + } + } + } + VisuGUI::myActiveStudy->updateObjBrowser( true ); + PlotContainer( pContainer, VISU::eDisplay ); + } + } + } + } + else { + // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type + Plot2d_CurveContainer container; + dlg->getCurves( container ); + if ( !container.isEmpty() ) { + ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + getRightFrame()->getViewFrame()))->displayCurves( container, true ); + ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + getRightFrame()->getViewFrame()))->setTitle( SOName ); + } + } + } + delete dlg; + } + } + } + } + } + else { + // possibly this is Table SObject + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + QString SOName; + + // check if Table SObject is selected + SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || + SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { + // get name of SObject + if ( SO->FindAttribute( anAttr, "AttributeName" ) ) { + aName = SALOMEDS::AttributeName::_narrow( anAttr ); + SOName = strdup( aName->Value() ); + } + Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); + if ( dlg->exec() == QDialog::Accepted ) { + if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + // if study is not locked - create new table and container objects, create curves + // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type + int horIndex; + QValueList verIndices; + dlg->getCurvesSource( horIndex, verIndices ); + if ( horIndex >= 0 && verIndices.count() > 0 ) { + CORBA::Object_var aTable = myComponent->CreateTable( SO->GetID() ); + CORBA::Object_var aContainer = myComponent->CreateContainer(); + if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) { + VISU::Table_i* pTable = dynamic_cast( VISU::GetServant( aTable ) ); + VISU::Container_i* pContainer = dynamic_cast( VISU::GetServant( aContainer ) ); + + if ( pContainer && pTable ) { + for ( int i = 0; i < verIndices.count(); i++ ) { + CORBA::Object_var aNewCurve = myComponent->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 ); + if( !CORBA::is_nil( aNewCurve ) ) { + VISU::Curve_i* pCrv = dynamic_cast( VISU::GetServant( aNewCurve ) ); + if ( pCrv ) { + bool isAuto; + int marker, line, lineWidth; + QColor color; + if ( dlg->getCurveAttributes( verIndices[i], isAuto, marker, line, lineWidth, color ) && !isAuto ) { + SALOMEDS::Color c; c.R = color.red()/255.; c.G = color.green()/255.; c.B = color.blue()/255.; + pCrv->SetColor( c ); + pCrv->SetMarker( ( VISU::Curve::MarkerType )marker ); + pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth ); + } + pContainer->AddCurve( pCrv->_this() ); + } + } + } + VisuGUI::myActiveStudy->updateObjBrowser( true ); + PlotContainer( pContainer, VISU::eDisplay ); + } + } + } + } + else { + // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_CurveContainer container; + dlg->getCurves( container ); + if ( !container.isEmpty() ) { + ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + getRightFrame()->getViewFrame()))->displayCurves( container, true ); + ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + getRightFrame()->getViewFrame()))->setTitle( SOName ); + } + } + } + } + delete dlg; + } + } +} +/*! + Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected +*/ +void VisuGUI::CurveProperties() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if( Sel->IObjectCount() !=1 ) + return; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + SALOMEDS::SObject_var SO; + if (CORBA::is_nil( anObject )) return; + + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) { + // Curve object + CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject ); + if( !CORBA::is_nil( aCurve ) ) { + VISU::Curve_i* curve = dynamic_cast( VISU::GetServant( aCurve ) ); + if ( curve && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() ); + dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() ); + dlg->setMarker( (int)curve->GetMarker() ); + SALOMEDS::Color color = curve->GetColor(); + dlg->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); + if( dlg->exec() == QDialog::Accepted ) { + curve->SetLine( (VISU::Curve::LineType)dlg->getLine(), dlg->getLineWidth() ); + curve->SetMarker( (VISU::Curve::MarkerType)dlg->getMarker()); + SALOMEDS::Color newColor; + newColor.R = dlg->getColor().red()/255.; + newColor.G = dlg->getColor().green()/255.; + newColor.B = dlg->getColor().blue()/255.; + curve->SetColor( newColor ); + QList sfList = VisuGUI::myActiveStudy->getStudyFrames(); + if ( sfList.count() > 0 ) { + QListIterator it( sfList ); + for ( ; it.current(); ++it ) { + if ( it.current()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)it.current()->getRightFrame()->getViewFrame(); + Handle(SALOME_InteractiveObject) IO = aPlot->FindIObject( curve->GetEntry() ); + if ( IO.IsNull() ) + continue; + Plot2d_Curve* plotCurve = aPlot->getCurveByIO( IO ); + if ( plotCurve ) { + plotCurve->setLine( (Plot2d_Curve::LineType)dlg->getLine(), dlg->getLineWidth() ); + plotCurve->setMarker( (Plot2d_Curve::MarkerType)dlg->getMarker() ); + plotCurve->setColor( dlg->getColor() ); + aPlot->updateCurve( plotCurve, true ); + } + } + } + } + } + } + } + } +} + + +/*! + Slot : Clears container contents : for Container object selected +*/ +void VisuGUI::ClearContainer() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if( Sel->IObjectCount() !=1 ) + return; + + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + SALOMEDS::SObject_var SO; + if (CORBA::is_nil( anObject )) return; + + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) { + // Container object + CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject ); + if( !CORBA::is_nil( aCnt ) ) { + VISU::Container_i* container = dynamic_cast( VISU::GetServant( aCnt ) ); + if ( container && container->GetNbCurves() > 0 && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + container->Clear(); + VisuGUI::myActiveStudy->updateObjBrowser(); + } + } + } +} + + +void VisuGUI::DeletePrs() { + DeletePresentation(GetSelectedPrs()); +} + +void VisuGUI::SaveViewParams() +{ + if (checkLock(myStudy)) return; + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + return; + // getting view manager + CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager(); + if( CORBA::is_nil( aVM ) ) + return; + VISU::ViewManager_i* pVM = dynamic_cast( VISU::GetServant( aVM ) ); + if ( !pVM ) + return; + // getting current 3d view + CORBA::Object_var aView = pVM->GetCurrentView(); + if( CORBA::is_nil( aView ) ) + return; + VISU::View3D_i* pView = dynamic_cast( VISU::GetServant( aView ) ); + if ( !pView ) + return; + if ( Sel->IObjectCount() == 0 ) { + // Save view parameters by new name + pView->SaveViewParams( 0 ); + VisuGUI::myActiveStudy->updateObjBrowser( true ); + } + else { + // Try to save view parameters by selected object's name + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); +// QString strIn( aComment.c_str() ); +// VISU::Storable::RestoringMapType aMap; +// VISU::Storable::StrToMap( strIn,aMap ); +// QString aCmt = VISU::Storable::FindValue( aMap, "myComment" ); + if (ObjectTypes.find( aComment.c_str() ) == 6 ) { + pView->SaveViewParams( anIO->getName() ); + VisuGUI::myActiveStudy->updateObjBrowser( true ); + } + } +} +void VisuGUI::RestoreViewParams() +{ + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + return; + // getting view manager + CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager(); + if( CORBA::is_nil( aVM ) ) + return; + VISU::ViewManager_i* pVM = dynamic_cast( VISU::GetServant( aVM ) ); + if ( !pVM ) + return; + // getting current 3d view + CORBA::Object_var aView = pVM->GetCurrentView(); + if( CORBA::is_nil( aView ) ) + return; + VISU::View3D_i* pView = dynamic_cast( VISU::GetServant( aView ) ); + if ( !pView ) + return; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + QString aCmt = aComment.c_str(); + if ( !aCmt.isEmpty() && ObjectTypes.find( aCmt ) == 6 ) { + pView->RestoreViewParams( anIO->getName() ); + } +} + +//===================================================================================== +// function : DeleteViewParams() +// purpose : +//===================================================================================== +void VisuGUI::DeleteViewParams() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection()); + if( Sel->IObjectCount() > 0 ) { + SALOME_ListIteratorOfListIO aSelectionIterator(Sel->StoredIObjects()); + for(;aSelectionIterator.More(); aSelectionIterator.Next()) { + Handle(SALOME_InteractiveObject) anIO = aSelectionIterator.Value(); + if (anIO->hasEntry()){ + SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()){ + SALOMEDS::GenericAttribute_var anAttr; + if (aSObject->FindAttribute(anAttr, "AttributeComment")) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + int aType; + // possibly this is view params + QString strIn(aComment->Value()); + VISU::Storable::TRestoringMap aMap; + VISU::Storable::StrToMap( strIn, aMap ); + QString aCmt; + bool isExist; + aCmt = VISU::Storable::FindValue( aMap, "myComment", &isExist ); + if ( isExist ) aType = ObjectTypes.find( aCmt ); + if (aType == 6) { + MYStudyDocument->NewBuilder()->RemoveObject(aSObject); + Sel->RemoveIObject(anIO, 0); + } + } + } + } + } + } + VisuGUI::myActiveStudy->updateObjBrowser( true ); +} + + +//===================================================================================== +// function : Sweep() +// purpose : +//===================================================================================== +void VisuGUI::Sweep() { + VISU::ScalarMap_i* aPrsObject = dynamic_cast(GetSelectedPrs()); + if (!aPrsObject) return; + + int aTemp=100000; + QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo"); + if ( !aTempoStr.isEmpty() ) + aTemp = int(1.E6*(aTempoStr.toFloat())); + + int aCycles=1; + QString aCyclesStr = QAD_CONFIG->getSetting("Visu:SweepCycles"); + if ( !aCyclesStr.isEmpty() ) + aCycles = aCyclesStr.toInt(); + + int aSteps=40; + QString aStepsStr = QAD_CONFIG->getSetting("Visu:SweepSteps"); + if ( !aStepsStr.isEmpty() ) + aSteps = aStepsStr.toInt(); + + VISU_Actor* aActor = GetActor(aPrsObject); + if (!aActor) return; + + if (!aActor->GetVisibility()) { + aActor->VisibilityOn(); + if (aActor->HasScalarBar()) + aActor->getScalarBar()->VisibilityOn(); + } + vtkDataSetMapper* aMapper = (vtkDataSetMapper*) aActor->GetMapper(); + VISU_LookupTable* aLookupTbl = (VISU_LookupTable*) aMapper->GetLookupTable(); + + QApplication::setOverrideCursor( Qt::waitCursor ); + + switch (aPrsObject->GetType()) { + case VISU::TCUTPLANES: // Cut planes 42 + case VISU::TSCALARMAP: // ScalarMap 18 + for (int j=0 ; jSetMapScale(float(i)/float(aSteps)); + RepaintCurrentView(); + usleep(aTemp); + } + } + break; + + case VISU::TDEFORMEDSHAPE: // Deformed Shape 28 + { + VISU::DeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); + if (aDefPrs) { + float aScale = aDefPrs->GetScale(); + bool isColored = aDefPrs->isColored(); + vtkWarpVector* aWarp = vtkWarpVector::New(); + if((VISU::Entity)aDefPrs->GetField()->myEntity == VISU::CELL) { + vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); + aFilter->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput()); + aFilter->PassCellDataOn(); + aWarp->SetInput(aFilter->GetUnstructuredGridOutput()); + aFilter->Delete(); + } else + aWarp->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput()); + for (int j=0 ; jSetScaleFactor(aScale*float(i)/float(aSteps)); + aMapper->SetInput(aWarp->GetOutput()); + + if (isColored) + aLookupTbl->SetMapScale(float(i)/float(aSteps)); + RepaintCurrentView(); + usleep(aTemp); + } + } + aWarp->Delete(); + } + } + break; + + case VISU::TISOSURFACE: // Iso surfaces + { + VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast(aPrsObject); + if (aIsoPrs) { + int nbIso = aIsoPrs->GetNbSurfaces(); + if (nbIso <= 1) break; + vtkContourFilter* aContourFilter = vtkContourFilter::New(); + if ((VISU::Entity)aIsoPrs->GetField()->myEntity == VISU::CELL) { + vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); + aFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput()); + aFilter->PassCellDataOn(); + aContourFilter->SetInput(aFilter->GetOutput()); + aFilter->Delete(); + } else + aContourFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput()); + float aMul; + for (int j=0 ; jSetMapScale(aMul); + aContourFilter->GenerateValues(nbIso*(i+1)/aSteps,aIsoPrs->GetRangeMin(),aIsoPrs->GetRangeMax()); + aMapper->SetInput(aContourFilter->GetOutput()); + RepaintCurrentView(); + usleep(aTemp); + } + } + aContourFilter->Delete(); + } + } + break; + } + QApplication::restoreOverrideCursor(); +} + + + +void VisuGUI::TimeAnimation() { + VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(myStudy); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + + bool isDefined = false; + long aNbTimes = 0; + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for (; It.More(); It.Next()) { + SALOMEDS::SObject_var aSObject = myStudy->FindObjectID( It.Value()->getEntry() ); + if (aSObject->_is_nil()) continue; + if (getValue(aSObject, "myComment") == QString("FIELD")) { + long aNumber = getValue(aSObject, "myNbTimeStamps").toLong(); + if (aNumber > 1) { + if (!isDefined) { + aNbTimes = aNumber; + aAnimationDlg->addField(aSObject); + isDefined = true; + } else if (aNbTimes == aNumber) { + aAnimationDlg->addField(aSObject); + } + } + } + } + if (isDefined) aAnimationDlg->show(); + else delete aAnimationDlg; +} + + + +void VisuGUI::ImportMedField() { + if (checkLock(myStudy)) return; + + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + QApplication::setOverrideCursor( Qt::waitCursor ); + for(;It.More();It.Next()) { + Handle(SALOME_InteractiveObject) anIO = It.Value(); + SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()){ + SALOMEDS::GenericAttribute_var anAttr; + aSObject->FindAttribute(anAttr, "AttributeIOR"); + if(!anAttr->_is_nil()){ + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + if(!anIOR->_is_nil()){ + CORBA::String_var aValue = anIOR->Value(); + if(strcmp(aValue,"") != 0){ + CORBA::ORB_ptr anORB = VISU::Base_i::GetORB(); + CORBA::Object_var anObject = anORB->string_to_object(aValue); + if ( !CORBA::is_nil( anObject ) ) { + //SALOME_MED::FIELD_ptr aField = SALOME_MED::FIELD::_narrow( anObject ); + SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject ); + if( !CORBA::is_nil( aMED ) ) { + VisuGUI::myComponent->ImportMed( aSObject ); + continue; + } + } + } + } + } + } + } + VisuGUI::myActiveStudy->updateObjBrowser( true ); + QApplication::restoreOverrideCursor(); +} +/* +void VisuGUI::ImportMedMesh() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if ( Sel->IObjectCount() != 1 ) + return; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, VisuGUI::myActiveStudy); + if ( !CORBA::is_nil( anObject ) ) { + SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject ); + if( !CORBA::is_nil( aMesh ) ) { + VisuGUI::myComponent->ImportMedMesh( aMesh ); + VisuGUI::myActiveStudy->updateObjBrowser( true ); + } + SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject ); + if( !CORBA::is_nil( aSupport ) ) { + VisuGUI::myComponent->ImportMedSupport( aSupport ); + VisuGUI::myActiveStudy->updateObjBrowser( true ); + } + } +} +*/ +//===================================================================================== +// functions : Rename() +// purpose : +//===================================================================================== +void VisuGUI::Rename() { + if (checkLock(myStudy)) return; + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if ( Sel->IObjectCount() != 1 ) + return; + SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( Sel->firstIObject()->getEntry() ); + if( aSObj->_is_nil() ) return; + + //TEST DU PARENT == VISU + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( aSObj->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow( anAttr ); + QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() ); + if ( !Name.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + VisuGUI::myActiveStudy->renameIObject( Sel->firstIObject(), Name ); + QApplication::restoreOverrideCursor(); + + //int TypeMode; bool InViewer; + //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode); + //ActorTmp->setName((Standard_CString)Name.latin1()); + } + } +} + + +//===================================================================================== +// function : CopyPresentation() +// purpose : +//===================================================================================== +void VisuGUI::CopyPresentation(){ + if (checkLock(myStudy)) return; + VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if (!aPrsObject) return; + switch (aPrsObject->GetType()) { + case VISU::TMESH: + { + VISU::Mesh_i* aMeshPrs = dynamic_cast(aPrsObject); + VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult()); + aSameMesh->SameAs(aMeshPrs); + UpdateViewer(aSameMesh, true); + } + break; + case VISU::TSCALARMAP: + { + VISU::ScalarMap_i* aScalarPrs = dynamic_cast(aPrsObject); + VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult()); + aSameScalar->SameAs(aScalarPrs); + UpdateViewer(aSameScalar, true); + } + break; + case VISU::TDEFORMEDSHAPE: + { + VISU::DeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); + VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult()); + aSameDeformed->SameAs(aDefPrs); + UpdateViewer(aSameDeformed, true); + } + break; + case VISU::TCUTPLANES: + { + VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); + VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult()); + aSameCut->SameAs(aCutPrs); + UpdateViewer(aSameCut, true); + } + break; + case VISU::TISOSURFACE: + { + VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast(aPrsObject); + VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult()); + aSameIso->SameAs(aIsoPrs); + UpdateViewer(aSameIso, true); + } + break; + case VISU::TSTREAMLINES: + { + VISU::StreamLines_i* aLinesPrs = dynamic_cast(aPrsObject); + VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult()); + aSameLines->SameAs(aLinesPrs); + UpdateViewer(aSameLines, true); + } + break; + case VISU::TVECTORS: + { + VISU::Vectors_i* aVectorsPrs = dynamic_cast(aPrsObject); + VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult()); + aSameVectors->SameAs(aVectorsPrs); + UpdateViewer(aSameVectors, true); + } + break; + } + myActiveStudy->updateObjBrowser(); +} + +//===================================================================================== +// function : InfoOnPoint() [ slot ] +// purpose : +//===================================================================================== +void VisuGUI::InfoOnPoint() +{ + VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + return; + int TypeMode; + VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); + if ( !ActorTmp ) + return; + + if ( TypeMode == SelectionPoint ) + Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp ); + else + QAD_MessageBox::warn1( visuGUI->myDesktop, + tr ("WARNING"), + tr ("Not Point selection mode"), + tr ("VISU_BUT_OK") ); +} + +//===================================================================================== +// function : InfoOnCell() [ slot ] +// purpose : +//===================================================================================== +void VisuGUI::InfoOnCell() +{ + VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + return; + int TypeMode; + VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); + if ( !ActorTmp ) + return; + + if ( TypeMode == SelectionCell || TypeMode == SelectionEdge ) + Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp ); + else + QAD_MessageBox::warn1( visuGUI->myDesktop, + tr ("WARNING"), + tr ("Not Cell/Edge selection mode"), + tr ("VISU_BUT_OK") ); +} + +//===================================================================================== +// function : SelectPoint() [ slot ] +// purpose : +//===================================================================================== +void VisuGUI::SelectPoint() +{ + VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + return; + vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy ); + int TypeMode; + VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); + if ( !ActorTmp ) + return; + if ( TypeMode != SelectionPoint ) { + QAD_MessageBox::warn1( visuGUI->myDesktop, + tr ("WARNING"), + tr ("Not Point selection mode"), + tr ("VISU_BUT_OK") ); + return; + } + + bool ok = FALSE; + vtkDataSetMapper* Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); + Mapper->SetInput(ActorTmp->DataSource); + vtkDataSet *Data=Mapper->GetInput(); + int nbPoints=Data->GetNumberOfPoints(); + int selectedPoint = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"), + tr("Point number:" ), + 0, + &ok, + visuGUI->myDesktop ); + if ( ok && theRenderer && selectedPoint > 0 && selectedPoint <= nbPoints ) + Selection->HighlightPoint( selectedPoint, nbPoints, ActorTmp, theRenderer ); +} + +//===================================================================================== +// function : SelectCell() [ slot ] +// purpose : +//===================================================================================== +void VisuGUI::SelectCell() +{ + VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); + SALOME_Selection* Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection()); + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + return; + vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy ); + int TypeMode=Sel->SelectionMode(); + if ( TypeMode != SelectionCell && TypeMode != SelectionEdge ) { + QAD_MessageBox::warn1( visuGUI->myDesktop, + tr ("WARNING"), + tr ("Not Cell/Edge selection mode"), + tr ("VISU_BUT_OK") ); + return; + } + VISU_Actor* ActorTmp; + string aComment; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); + //srn: Added check if anObject is Null, then break +// if(CORBA::is_nil(anObject)) break; + + VISU::Prs3d_i* aPrsObject = NULL; + if(!CORBA::is_nil(anObject)) + aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if(aPrsObject){ + //aPrsObject->SetIO(anIO); + //ActorTmp = aPrsObject->GetActor(); + //UpdateViewer(ActorTmp); + ActorTmp = visuGUI->UpdateViewer(aPrsObject); + } else { + ActorTmp = ActorSelected(visuGUI->myDesktop,true,&TypeMode); + } + if (ActorTmp==NULL) + return; + + bool ok=FALSE; + vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); + Mapper->SetInput(ActorTmp->DataSource); + vtkDataSet *Data=Mapper->GetInput(); + int nbCells=Data->GetNumberOfCells(); + int selectedCell = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"), + tr("Cell number:" ), + 0, + &ok, + visuGUI->myDesktop ); + if ( ok && theRenderer && selectedCell > 0 && selectedCell <= nbCells ) + if (ok && theRenderer ) + Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); +} + +//===================================================================================== +// function : DefinePopup() +// purpose : +//===================================================================================== +void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject ) +{ + VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); + theObject = ""; + theContext = ""; +} + + +//===================================================================================== +// function : CustomPopup() +// purpose : +//===================================================================================== +bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QString & theContext, + const QString & theParent, const QString & theObject) +{ + int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900; + VisuGUI::GetOrCreateVisuGUI(parent); + QAD_ResourceMgr* rmgr = parent->createResourceManager(); + + bool isVTKViewer = (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK); + thePopup->clear(); + + SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection()); + if ( Sel->IObjectCount() == 0 ) { + if ( theParent == "Viewer" && isVTKViewer) + // Available only for VTK viewer + thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); + return false; + } + + VISU::Storable::TRestoringMap aMap; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(VisuGUI::myActiveStudy,&anIO,&aMap); + bool isExist; + string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); + if(!isExist) aComment = "NONE"; + SALOMEDS::GenericAttribute_var anAttr; + + if (!CORBA::is_nil(anObject)) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj)) { + if( Sel->IObjectCount() > 1) return false; + + VISU::VISUType aType = aVisuObj->GetType(); + MESSAGE("VisuGUI::CustomPopup - VISU object :: "<insertItem("Import From File", visuGUI, SLOT(ImportFromFile())); + break; + + case VISU::TRESULT: + //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh())); + //thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile())); + //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs())); + break; + + case VISU::TTABLE: + thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) ); + thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) ); + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); + thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); + } + break; + + case VISU::TCURVE: + if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) + thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) ); + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) ) + thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); + else + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); + thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); + } + break; + + case VISU::TCONTAINER: + if( !CORBA::is_nil( anObject ) ) { + CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject ); + if( !CORBA::is_nil( aCnt ) ) { + VISU::Container_i* container = dynamic_cast( VISU::GetServant( aCnt ) ); + if ( container && container->GetNbCurves() > 0 ) { + if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) + thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) ); + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); + thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); + } + } + } + } + break; + + default: // Presentation + { + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if (aPrsObject) { + VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject); + if (isVTKViewer) { + // Add Presentation menu + if ((aType != VISU::TSTREAMLINES) && anVISUActor) { + QPopupMenu* aPresMenu = new QPopupMenu(VisuGUI::myDesktop); + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + if (anVISUActor->IsShrinkable) { + if (anVISUActor->IsShrunk) + aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink())); + else + aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink())); + } + thePopup->insertItem("Representation", aPresMenu); + } + + // Add Properties + QPopupMenu* aPropMenu = new QPopupMenu(VisuGUI::myDesktop); + if ((aType == VISU::TMESH) || + (aType == VISU::TDEFORMEDSHAPE) || + (aType == VISU::TVECTORS) || + (aType == VISU::TSTREAMLINES)) // Mesh, deformed shape, vectors + aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor())); + if (aType == VISU::TMESH) + aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor())); + + if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES)) + aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity())); + aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines())); + thePopup->insertItem("Properties", aPropMenu); + + thePopup->insertSeparator(); + } + thePopup->insertItem("Rename...", visuGUI, SLOT(Rename())); + if (aType != VISU::TMESH) { + if (aType != VISU::TSCALARMAP) + thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs())); + thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar())); + + if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) && isVTKViewer) + thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep())); + } + if (isVTKViewer) { + if ( theParent == "Viewer" && + ( aType == VISU::TMESH || + aType == VISU::TSCALARMAP || + aType == VISU::TDEFORMEDSHAPE ) ) { + thePopup->insertSeparator(); + if ( Sel->SelectionMode() == SelectionPoint ) { + thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint())); + thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint())); + } + else if ( Sel->SelectionMode() == SelectionCell || Sel->SelectionMode() == SelectionEdge ) { + thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell())); + thePopup->insertItem("Select a Cell", visuGUI, SLOT(SelectCell())); + } + } + thePopup->insertSeparator(); + if (visuGUI->IsDisplayed(aPrsObject) ) + thePopup->insertItem("Hide", visuGUI, SLOT(ErasePrs())); + else + thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs())); + + thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs())); + } + if (aType != VISU::TMESH) + thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs())); + thePopup->insertSeparator(); + thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation())); + } + } + } + return false; + } + else { + // possibly this is the MED field/mesh and suppot objects + SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject ); + if( !CORBA::is_nil( aMED ) ) { + thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) ); + return false; + } + /*CORBA::Object_var anObj = SALOME_MED::FIELD::_narrow( anObject ); + if( !CORBA::is_nil( anObj ) ) { + thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) ); + return false; + } + anObj = SALOME_MED::MESH::_narrow( anObject ); + if( !CORBA::is_nil( anObj ) ) { + thePopup->insertItem( "Import Mesh", visuGUI, SLOT( ImportMedField() ) ); + return false; + } + anObj = SALOME_MED::GROUP::_narrow( anObject ); + if( !CORBA::is_nil( anObj ) ) { + thePopup->insertItem( "Import Group", visuGUI, SLOT( ImportMedField() ) ); + return false; + } + anObj = SALOME_MED::FAMILY::_narrow( anObject ); + if( !CORBA::is_nil( anObj ) ) { + thePopup->insertItem( "Import Family", visuGUI, SLOT( ImportMedField() ) ); + return false; + } + anObj = SALOME_MED::SUPPORT::_narrow( anObject ); + if( !CORBA::is_nil( anObj ) ) { + thePopup->insertItem( "Import Support", visuGUI, SLOT( ImportMedField() ) ); + return false; + }*/ + } + } + int aType = ObjectTypes.find( aComment.c_str() ); + if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - aComment = "<FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { + thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) ); + thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) ); + } + return false; + } + if(aComment == "ENTITY" || aComment == "FAMILY" || aComment == "GROUP") + thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); + switch (aType) { + case 0: // Field + if (getValue(obj, "myNbTimeStamps").toLong() > 1) + thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) ); + break; + + case 6: // VIEW3D node + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // Available only for VTK viewer + thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); + thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) ); + } + thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) ); + thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams())); + break; + + //case 13: // Mesh node + //thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); + //break; + + case 18: { // Timestamp +// if( isStudyLocked(VisuGUI::myActiveStudy->getStudyDocument())) +// return false; + int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt(); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_SCALAR_MAP") ), + "Scalar Map...", visuGUI, SLOT(CreateScalarMap())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ), + "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ), + "Cut Planes...", visuGUI, SLOT(CreateCutPlanes())); + if(aNunComponent > 1){ + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ), + "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ), + "Vectors...", visuGUI, SLOT(CreateVectors())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ), + "Stream lines...", visuGUI, SLOT(CreateStreamLines())); + } + } + } + return false; +} + +//=========================================================================== +// BuildPresentation +//=========================================================================== +void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) +{ + BEGIN_OF("VisuGUI::BuildPresentation"); + + if (theIO.IsNull()) { + MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed"); + return; + } + + /* Create or retrieve an object VisuGUI */ + + VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); + + SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + + if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; + + vtkRenderer *Renderer = GetRenderer(visuGUI->myActiveStudy); + + SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() ); + SCRUTE(aSObj); + if (aSObj -> _is_nil() ) { + MESSAGE("No SObject for interacative object is found"); + return; + } + + CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); + if(!CORBA::is_nil(anObject)) { + + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); + if ( !aPrsObject ) { + MESSAGE("The object is not VISU::Prs3d_i"); + return; + } + VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject); + if ( ! SelectedActor ) + SelectedActor = aPrsObject -> CreateActor(); + SCRUTE(SelectedActor); + if ( SelectedActor == NULL ) { + MESSAGE("VisuGUI::BuildPresentation(): actor doesn't exist in Render"); + return; + } + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + vf->AddActor(SelectedActor); + if(SelectedActor->HasScalarBar()){ + Renderer->AddActor2D(SelectedActor->getScalarBar()); + } + } + else { + MESSAGE("CORBA::is_nil(anObject) = true"); + } + END_OF("VisuGUI::BuildPresentation"); + +} + +extern "C" +{ + + bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) + { + //MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID); + return VisuGUI::OnGUIEvent(theCommandID, parent); + } + + bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + MESSAGE("VisuGUI::OnKeyPress "); + return VisuGUI::OnKeyPress (pe, parent, studyFrame); + } + + bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + //MESSAGE("VisuGUI::OnMousePress "); + return VisuGUI::OnMousePress (pe, parent, studyFrame); + } + + bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) + { + //MESSAGE("VisuGUI::OnMouseMove "); + return VisuGUI::OnMouseMove (pe, parent, studyFrame); + } + + bool SetSettings ( QAD_Desktop* parent ) + { + return VisuGUI::setSettings( parent ); + } + + bool customPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, + const QString & theParent, const QString & theObject ) + { + return VisuGUI::CustomPopup( parent, popup, theContext, theParent, theObject ); + } + + void definePopup ( QString & theContext, QString & theParent, QString & theObject ) + { + VisuGUI::DefinePopup( theContext, theParent, theObject ); + } + + bool activeStudyChanged ( QAD_Desktop* parent ) + { + //VisuGUI::activeStudyChanged( parent ); + } + void buildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ) + { + VisuGUI::BuildPresentation(theIO); + } + +} + +// ==================================================================================================================== +// =================================================================================================================== + +bool VisuGUI::getObjectRef( QAD_Desktop* parent, SALOMEDS::SObject_ptr obj, + _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres, + const char* Type) { + + VisuGUI::GetOrCreateVisuGUI(parent); + SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(obj); + SALOMEDS::SObject_var RefObj; + + for (; it->More();it->Next()) { + SALOMEDS::SObject_var Fils = it->Value(); + + if ( Fils->ReferencedObject( RefObj ) ) { + SALOMEDS::SComponent_var theComponent = RefObj->GetFatherComponent(); + Standard_CString nameComponent = theComponent->ComponentDataType(); + + if ( TCollection_AsciiString(nameComponent).IsEqual(strdup(Type)) ) { + objres = SALOMEDS::SObject::_narrow(RefObj); + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////////////// +//////////////// CHANGE ACTOR COLOR //////////////////////// +////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// +// change actor color +// In : Name of Actor +// +// + +void VisuGUI::NewColor(VISU_Actor *Actor) +{ + float oldcolor[3],newcolor[3]; + Actor->GetProperty()->GetColor(oldcolor); + QColor colorold; + colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255); + QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() ); + + if (!colornew.isValid()) return; + + newcolor[0]=colornew.red()/255.; + newcolor[1]=colornew.green()/255.; + newcolor[2]=colornew.blue()/255.; + Actor->GetProperty()->SetColor(newcolor); + if (Actor->getPrs3d()) + Actor->getPrs3d()->SetColor(newcolor); +} + +void VisuGUI::NewOutlineColor(VISU_Actor *Actor) +{ + float oldcolor[3],newcolor[3]; + Actor->EdgeDevice->GetProperty()->GetColor(oldcolor); + QColor colorold; + colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255); + QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() ); + + if (!colornew.isValid()) return; + + SALOMEDS::Color aColor; + aColor.R = newcolor[0]=colornew.red()/255.; + aColor.G = newcolor[1]=colornew.green()/255.; + aColor.B = newcolor[2]=colornew.blue()/255.; + Actor->EdgeDevice->GetProperty()->SetColor(newcolor); + if (Actor->getPrs3d()) + dynamic_cast(Actor->getPrs3d())->SetLinkColor(aColor); +} + +////////////////////////////////////////////////////////////////////////////////// +//////////////// CHANGE ACTOR OPACITY //////////////////////// +////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// +// change actor opacity +// In : Name of Actor +// +// Use CursorDlg to select a value between 0 and 100 +// + +void VisuGUI::NewOpacity(VISU_Actor *Actor) +{ + + VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Opacity"), TRUE ); + + float oldopac,newopac; + int intopac; + CursorDlg->Comment1->setText( tr( "Set value between") ); + CursorDlg->Comment2->setText( tr( "0 (transparent) and 100 (opaque)" ) ); + oldopac=Actor->GetProperty()->GetOpacity(); + intopac=int(oldopac*100.); + CursorDlg->SpinBox1->setMinValue(0); + CursorDlg->SpinBox1->setMaxValue(100); + CursorDlg->SpinBox1->setValue(intopac); + + int ret = CursorDlg->exec(); + if (ret == 1) + { + intopac = CursorDlg->SpinBox1->value() ; + newopac = intopac/100.; + Actor->GetProperty()->SetOpacity(newopac); + } + delete CursorDlg; +} + +////////////////////////////////////////////////////////////////////////////////// +//////////////// CHANGE ACTOR LINEWIDTH //////////////////////// +////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////// +// change actor linewidth +// In : Name of Actor +// +// Use CursorDlg to select a value between 0 and 10 +// + +void VisuGUI::NewLinewidth(VISU_Actor *Actor) +{ + + VisuGUI_CursorDlg* CursorDlg = new VisuGUI_CursorDlg(QAD_Application::getDesktop(), tr("Line Width"), TRUE ); + + float oldlwid,newlwid; + int intlwid; + CursorDlg->Comment1->setText("Set value between"); + CursorDlg->Comment2->setText("1 (thin) and 10 (thick)"); + oldlwid=Actor->GetProperty()->GetLineWidth(); + intlwid=int(oldlwid); + CursorDlg->SpinBox1->setMinValue(1); + CursorDlg->SpinBox1->setMaxValue(10); + CursorDlg->SpinBox1->setValue(intlwid); + + int ret = CursorDlg->exec(); + if (ret == 1) { + intlwid = CursorDlg->SpinBox1->value() ; + newlwid = intlwid; + Actor->GetProperty()->SetLineWidth(newlwid); + } + delete CursorDlg; +} + +/* ======================================================================================== */ +/* Setting parameters for Scalar Bar */ +/* ======================================================================================== */ +void VisuGUI::ChangeScalarBar() +{ + VisuGUI_ScalarBarDlg* Scbar = new VisuGUI_ScalarBarDlg(TRUE); + Scbar->initFromResources(); + int ret = Scbar->exec(); + if ( ret ) { + Scbar->storeToResources(); + } + delete Scbar; +} + +/* ======================================================================================== */ +/* Setting parameters for Sweeping */ +/* ======================================================================================== */ +void VisuGUI::SetSweepingPreferences() +{ + float tempo=0.2; + int cycles=1; + int steps=20; + + QString Tempo = QAD_CONFIG->getSetting("Visu:SweepTempo"); + if ( !Tempo.isEmpty() ) + tempo = Tempo.toFloat(); + + QString Cycles = QAD_CONFIG->getSetting("Visu:SweepCycles"); + if ( !Cycles.isEmpty() ) + cycles = Cycles.toInt(); + + QString Steps = QAD_CONFIG->getSetting("Visu:SweepSteps"); + if ( !Steps.isEmpty() ) + steps = Steps.toInt(); + + VisuGUI_SweepPrefDlg* Sweep = new VisuGUI_SweepPrefDlg(QAD_Application::getDesktop(), 0, TRUE, 0); + + Sweep->setTimeStep( tempo ); + Sweep->setNbCycles( cycles ); + Sweep->setNbSteps ( steps ); + + if ( Sweep->exec() ) + { + tempo = Sweep->getTimeStep(); + cycles = Sweep->getNbCycles(); + steps = Sweep->getNbSteps(); + + QAD_CONFIG->addSetting("Visu:SweepTempo", tempo); + QAD_CONFIG->addSetting("Visu:SweepCycles", cycles); + QAD_CONFIG->addSetting("Visu:SweepSteps", steps); + } + delete Sweep; +} + +/* ======================================================================================== */ +/* Returns Visu input files directory (default is CSF_PATHData) */ +/* ======================================================================================== */ +QString VisuGUI::getVisuInputDir() +{ + QString Tmp = QAD_CONFIG->getSetting("Visu:InputDir"); + if ( Tmp.isEmpty() ) + Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData")); + Tmp = QAD_Tools::addSlash(Tmp); + return (Tmp); +} + +/* ======================================================================================== */ +/* Returns Visu output files directory (default is InputDir) */ +/* ======================================================================================== */ +QString VisuGUI::getVisuOutputDir() +{ + QString Tmp = QAD_CONFIG->getSetting("Visu:OutputDir"); + if ( Tmp.isEmpty() ) + { + QString Tmp2 = QAD_CONFIG->getSetting("Visu:InputDir"); + if ( Tmp2.isEmpty() ) + Tmp = QAD_Tools::addSlash(getenv("CSF_PATHData")); + else + Tmp = Tmp2; + } + Tmp = QAD_Tools::addSlash(Tmp); + return (Tmp); +} + + +/* ======================================================================================== */ +/* Global Method for Scalar Map */ +/* ======================================================================================== */ +VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){ + if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent"); + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + SALOMEDS::SObject_var aSObj = theField->GetFather(); + aSObj = aSObj->GetFather(); + aSObj = aSObj->GetFather(); + aSObj = aSObj->GetFather(); + CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); + if(CORBA::is_nil(anObject)) return NULL; + theResult = VISU::Result::_narrow(anObject); + VISU::Result_i* pResult = dynamic_cast(VISU::GetServant(anObject)); + if(pResult == NULL) + QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("No Available data in selection"), + tr ("VISU_BUT_OK")); + return pResult; +} + +#define CREATEPRS(PRSTYPE, FNAME, FCREATE) \ +PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \ + const char* theMeshName, VISU::Entity theEntity, \ + const char* theFieldName, double theTimeId) {\ + VISU::Result_var aResult; \ + VISU::Result_i* pResult = CreatePresent(theField,aResult); \ + if(pResult){ \ + if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \ + QApplication::setOverrideCursor( Qt::waitCursor ); \ + VISU::VISU_Gen_var aVisuGen = VISU::Base_i::GetVisuGenInter(); \ + CORBA::Object_var anObject = \ + aVisuGen->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \ + QApplication::restoreOverrideCursor(); \ + if(CORBA::is_nil(anObject)) return NULL; \ + return dynamic_cast(VISU::GetServant(anObject)); \ + } \ + } else { \ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \ + tr ("The presentation can't be built."), \ + tr ("VISU_BUT_OK") ); \ + } \ + return NULL; \ +} + +CREATEPRS(VISU::ScalarMap_i, VisuGUI::CreateScalarMapPrs, ScalarMapOnField); +CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeOnField); +CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField); +CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField); +CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField); +CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField); + + +#define BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) \ +bool FNAME(SALOMEDS::SObject_var theField) { \ + VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \ + bool isExist; \ + QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \ + if(!isExist && aType.toInt() != VISU::TTIMESTAMP) return false; \ + QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \ + QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \ + QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \ + QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \ + TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toDouble()); \ + if (pPresent) { \ + DLGNAME* aDlg = new DLGNAME(); \ + aDlg->initFromPrsObject(pPresent); \ + if (aDlg->exec()) { \ + aDlg->storeToPrsObject(pPresent); \ + } else { \ + DeletePresentation(pPresent); \ + delete aDlg; \ + return false; \ + } \ + delete aDlg; \ + CreateActor(pPresent); \ + return true; \ + } \ + return false; \ +} + +BUILDPRS(VISU::ScalarMap_i, CreateScalarMapPrs, VisuGUI::CreateScalarMap, VisuGUI_ScalarBarDlg); +BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedShape, VisuGUI_MagnitudeDlg); +BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg); +BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg); +BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg); +BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg); + + + +/* ======================================================================================== */ +/* Global Method to import tables from file */ +/* ======================================================================================== */ +void VisuGUI::ImportTablesFromFile(){ + QStringList flt; + flt.append( "Files (*.xls *.txt *.tab)" ); + flt.append( "All Files (*.*)" ); + QString aDir = getVisuInputDir(); + QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + aDir,flt,tr("Import From File"),true); + if(!aFile.isEmpty()){ + QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." ); + aDir = QAD_Tools::getDirFromPath(aFile); + QAD_CONFIG->addSetting("Visu:InputDir",aDir); + QApplication::setOverrideCursor( Qt::waitCursor ); + QAD_PyInterp* myPyInterp = myActiveStudy->get_PyInterp(); + myPyInterp->run("import VisuGUI"); + myPyInterp->run("reload(VisuGUI)"); + myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')"); + // VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1()); + // if(aResult->_is_nil()) + // QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + // tr ("There is an error in imported file"), + // tr ("VISU_BUT_OK") ); + // else + // QAD_Application::getDesktop()->putInfo(aFile+" imported."); + myActiveStudy->updateObjBrowser(); //update Object browser + QApplication::restoreOverrideCursor(); + } +} + +/* ======================================================================================== */ +/* Global Method to import mesh results in MED and DAT format */ +/* ======================================================================================== */ +void VisuGUI::ImportFromFile(){ + if (checkLock(myActiveStudy->getStudyDocument())) return; + QStringList flt; + //flt.append( "Exportable Files (*.med *.dat)" ); + //flt.append( "Dat Files (*.dat)" ); + flt.append( "Med Files (*.med)" ); + flt.append( "Dat Files (*.xls)" ); + QString aDir = getVisuInputDir(); + QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + aDir,flt,tr("Import From File"),true); + if(aFileInfo.exists()){ + QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); + aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath()); + QAD_CONFIG->addSetting("Visu:InputDir",aDir); + QApplication::setOverrideCursor( Qt::waitCursor ); + + CORBA::Object_var anObject; + if(aFileInfo.extension(false) == "med") + anObject = myComponent->ImportFile(aFileInfo.filePath()); + else if(aFileInfo.extension(false) == "xls") + anObject = myComponent->ImportTables(aFileInfo.filePath()); + + if(CORBA::is_nil(anObject)) + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("There is an error in imported file"), + tr ("VISU_BUT_OK") ); + else + QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported."); + + myActiveStudy->updateObjBrowser(); //update Object browser + QApplication::restoreOverrideCursor(); + } +} + +void VisuGUI::ExportToFile(){ + VISU::Base_i* aBase = GetSelectedVisuObj(); + if(aBase != NULL && aBase->GetType() == VISU::TRESULT){ + QStringList flt; + flt.append( "Dat Files (*.dat)" ); + flt.append( "Med Files (*.med)" ); + QString aDir = getVisuOutputDir(); + QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + aDir,flt,tr("Export To File"),false); + if(!aFile.isEmpty()){ + QAD_Application::getDesktop()->putInfo( "Exporting To File " + aFile + "..." ); + aDir = QAD_Tools::getDirFromPath(aFile); + QAD_CONFIG->addSetting("Visu:OutputDir",aDir); + if(VISU::Result_i* aResult = dynamic_cast(aBase)){ + try{ + //APO - aResult->GetInput()->ToFile(aFile.latin1()); + QAD_Application::getDesktop()->putInfo(aFile+" exported."); + }catch(...){ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("There is an error during exporting to file"), + tr ("VISU_BUT_OK") ); + } + } + } + }else + QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("No Available data in selection"), + tr ("VISU_BUT_OK")); +} + + +/* ======================================================================================== */ +/* Find an Actor to be the reference for a new visualization */ +/* ======================================================================================== */ +VISU_Actor *VisuGUI::ReferenceActor(QAD_Desktop* parent) +{ + bool exiDS = false, exiVE = false, exiSM = false, exiIS = false, exiCP = false; + int nbSf = visuGUI->myActiveStudy->getStudyFramesCount(); + int nbObj = 0; + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) { + vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* ac = aRenderer->GetActors(); + vtkActor *anActor; + for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) { + if ( anActor->IsA( "VISU_Actor" ) ) { + VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor); + if (VisuGUI_VisuAsDlg::ActorTypeIsValid(VISUActor,-1)) { + // VisuAs->ListObjects->insertItem(VISUActor->getName()); + nbObj++; + int test = VISUActor->VisuActorType; + if(test == VisuActorType_DeformedShape) + exiDS=true; + else if(test == VisuActorType_Vectors) + exiVE=true; + else if(test == VisuActorType_ScalarMap) + exiSM=true; + else if(test == VisuActorType_IsoSurfaces) + exiIS=true; + else if(test == VisuActorType_CutPlanes) + exiCP=true; + } + } + } + } + } + + if ( nbObj > 0 ) { + VisuGUI_VisuAsDlg * VisuAs = new VisuGUI_VisuAsDlg(QAD_Application::getDesktop(), 0, true, 0 ); + + if(exiDS) + VisuAs->addType( tr( "Deformed Shape" ) ); + if(exiVE) + VisuAs->addType( tr( "Vectors" ) ); + if(exiSM) + VisuAs->addType( tr( "Scalar Map" ) ); + if(exiIS) + VisuAs->addType( tr( "Iso-Surfaces" ) ); + if(exiCP) + VisuAs->addType( tr( "Cut Planes" ) ); + + if ( VisuAs->exec() ) { + QString nameActor = VisuAs->getObject(); + if ( !nameActor.isNull() ) { + MESSAGE("Actor --> "<myActiveStudy->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) { + vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* ac = aRenderer->GetActors(); + vtkActor *anActor; + for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) { + if ( anActor->IsA( "VISU_Actor" ) ) { + VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor); + if (strcmp(VISUActor->getName(),nameActor) == 0) + return VISUActor; + } + } + } + } + } + } + } + return NULL; +} + +/* ======================================================================================== */ +/* Test and Read Object Browser before display */ +/* ======================================================================================== */ +bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var *objVisu ){ + if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser"); + SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + if(It.More()){ + Handle(SALOME_InteractiveObject) IObject = It.Value(); + SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active + if (IObject->hasEntry()){ + *objVisu = aStudy->FindObjectID(IObject->getEntry()); + if(!(*objVisu)->_is_nil()) return true; + } + } + QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr("No Available data in selection"), + tr("VISU_BUT_OK") ); + return false; +} + +/* ======================================================================================== */ +/* Print the render window */ +/* ======================================================================================== */ +void VisuGUI::PrintRW( QString prFile, bool toPrinter) +{ + ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->Repaint(); + + vtkRenderWindow *renwin = vtkRenderWindow::New(); + vtkRenderWindowInteractor *theInteractor = vtkRenderWindowInteractor::New(); + theInteractor = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); + //visuGUI->myActiveStudy->getActiveStudyFrame()->getVTKRWInteractor(); + + renwin=theInteractor->GetRenderWindow(); + vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New(); + vtkTIFFWriter *rttiffw = vtkTIFFWriter::New(); + w2if->SetInput(renwin); + rttiffw->SetInput(w2if->GetOutput()); + rttiffw->SetFileName(prFile); + rttiffw->Write(); + + if (toPrinter) // print the file + { + QString printer = QAD_CONFIG->getSetting("Visu:Printer"); + if (printer.isEmpty()) + printer="kprinter"; + system(printer + " " + prFile); + } +} + +/** + * Returns Actor of presentation if it exists + */ +VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs){ + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (!vf) return NULL; + + vtkRenderer *aRen = vf->getRenderer(); + vtkActorCollection *anActColl = aRen->GetActors(); + vtkActor *anActor; + VISU_Actor* anVISUActor = NULL; + VISU_Actor* aResActor = NULL; + long aSrcAddr = (long) thePrs; + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + if(anActor->IsA("VISU_Actor")){ + anVISUActor = VISU_Actor::SafeDownCast(anActor); + long aCurrAddr = (long) anVISUActor->getPrs3d(); + if (aSrcAddr == aCurrAddr) { + return anVISUActor; + } + } + } + return NULL; +} + +/** + * Displays only actor of given presentation + * Creates it if it is abcent + */ +VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){ + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (!vf) return NULL; + + vtkRenderer *aRen = vf->getRenderer(); + vtkActorCollection *anActColl = aRen->GetActors(); + + vtkActor *anActor; + VISU_Actor* anVISUActor = NULL; + VISU_Actor* aResActor = NULL; + long aSrcAddr = (long) thePrs; + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + if(anActor->IsA("VISU_Actor")){ + anVISUActor = VISU_Actor::SafeDownCast(anActor); + long aCurrAddr = (long) anVISUActor->getPrs3d(); + if (aSrcAddr == aCurrAddr) { + aResActor = anVISUActor; + aResActor->VisibilityOn(); + if ( aResActor->VisuActorType == VisuActorType_Mesh ) { + if ( aResActor->GetProperty()->GetRepresentation() == 2 && !aResActor->IsShrunk ) + aResActor->EdgeDevice->VisibilityOn(); + else + aResActor->EdgeDevice->VisibilityOff(); + } + if (aResActor->HasScalarBar()) + aResActor->getScalarBar()->VisibilityOn(); + } else if (theDispOnly) { + anVISUActor->VisibilityOff(); + if ( anVISUActor->VisuActorType == VisuActorType_Mesh) { + anVISUActor->EdgeDevice->VisibilityOff(); + } + if (anVISUActor->HasScalarBar()) + anVISUActor->getScalarBar()->VisibilityOff(); + } + } + } + if (aResActor) return aResActor; +#ifdef CHECKTIME + OSD_Timer timer; + timer.Start(); +#endif + anVISUActor = thePrs->CreateActor(); + MESSAGE("UpdateViewer - thePrs->CreateActor() = "<AddActor(anVISUActor); + if(anVISUActor->HasScalarBar()){ + aRen->AddActor2D(anVISUActor->getScalarBar()); + } + } else + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("Can't visulize current object"), + tr ("VISU_BUT_OK") ); +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("Cheking time in VisuGUI::UpdateViewer - thePrs->CreateActor + vf->AddActor + aRen->AddActor2D"); + timer.Show(); +#endif + return anVISUActor; +} + + +/** + * Returns TRUE if Presentation is displayed + */ +bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) { + VISU_Actor* anVISUActor = GetActor(thePrs); + return (anVISUActor)? anVISUActor->GetVisibility() : false; +} + +/** + * Erases Presentation + */ +void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) { + myActiveStudy->unHighlightAll(); + VISU_Actor* anVISUActor = GetActor(thePrs); + if (anVISUActor) { + anVISUActor->VisibilityOff(); + if ( anVISUActor->VisuActorType == VisuActorType_Mesh ) + anVISUActor->EdgeDevice->VisibilityOff(); + if (anVISUActor->HasScalarBar()) + anVISUActor->getScalarBar()->VisibilityOff(); + } +} + +/** + * Deletes given presentation from Data structure + */ +void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) { + if (checkLock(myStudy)) return; + if (!thePrs) return; + + myActiveStudy->unHighlightAll(); + + vtkActor *anActor; + VISU_Actor* aVISUActor = NULL; + long aSrcAddr = (long) thePrs; + int nbFrames = myActiveStudy->getStudyFramesCount(); + QAD_StudyFrame* aFrame; + + for(int i=0; igetStudyFrame(i); + if(!aFrame || aFrame->getTypeView() != VIEW_VTK) continue; + vtkRenderer* aRen = ((VTKViewer_ViewFrame*)aFrame->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection *anActColl = aRen->GetActors(); + + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + if(anActor->IsA("VISU_Actor")) { + aVISUActor = VISU_Actor::SafeDownCast(anActor); + if (aSrcAddr == ((long) aVISUActor->getPrs3d())) { + if (aVISUActor->HasScalarBar()) + aRen->RemoveActor(aVISUActor->getScalarBar()); + aRen->RemoveActor(aVISUActor); + aVISUActor->EdgeDevice->Delete(); + aVISUActor->Delete(); + aVISUActor = NULL; + } + } + } + } + SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(thePrs->GetEntry()); + if(aSObj->_is_nil()) return; + myStudyBuilder->RemoveObject(aSObj); + myActiveStudy->updateObjBrowser(); //update Object browser +} + +/** + * Creates new actor of presentation + */ +void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) { + if (!thePrs) return; + QApplication::setOverrideCursor( Qt::waitCursor ); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { +#ifdef CHECKTIME + OSD_Timer timer; + timer.Start(); +#endif + VISU_Actor* aActor = thePrs->CreateActor(); + if ( ! aActor ) { + QApplication::restoreOverrideCursor(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("The presentation can't be visualized.\n Null actor is created."), + tr ("VISU_BUT_OK") ); + return; + } +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("Cheking time in VisuGUI::CreateActor - thePrs->CreateActor"); + timer.Show(); +#endif + vtkRenderer *aRenderer = vf->getRenderer(); + //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1); + //visuGUI->ShowTrihedron(true); +#ifdef CHECKTIME + timer.Reset(); + timer.Start(); +#endif + vf->AddActor(aActor); + if (aActor->HasScalarBar()) + aRenderer->AddActor2D(aActor->getScalarBar()); +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("Cheking time in VisuGUI::CreateActor - vf->AddActor"); + timer.Show(); +#endif + } + QApplication::restoreOverrideCursor(); +} + + + +/* ======================================================================================== */ +/* Functions to State of VisuGUI and Dialog Box */ +/* ======================================================================================== */ + +void VisuGUI::SetState(int aState ) +{ + this->myState = aState ; + return ; +} + + +void VisuGUI::ResetState() +{ + this->myState = -1 ; + return ; +} + +void VisuGUI::EmitSignalDeactivateDialog() +{ + emit this->SignalDeactivateActiveDialog() ; + return ; +} + +void VisuGUI::EmitSignalCloseAllDialogs() +{ + emit this->SignalCloseAllDialogs() ; + return ; +} + +QDialog* VisuGUI::GetActiveDialogBox() +{ + return this->myActiveDialogBox ; +} + +void VisuGUI::SetActiveDialogBox(QDialog* aDlg) +{ + this->myActiveDialogBox = (QDialog*)aDlg ; + return ; +} + +QAD_Study* VisuGUI::GetActiveStudy() +{ + return this->myActiveStudy ; +} + +QAD_Desktop* VisuGUI::GetDesktop() +{ + return this->myDesktop ; +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h new file mode 100644 index 00000000..8af43519 --- /dev/null +++ b/src/VISUGUI/VisuGUI.h @@ -0,0 +1,278 @@ +// File : VisuGUI.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VisuGUI_HeaderFile +#define VisuGUI_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif + +#include +#include CORBA_SERVER_HEADER(VISU_Gen) +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +#include "QAD_Desktop.h" +#include "VISU_Actor.h" +#include "VISU_PrsObject_i.hh" +#include "VISU_Table_i.hh" +#include "VISU_ViewManager_i.hh" + +#include +#include +#include "SALOME_ListIteratorOfListIO.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static QString filters[] = { "DAT Files (*.dat)", + "Pressures Files (*.pre)", + "Displacements Files (*.dis)", + "Scalars Files (*.sca)", + "Vectors Files (*.vec)", + "Data Files (*.dat )", + "Vtk Files (*.vtk )", + "Med Files (*.med)", + "Results Files (*.res )", + "Print Files (*.tif)", + "Plot Files (*.plt)", + "Test Files (*.tst)" }; + +typedef enum {SOLVER,DAT_FILE,VTK_FILE,RES_FILE,MED_FILE,SMESH_FILE,VISU_FILE,SCALAR_FILE,ERROR} result ; + +enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK }; + + + +// ====================================================================== +// CLASS VIUSGUI +// ====================================================================== +// +class VisuGUI : public QObject +{ + Q_OBJECT + +public : +VisuGUI(); +~VisuGUI(); + +// Methods PUBLIC for Visualization +// + static SALOMEDS::Study_var GetCurrentStudy() { return myStudy; } + static QAD_Study* GetGUICurrentStudy() { return myActiveStudy; } + static VTKViewer_ViewFrame* GetVtkViewFrame(); + static SALOMEDS::StudyBuilder_var GetStudyBuilder() { return myStudyBuilder;} + static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); + + static vtkRenderer* GetRenderer(QAD_Study* theStudy); + + +static VisuGUI* GetOrCreateVisuGUI( QAD_Desktop* desktop ); +static VisuGUI* GetVisuGUI() ; +static VISU::Result_i* CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult); + +bool CreateScalarMap(SALOMEDS::SObject_var theField); +static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); +bool CreateDeformedShape(SALOMEDS::SObject_var theField); +static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); +bool CreateVectors(SALOMEDS::SObject_var theField); +static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); +bool CreateIsoSurfaces(SALOMEDS::SObject_var theField); +static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); +bool CreateCutPlanes(SALOMEDS::SObject_var theField); +static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); +bool CreateStreamLines(SALOMEDS::SObject_var theField); +static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); +bool TestObjectBrowser(SALOMEDS::SObject_var *objVisu); + +static void ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor); +static void ShowTrihedron(bool Show); +static void ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type); + +static void NewColor(VISU_Actor *Actor); +static void NewOutlineColor(VISU_Actor *Actor); +static void NewOpacity(VISU_Actor *Actor); +static void NewLinewidth(VISU_Actor *Actor); + +static void ChangeScalarBar(); +static void SetSweepingPreferences(); +static VISU_Actor *ReferenceActor(QAD_Desktop* parent); + +static void PlotTable( VISU::Table_i* table, int theDisplaying ); +static void PlotCurve( VISU::Curve_i* curve, int theDisplaying ); +static void PlotContainer( VISU::Container_i* container, int theDisplaying ); + +void PrintRW(QString prFile, bool toPrinter); + +static QString getVisuInputDir(); +static QString getVisuOutputDir(); + +static VISU_Actor *ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode); +static VISU_Actor *GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren); +static VISU_Actor *GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren); + + static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey); + + +VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false); +bool IsDisplayed(VISU::Prs3d_i* thePrs); +void ErasePrs(VISU::Prs3d_i* thePrs); + +VISU_Actor* GetActor(VISU::Prs3d_i* thePrs); +static VISU::Prs3d_i* GetSelectedPrs(); +void RecreateActor(VISU::Prs3d_i* thePrs); +static void CreateActor(VISU::Prs3d_i* thePrs); + +void VisuGUI::ChangeRepresentation(RepresentType theType); +void DeletePresentation(VISU::Prs3d_i* thePrs); + + +void SetState(int aState ); +void ResetState(); +void EmitSignalDeactivateDialog(); +void EmitSignalCloseAllDialogs(); +QDialog* GetActiveDialogBox(); +void SetActiveDialogBox(QDialog* aDlg); +QAD_Study* GetActiveStudy(); +QAD_Desktop* GetDesktop(); + +// ---------------------------------------- +// All method of standard EXPORT +// ---------------------------------------- +// +Standard_EXPORT static bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); + +Standard_EXPORT static bool setSettings (QAD_Desktop* parent); + +Standard_EXPORT static void DefinePopup(QString & theContext, + QString & theParent, + QString & theObject ) ; + +Standard_EXPORT static bool CustomPopup (QAD_Desktop* parent, + QPopupMenu* popup, + const QString & theContext, + const QString & theParent, + const QString & theObject); + +Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + +Standard_EXPORT static bool OnMousePress (QMouseEvent* pe , + QAD_Desktop* parent, + QAD_StudyFrame* studyFrame); + +Standard_EXPORT static bool OnMouseMove (QMouseEvent* pe , + QAD_Desktop* parent, + QAD_StudyFrame* studyFrame); + +Standard_EXPORT static bool OnKeyPress (QKeyEvent* pe, + QAD_Desktop* parent, + QAD_StudyFrame* studyFrame); + +Standard_EXPORT static bool APIreaderVTK (QString FileMesh, QString FileResultat); + +Standard_EXPORT static bool getObjectRef(QAD_Desktop* parent, SALOMEDS::SObject_ptr obj, + _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres, + const char* Type); + +public slots: + void ImportTablesFromFile(); + void ImportFromFile(); + void ExportToFile(); + void CreateMesh(); + void CreateScalarMap(); + void CreateDeformedShape(); + void CreateVectors(); + void CreateIsoSurfaces(); + void CreateCutPlanes(); + void CreateStreamLines(); + + void DisplayPrs(); + void DisplayOnlyPrs(); + void ErasePrs(); + void EditPrs(); + void EditScalarBar(); + + void MakeWireframe(); + void MakeSurface(); + void MakePoints(); + void MakeShrink(); + + void ChageColor(); + void ChangeOutlineColor(); + void ChangeOpacity(); + void ChangeLines(); + + void ShowTable(); + void PlotData(); + void CurveProperties(); + void ClearContainer(); + + void SaveViewParams(); + void RestoreViewParams(); + + void DeletePrs(); + void Rename(); + void Sweep(); + void TimeAnimation(); + + void ImportMedField(); + //void ImportMedMesh(); + + void DeleteViewParams(); + void CopyPresentation(); + + void InfoOnPoint(); + void InfoOnCell(); + void SelectPoint(); + void SelectCell(); + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + +private : + static VISU::VISU_Gen_var myComponent; + static SALOMEDS::Study_var myStudy; + static SALOMEDS::StudyBuilder_var myStudyBuilder; + static QAD_Desktop* myDesktop; + static QAD_Study* myActiveStudy; + QDialog* myActiveDialogBox; + int myState ; + int myStudyId; + +signals: + void SignalDeactivateActiveDialog(); + void SignalCloseAllDialogs(); +}; + +#endif diff --git a/src/VISUGUI/VisuGUI.py b/src/VISUGUI/VisuGUI.py new file mode 100644 index 00000000..83c96fb4 --- /dev/null +++ b/src/VISUGUI/VisuGUI.py @@ -0,0 +1,157 @@ +class Row: + def __init__(self): + self.title = "" + self.unit = "" + self.values = [] + return + pass + +class Table2D: + def __init__(self): + self.title = "" + self.columnTitles = [] + self.columnUnits = [] + self.rows = [] + return + def getColumns(self): + nb = len(self.rows[0].values) + cols = [] + for i in range(nb): + col = Row() + for r in self.rows: + col.values.append(r.values[i]) + pass + print self.columnTitles + if len(self.columnTitles)>i: + col.title = self.columnTitles[i] + print col.title + pass + if len(self.columnUnits)>i: + col.unit = self.columnUnits[i] + pass + cols.append(col) + pass + return cols + pass + +def AddTablesInStudyFromFile(ffile): + from exceptions import IOError + try: + file = open(ffile, 'r') + except : + msg="can't open file <%s>...\n"%ffile + raise IOError(msg) + # -- + is_table_first_line = 1 + tables = [] + # -- + num = 0 + for line in file.readlines(): + num += 1 + line = line.strip() + if len(line)==0: + is_table_first_line = 1 + continue + if is_table_first_line: + is_table_first_line = 0 + t = Table2D() + tables.append(t) + pass + if line.find('#TITLE:')==0: + t.title = line.split('#TITLE:')[1].strip() + continue + if line.find('#COLUMN_TITLES:')==0: + titles = line.split('#COLUMN_TITLES:')[1].split("|") + t.columnTitles = [ title.strip() for title in titles ] + continue + if line.find('#COLUMN_UNITS:')==0: + units = line.split('#COLUMN_UNITS:')[1].split() + t.columnUnits = [ unit.strip() for unit in units ] + continue + if line[0]== '#': + continue + row = Row() + if line.find('#TITLE:')>0: + row.title = line.split('#TITLE:')[1].strip() + line = line.split('#TITLE:')[0] + pass + values = line.split() + floatingValues = [] + for val in values : + try: + val = float(val) + except ValueError: + message = "Syntax error at line " + str(num) + " ... \n" + message += "Found field : " + str(val) + '\n' + message += "instead of a floating point number" + import qt + qt.QMessageBox.warning(None,"Error",message) + return + floatingValues.append(val) + pass + + if len(t.rows)>0: + if len(t.rows[0].values) != len(floatingValues): + message = "Syntax error at line " + str(num) + " ... \n" + message += "All rows must have the same number of fields" + import qt + qt.QMessageBox.warning(None,"Error",message) + return + pass + + row.values = floatingValues + t.rows.append(row) + pass + + import salome + myStudy = salome.myStudy + myBuilder = myStudy.NewBuilder() + + # >>> Getting (loading) VISU component ======================================= + myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "Visu") + myComponent = myStudy.FindComponent("VISU") + if not myComponent: + myComponent = myBuilder.NewComponent("VISU") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + aName.SetValue("Visu") + myBuilder.DefineComponentInstance(myComponent,myVisu) + pass + + # >>> Creating object with file name ===================================== + myFileObject = myBuilder.NewObject(myComponent) + AName = myBuilder.FindOrCreateAttribute(myFileObject, "AttributeName") + import os.path + AName.SetValue(os.path.basename(ffile)) + + num = 1 + for t in tables: + # >>> Creating object with Table of real ===================================== + myTRealObject = myBuilder.NewObject(myFileObject) + AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") + if t.title: + AName.SetValue(t.title) + else: + AName.SetValue("Table "+str(num)) + pass + num = num+1 + ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") + if t.title: + ARealTable.SetTitle(t.title) + pass + cols = t.getColumns() + for col in cols: + ARealTable.AddRow(col.values) + ARealTable.SetRowTitle(cols.index(col)+1, col.title) + ARealTable.SetRowUnit(cols.index(col)+1, col.unit) + # ARealTable.SetColumnTitles(l.values()) + pass + pass + + + + # >>> Updating Object Browser ================================================ + salome.sg.updateObjBrowser(1) + + + return + diff --git a/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx b/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx new file mode 100644 index 00000000..b95055fc --- /dev/null +++ b/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx @@ -0,0 +1,118 @@ +using namespace std; +// File : VisuGUI_CellsResultsDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_CellsResultsDlg.h" +#include +#include + +/*! + Constructor +*/ +VisuGUI_CellsResultsDlg::VisuGUI_CellsResultsDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_CellsResultsDlg" ); + setCaption( tr( "Results on selected Cell" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + GroupLimit = new QGroupBox( this, "GroupLimit" ); + GroupLimit->setTitle( tr( "Results on Cell" ) ); + GroupLimit->setColumnLayout(0, Qt::Vertical ); + GroupLimit->layout()->setSpacing( 0 ); + GroupLimit->layout()->setMargin( 0 ); + QGridLayout* GroupLimitLayout = new QGridLayout( GroupLimit->layout() ); + GroupLimitLayout->setAlignment( Qt::AlignTop ); + GroupLimitLayout->setSpacing( 6 ); + GroupLimitLayout->setMargin( 11 ); + + IdCell = new QLabel( tr( "IdCell" ), GroupLimit, "IdCell" ); + QFont IdCell_font = IdCell->font(); + IdCell_font.setBold( TRUE ); + IdCell->setFont( IdCell_font ); + IdCell->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); + IdCell->setFrameStyle( QLabel::Box | QLabel::Plain ); + IdCell->setMargin( 5 ); + QHBoxLayout* IdLayout = new QHBoxLayout; + + IdLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum )); + IdLayout->addWidget( IdCell ); + GroupLimitLayout->addMultiCellLayout( IdLayout, 0, 0, 0, 2); + + NbPoints = new QLabel( tr( "Number of Points :"), GroupLimit, "NbPoints" ); + GroupLimitLayout->addWidget( NbPoints, 1, 0 ); + NbPoint = new QLabel( tr( "NbPoints" ), GroupLimit, "NbPoint" ); + NbPoint->setAlignment( AlignLeft ); + GroupLimitLayout->addWidget( NbPoint, 1, 1 ); + GroupLimitLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 1, 2 ); + + ListPoints = new QListView( GroupLimit, "ListPoints" ); + ListPoints->setMinimumSize( 300, 120 ); + ListPoints->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + ListPoints->addColumn( tr( "Point" ) ); + ListPoints->addColumn( tr( "X" ) ); + ListPoints->addColumn( tr( "Y" ) ); + ListPoints->addColumn( tr( "Z" ) ); + ListPoints->setAllColumnsShowFocus( true ); + ListPoints->setShowToolTips( true ); + ListPoints->setSelectionMode( QListView::Single ); + ListPoints->header()->setStretchEnabled( true ); + ListPoints->header()->setStretchEnabled( true, 0 ); + ListPoints->header()->setStretchEnabled( true, 1 ); + ListPoints->header()->setStretchEnabled( true, 2 ); + ListPoints->header()->setStretchEnabled( true, 3 ); + GroupLimitLayout->addMultiCellWidget( ListPoints, 2, 2, 0, 2 ); + + Scalar_Results = new QLabel( tr( "Scalar result :" ), GroupLimit, "Scalar_Results" ); + GroupLimitLayout->addWidget( Scalar_Results, 3, 0 ); + ScalValue = new QLabel( tr( "Scalar Value" ), GroupLimit, "ScalValue" ); + ScalValue->setAlignment( AlignLeft ); + GroupLimitLayout->addWidget( ScalValue, 3, 1 ); + GroupLimitLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 3, 2 ); + + Vector_Results = new QLabel( tr( "Vector result :" ), GroupLimit, "Vector_Results" ); + GroupLimitLayout->addWidget( Vector_Results, 4, 0 ); + VectTxt = new QLabel( tr( "Vector Txt" ), GroupLimit, "VectTxt" ); + VectTxt->setAlignment( AlignLeft ); + GroupLimitLayout->addWidget( VectTxt, 4, 1 ); + GroupLimitLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 4, 2 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 0 ); + GroupButtonsLayout->addWidget( buttonOk, 0, 1 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + + TopLayout->addWidget( GroupLimit, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); +} + +/*! + Destructor +*/ +VisuGUI_CellsResultsDlg::~VisuGUI_CellsResultsDlg() +{ +} diff --git a/src/VISUGUI/VisuGUI_CellsResultsDlg.h b/src/VISUGUI/VisuGUI_CellsResultsDlg.h new file mode 100644 index 00000000..65e1a849 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CellsResultsDlg.h @@ -0,0 +1,39 @@ +// File : VisuGUI_CellsResultsDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_CELLSRESULTSDLG_H +#define VISUGUI_CELLSRESULTSDLG_H + +#include +#include +#include +#include +#include + +class VisuGUI_CellsResultsDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_CellsResultsDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_CellsResultsDlg(); + + QGroupBox* GroupLimit; + QLabel* IdCell; + QLabel* NbPoints; + QLabel* NbPoint; + QListView* ListPoints; + QLabel* Scalar_Results; + QLabel* ScalValue; + QLabel* Vector_Results; + QLabel* VectTxt; + QGroupBox* GroupButtons; + QPushButton* buttonOk; +}; + +#endif // VISUGUI_CELLSRESULTSDLG_H diff --git a/src/VISUGUI/VisuGUI_CursorDlg.cxx b/src/VISUGUI/VisuGUI_CursorDlg.cxx new file mode 100644 index 00000000..bb29dc65 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CursorDlg.cxx @@ -0,0 +1,89 @@ +using namespace std; +// File : VisuGUI_CursorDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_CursorDlg.h" +#include + +/*! + Constructor +*/ +VisuGUI_CursorDlg::VisuGUI_CursorDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_CursorDlg" ); + setCaption( name ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + TopGroupBox = new QGroupBox( this, "TopGroupBox" ); + TopGroupBox->setColumnLayout(0, Qt::Vertical ); + TopGroupBox->layout()->setSpacing( 0 ); + TopGroupBox->layout()->setMargin( 0 ); + QGridLayout* TopGroupBoxLayout = new QGridLayout( TopGroupBox->layout() ); + TopGroupBoxLayout->setAlignment( Qt::AlignTop ); + TopGroupBoxLayout->setSpacing( 6 ); + TopGroupBoxLayout->setMargin( 11 ); + + Comment1 = new QLabel( tr( "TextLabel1" ), TopGroupBox, "Comment1" ); + Comment1->setAlignment( QLabel::AlignCenter ); + TopGroupBoxLayout->addWidget( Comment1, 0, 0 ); + + Comment2 = new QLabel( tr( "TextLabel2" ), TopGroupBox, "Comment2" ); + Comment2->setAlignment( QLabel::AlignCenter ); + TopGroupBoxLayout->addWidget( Comment2, 1, 0 ); + + SpinBox1 = new QSpinBox( 1, 100, 1, TopGroupBox, "SpinBox1" ); + SpinBox1->setValue( 100 ); + SpinBox1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + SpinBox1->setMinimumSize( 70, 0 ); + QHBoxLayout* SLayout = new QHBoxLayout; + SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + SLayout->addWidget( SpinBox1 ); + SLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + TopGroupBoxLayout->addLayout( SLayout, 2, 0 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( TopGroupBox, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_CursorDlg::~VisuGUI_CursorDlg() +{ +} + diff --git a/src/VISUGUI/VisuGUI_CursorDlg.h b/src/VISUGUI/VisuGUI_CursorDlg.h new file mode 100644 index 00000000..0668aa6f --- /dev/null +++ b/src/VISUGUI/VisuGUI_CursorDlg.h @@ -0,0 +1,35 @@ +// File : VisuGUI_CursorDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_CURSORDLG_H +#define VISUGUI_CURSORDLG_H + +#include +#include +#include +#include +#include + +class VisuGUI_CursorDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_CursorDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_CursorDlg(); + + QGroupBox* TopGroupBox; + QLabel* Comment1; + QLabel* Comment2; + QSpinBox* SpinBox1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; +}; + +#endif // VISUGUI_CURSORDLG_H diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx new file mode 100644 index 00000000..fc0d175d --- /dev/null +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -0,0 +1,526 @@ +using namespace std; +// File : VisuGUI_CutPlanesDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_CutPlanesDlg.h" +#include +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +/*! + Constructor +*/ +VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() + : QDialog( QAD_Application::getDesktop(), "VisuGUI_CutPlanesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "Cut Planes Definition" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + /* + QGridLayout* CommentLayout = new QGridLayout; + CommentLayout->setMargin( 0 ); + CommentLayout->setSpacing( 6 ); + + QLabel* Comment1 = new QLabel( tr( "Enter plane position between" ), this, "Comment1" ); + Comment1->setText( tr( "Enter plane position between" ) ); + Comment1->setAlignment( AlignCenter ); + + Comment2_1 = new QLabel( tr( "v1" ), this, "Comment2_1" ); + Comment2_1->setMinimumSize( QSize( 70, 0 ) ); + Comment2_1->setAlignment( AlignCenter); + + QLabel* Comment2 = new QLabel( tr( " and " ), this, "Comment2" ); + Comment2->setAlignment( AlignCenter ); + + Comment2_2 = new QLabel( tr( "v2" ), this, "Comment2_2" ); + Comment2_2->setMinimumSize( QSize( 70, 0 ) ); + Comment2_2->setAlignment( AlignCenter ); + + QLabel* Comment3 = new QLabel( tr( "or in fraction between" ), this, "Comment3" ); + Comment3->setAlignment( AlignCenter ); + + QLabel* Commento4 = new QLabel( tr( " and " ), this, "Comment4" ); + Comment4->setAlignment( AlignCenter ); + + QLabel* Comment4_1 = new QLabel( tr( "0" ), this, "Comment4_1" ); + Comment4_1->setMinimumSize( QSize( 70, 0 ) ); + Comment4_1->setAlignment( AlignCenter ); + + QLabel* Comment4_2 = new QLabel( tr( "100" ), this, "Comment4_2" ); + Comment4_2->setMinimumSize( QSize( 70, 0 ) ); + Comment4_2->setAlignment( AlignCenter ); + QFont font = Comment3->font(); font.setBold( true ); + Comment2_1->setFont( font ); + Comment2_2->setFont( font ); + Comment4_1->setFont( font ); + Comment4_2->setFont( font ); + + CommentLayout->addMultiCellWidget( Comment1, 0, 0, 0, 2 ); + CommentLayout->addWidget( Comment2_1, 1, 0 ); + CommentLayout->addWidget( Comment2, 1, 1 ); + CommentLayout->addWidget( Comment2_2, 1, 2 ); + CommentLayout->addMultiCellWidget( Comment3, 2, 2, 0, 2 ); + CommentLayout->addWidget( Comment4_1, 3, 0 ); + CommentLayout->addWidget( Comment4, 3, 1 ); + CommentLayout->addWidget( Comment4_2, 3, 2 ); + CommentLayout->setColStretch( 0 , 5 ); + CommentLayout->setColStretch( 2 , 5 ); + */ + QButtonGroup* SelPlane = new QButtonGroup( tr( "Orientation" ), this, "SelPlane" ); + SelPlane->setTitle( tr( "Orientation" ) ); + SelPlane->setColumnLayout(0, Qt::Vertical ); + SelPlane->layout()->setSpacing( 0 ); + SelPlane->layout()->setMargin( 0 ); + QGridLayout* SelPlaneLayout = new QGridLayout( SelPlane->layout() ); + SelPlaneLayout->setAlignment( Qt::AlignTop ); + SelPlaneLayout->setSpacing( 6 ); + SelPlaneLayout->setMargin( 11 ); + + RBzx = new QRadioButton( tr( "// Z-X" ), SelPlane, "RBzx" ); + RByz = new QRadioButton( tr( "// Y-Z" ), SelPlane, "RByz" ); + RBxy = new QRadioButton( tr( "// X-Y" ), SelPlane, "RBxy" ); + SelPlaneLayout->addWidget( RBxy, 0, 0 ); + SelPlaneLayout->addWidget( RByz, 0, 1 ); + SelPlaneLayout->addWidget( RBzx, 0, 2 ); + + QLabel* LabelPosi_3 = new QLabel( tr( "Number of planes:" ), this, "LabelPosi_3" ); + + nbPlan = new QSpinBox( 1, 100, 1, this, "nbPlan" ); + nbPlan->setValue( 1 ); + nbPlan->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + /* + GBplan1 = new QGroupBox( tr( "First plane" ), this, "GBplan1" ); + GBplan1->setColumnLayout(0, Qt::Vertical ); + GBplan1->layout()->setSpacing( 0 ); + GBplan1->layout()->setMargin( 0 ); + QGridLayout* GBplan1Layout = new QGridLayout( GBplan1->layout() ); + GBplan1Layout->setAlignment( Qt::AlignTop ); + GBplan1Layout->setSpacing( 6 ); + GBplan1Layout->setMargin( 11 ); + + QLabel* LabelPos = new QLabel( tr( "Plane position (value):" ), GBplan1, "LabelPos" ); + GBplan1Layout->addWidget( LabelPos, 0, 0 ); + + PosPlan1 = new QAD_SpinBoxDbl( GBplan1, -999.999, 999.999, 0.1 ); + PosPlan1->setValue( 0 ); + PosPlan1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + GBplan1Layout->addWidget( PosPlan1, 0, 1 ); + + QLabel* LabelPosi = new QLabel( tr( "Plane position (fraction):" ), GBplan1, "LabelPosi" ); + GBplan1Layout->addWidget( LabelPosi, 1, 0 ); + + PosFrac1 = new QAD_SpinBoxDbl( GBplan1, 0, 100, 0.1 ); + PosFrac1->setValue( 0 ); + PosFrac1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + GBplan1Layout->addWidget( PosFrac1, 1, 1 ); + + GBplan2 = new QGroupBox( tr( "Second plane" ), this, "GBplan2" ); + GBplan2->setColumnLayout(0, Qt::Vertical ); + GBplan2->layout()->setSpacing( 0 ); + GBplan2->layout()->setMargin( 0 ); + QGridLayout* GBplan2Layout = new QGridLayout( GBplan2->layout() ); + GBplan2Layout->setAlignment( Qt::AlignTop ); + GBplan2Layout->setSpacing( 6 ); + GBplan2Layout->setMargin( 11 ); + + QLabel* LabelPos_5 = new QLabel( tr( "Plane position (value):" ), GBplan2, "LabelPos_5" ); + GBplan2Layout->addWidget( LabelPos_5, 0, 0); + + PosPlan2 = new QAD_SpinBoxDbl( GBplan2, -999.999, 999.999, 0.1 ); + PosPlan2->setValue( 0 ); + PosPlan2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + GBplan2Layout->addWidget( PosPlan2, 0, 1 ); + + QLabel* LabelPosi_6 = new QLabel( tr( "Plane position (fraction):" ), GBplan2, "LabelPosi_6" ); + GBplan2Layout->addWidget( LabelPosi_6, 1, 0); + + PosFrac2 = new QAD_SpinBoxDbl( GBplan2, 0, 100, 0.1 ); + PosFrac2->setValue( 100 ); + PosFrac2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + GBplan2Layout->addWidget( PosFrac2, 1, 1 ); + */ + QGroupBox* GBrot = new QGroupBox( tr( "Rotations" ), this, "GBrot" ); + GBrot->setColumnLayout(0, Qt::Vertical ); + GBrot->layout()->setSpacing( 0 ); + GBrot->layout()->setMargin( 0 ); + QGridLayout* GBrotLayout = new QGridLayout( GBrot->layout() ); + GBrotLayout->setAlignment( Qt::AlignTop ); + GBrotLayout->setSpacing( 6 ); + GBrotLayout->setMargin( 11 ); + + LabelRot1 = new QLabel( tr( "Rotation around X (Y to Z):" ), GBrot, "LabelRot1" ); + GBrotLayout->addWidget( LabelRot1, 0, 0 ); + + Rot1 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 ); + Rot1->setValue( 0 ); + Rot1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + GBrotLayout->addWidget( Rot1, 0, 1 ); + + LabelRot2 = new QLabel( tr( "Rotation around Y (Z to X):" ), GBrot, "LabelRot2" ); + GBrotLayout->addWidget( LabelRot2, 1, 0 ); + + Rot2 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 ); + Rot2->setValue( 0 ); + Rot2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + GBrotLayout->addWidget( Rot2, 1, 1 ); + + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 ); + + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + // layouting + TopLayout->addMultiCellWidget( SelPlane, 0, 0, 0, 1 ); + // TopLayout->addLayout( CommentLayout, 0, 1 ); + TopLayout->addWidget( LabelPosi_3, 1, 0 ); + TopLayout->addWidget( nbPlan, 1, 1 ); + //TopLayout->addMultiCellWidget( GBplan1, 2, 2, 0, 1 ); + //TopLayout->addMultiCellWidget( GBplan2, 3, 3, 0, 1 ); + TopLayout->addMultiCellWidget( GBrot, 2, 2, 0, 1 ); + TopLayout->addMultiCellWidget( GroupButtons, 3, 3, 0, 1 ); + + // signals and slots connections + connect( SelPlane, SIGNAL( clicked( int ) ), this, SLOT( orientationChanged( int ) ) ); + //connect( PosPlan1, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) ); + //connect( PosPlan2, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) ); + //connect( PosFrac1, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) ); + //connect( PosFrac2, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) ); + //connect( nbPlan, SIGNAL( valueChanged( int ) ), this, SLOT( nbPlanChanged( int ) ) ); + + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + // default values + X1 = 0; X2 = 0; + Y1 = 0; Y2 = 0; + Z1 = 0; Z2 = 0; + //nbPold = 0; + RBxy->setChecked( true ); + orientationChanged( 0 ); + //nbPlanChanged( 1 ); +} + +/*! + Destructor +*/ +VisuGUI_CutPlanesDlg::~VisuGUI_CutPlanesDlg() +{ +} + + +void VisuGUI_CutPlanesDlg::initFromPrsObject(VISU::CutPlanes_i* thePrs) { + setNbPlanes(thePrs->GetNbPlanes()); + setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI); + setPlanePos(thePrs->GetOrientationType()); +} + +void VisuGUI_CutPlanesDlg::storeToPrsObject(VISU::CutPlanes_i* thePrs) { + thePrs->SetNbPlanes(getNbPlanes()); + thePrs->SetRotateX(getRotation1()*PI/180.); + thePrs->SetRotateY(getRotation2()*PI/180.); + thePrs->SetOrientationType(getOrientaion()); + thePrs->Update(); +} + +/*! + Called when orientation is changed +*/ +void VisuGUI_CutPlanesDlg::orientationChanged( int ) +{ + if ( RBxy->isChecked() ) { + LabelRot1->setText( tr( "Rotation around X (Y to Z):" ) ); + LabelRot2->setText( tr( "Rotation around Y (Z to X):" ) ); + //Comment2_1->setText( QString::number( Z1 ) ); + //Comment2_2->setText( QString::number( Z2 ) ); + //PosPlan1->setMinValue( Z1 ); + //PosPlan1->setMaxValue( Z2 ); + //PosPlan2->setMinValue( Z1 ); + //PosPlan2->setMaxValue( Z2 ); + /* + if( nbPlan->value() == 1 ) { +// PosFrac1->setValue( 50 ); + PosPlan1->setValue( ( Z1 + Z2 ) / 2 ); +// PosFrac2->setValue( 50 ); + PosPlan2->setValue( ( Z1 + Z2 ) / 2 ); + } + else { +// PosFrac1->setValue( 0 ); + //PosPlan1->setValue( Z1 ); +// PosFrac2->setValue(100); + PosPlan2->setValue( Z2 ); + }*/ + } + else if ( RByz->isChecked() ) { + LabelRot1->setText( tr( "Rotation around Y (Z to X):" ) ); + LabelRot2->setText( tr( "Rotation around Z (X to Y):" ) ); + //Comment2_1->setText( QString::number( X1 ) ); + //Comment2_2->setText( QString::number( X2 ) ); + //PosPlan1->setMinValue( X1 ); + //PosPlan1->setMaxValue( X2 ); + //PosPlan2->setMinValue( X1 ); + //PosPlan2->setMaxValue( X2 ); + /* + if( nbPlan->value() == 1 ) { +// PosFrac1->setValue( 50 ); + PosPlan1->setValue( ( X1 + X2 ) / 2 ); +// PosFrac2->setValue( 50 ); + PosPlan2->setValue( ( X1 + X2 ) / 2 ); + } + else { +// PosFrac1->setValue( 0 ); + PosPlan1->setValue( X1 ); +// PosFrac2->setValue( 100 ); + PosPlan2->setValue( X2 ); + }*/ + } + else { // RBzx->isChecked() + //Comment2_1->setText( QString::number( Y1 ) ); + //Comment2_2->setText( QString::number( Y2 ) ); + //PosPlan1->setMinValue( Y1 ); + //PosPlan1->setMaxValue( Y2 ); + //PosPlan2->setMinValue( Y1 ); + //PosPlan2->setMaxValue( Y2 ); + LabelRot1->setText( tr( "Rotation around Z (X to Y):" ) ); + LabelRot2->setText( tr( "Rotation around X (Y to Z):" ) ); + /* + if( (nbPlan->value()) == 1 ) { +// PosFrac1->setValue( 50 ); + PosPlan1->setValue( ( Y1 + Y2 ) / 2 ); +// PosFrac2->setValue( 50 ); + PosPlan2->setValue( ( Y1 + Y2 ) / 2 ); + } + else { +// PosFrac1->setValue( 0 ); + PosPlan1->setValue( Y1 ); +// PosFrac2->setValue( 100 ); + PosPlan2->setValue( Y2 ); + }*/ + } +} + +/*! + Called when nb of planes is changed +*/ +/*void VisuGUI_CutPlanesDlg::nbPlanChanged( int nb ) +{ + int nold = ( nbPold == 0 ? 0 : ( nbPold > 1 ? 2 : 1 ) ); + int nnew = ( nb == 0 ? 0 : ( nb > 1 ? 2 : 1 ) ); + + if( nold != nnew ) + orientationChanged( 0 ); + //GBplan1->setEnabled( nnew != 0 ); + //GBplan2->setEnabled( nnew > 1 && nnew != 0 ); + nbPold = nb; + }*/ + +/*! + Called when position ( fraction ) is changed +*/ +/*void VisuGUI_CutPlanesDlg::fracChanged( double value ) +{ + if ( signalsBlocked() ) + return; + QAD_SpinBoxDbl* spin = 0; + double V1, V2; + if ( sender() == PosFrac1 ) + spin = PosPlan1; + if ( sender() == PosFrac2 ) + spin = PosPlan2; + if( RBxy->isChecked() ) { + V1 = Z1; V2 = Z2; + } + else if( RByz->isChecked() ) { + V1 = X1; V2 = X2; + } + else { + V1 = Y1; V2 = Y2; + } + if ( spin ) { + blockSignals( true ); + spin->setValue( V1 + ( V2 - V1 ) * value / 100 ); + blockSignals( false ); + } + }*/ + +/*! + Called when position ( value ) is changed +*/ +/*void VisuGUI_CutPlanesDlg::posChanged( double value ) +{ + if ( signalsBlocked() ) + return; + QAD_SpinBoxDbl* spin = 0; + double V; + if ( sender() == PosPlan1 ) + spin = PosFrac1; + if ( sender() == PosPlan2 ) + spin = PosFrac2; + if( RBxy->isChecked() ) { + if ( value <= Z1 ) + V = 0; + else if ( value >= Z2 ) + V = 100; + else + V = ( value - Z1 ) / ( Z2 - Z1 ) * 100; + } + else if( RByz->isChecked() ) + if ( value <= X1 ) + V = 0; + else if ( value >= X2 ) + V = 100; + else + V = ( value - X1 ) / ( X2 - X1 ) * 100; + else + if ( value <= Y1 ) + V = 0; + else if ( value >= Y2 ) + V = 100; + else + V = ( value - Y1 ) / ( Y2 - Y1 ) * 100; + if ( spin ) { + blockSignals( true ); + spin->setValue( V ); + blockSignals( false ); + } + }*/ + +/*! + Sets bounds ( must be called first ) +*/ +void VisuGUI_CutPlanesDlg::setBounds( const double x1, const double x2, + const double y1, const double y2, + const double z1, const double z2 ) +{ + X1 = min( x1, x2 ); X2 = max( x1, x2 ); + Y1 = min( y1, y2 ); Y2 = max( y1, y2 ); + Z1 = min( z1, z2 ); Z2 = max( z1, z2 ); + orientationChanged( 0 ); +} + +/*! + Sets nb of planes +*/ +void VisuGUI_CutPlanesDlg::setNbPlanes( const int nbp ) +{ + nbPlan->setValue( nbp ); +} + +/*! + Gets nb of planes +*/ +int VisuGUI_CutPlanesDlg::getNbPlanes() +{ + return nbPlan->value(); +} + +/*! + Sets planes orientation and position +*/ +void VisuGUI_CutPlanesDlg::setPlanePos( const VISU::CutPlanes::Orientation orient/*, const double pos1, const double pos2 */) +{ + if ( orient == VISU::CutPlanes::XY ) // xy + RBxy->setChecked( true ); + else if ( orient == VISU::CutPlanes::YZ ) // yz + RByz->setChecked( true ); + else // zx + RBzx->setChecked( true ); + orientationChanged( 0 ); + //PosPlan1->setValue( pos1 ); + //PosPlan2->setValue( pos2 ); +} + +/*! + Sets planes orientation and position ( fraction ) +*/ +/*void VisuGUI_CutPlanesDlg::setPlanePosFrac( const int orient, const double frac1, const double frac2 ) +{ + if ( orient == 1 ) // xy + RBxy->setChecked( true ); + else if ( orient == 2) // yz + RByz->setChecked( true ); + else // zx + RBzx->setChecked( true ); + orientationChanged( 0 ); + PosFrac1->setValue( frac1 ); + PosFrac2->setValue( frac2 ); + }*/ + +/*! + Gets planes orientation +*/ +VISU::CutPlanes::Orientation VisuGUI_CutPlanesDlg::getOrientaion() +{ + VISU::CutPlanes::Orientation orient; + if ( RBxy->isChecked() ) // xy + orient = VISU::CutPlanes::XY; + if ( RByz->isChecked() ) // yz + orient = VISU::CutPlanes::YZ; + if ( RBzx->isChecked() ) // zx + orient = VISU::CutPlanes::ZX; + return orient; +} + +/*! + Gets planes position 1 +*/ +/*double VisuGUI_CutPlanesDlg::getPlanePos1() +{ + return PosPlan1->value(); + }*/ + +/*! + Gets planes position 2 +*/ +/*double VisuGUI_CutPlanesDlg::getPlanePos2() +{ + return PosPlan2->value(); + }*/ + +/*! + Sets planes rotation +*/ +void VisuGUI_CutPlanesDlg::setRotation( const double r1, const double r2 ) +{ + Rot1->setValue( r1 ); + Rot2->setValue( r2 ); +} + +/*! + Gets plane rotation 1 +*/ +double VisuGUI_CutPlanesDlg::getRotation1() +{ + return Rot1->value(); +} + +/*! + Gets plane rotation 2 +*/ +double VisuGUI_CutPlanesDlg::getRotation2() +{ + return Rot2->value(); +} diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.h b/src/VISUGUI/VisuGUI_CutPlanesDlg.h new file mode 100644 index 00000000..16968782 --- /dev/null +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.h @@ -0,0 +1,91 @@ +// File : VisuGUI_CutPlanesDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_CUTPLANESDLG_H +#define VISUGUI_CUTPLANESDLG_H + +#include +#include +#include +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" +#include "VISU_PrsObject_i.hh" +#include "VisuGUI_ScalarBarDlg.h" + + +class VisuGUI_CutPlanesDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_CutPlanesDlg(); + ~VisuGUI_CutPlanesDlg(); + + void setBounds( const double x1, const double x2, + const double y1, const double y2, + const double z1, const double z2 ); + void setNbPlanes( const int nbp ); + int getNbPlanes(); + void setPlanePos( const VISU::CutPlanes::Orientation orient/*, const double pos1, const double pos2 */); + //void setPlanePosFrac( const int orient, const double frac1, const double frac2 ); + VISU::CutPlanes::Orientation getOrientaion(); + //double getPlanePos1(); + //double getPlanePos2(); + void setRotation( const double r1, const double r2 ); + double getRotation1(); + double getRotation2(); + + void initFromPrsObject(VISU::CutPlanes_i* thePrs); + void storeToPrsObject(VISU::CutPlanes_i* thePrs); + +protected slots: + + +private: + //QLabel* Comment2_1; + //QLabel* Comment2_2; + QLabel* LabelRot1; + QLabel* LabelRot2; + QSpinBox* nbPlan; + //QAD_SpinBoxDbl* PosPlan1; + //QAD_SpinBoxDbl* PosFrac1; + //QAD_SpinBoxDbl* PosPlan2; + //QAD_SpinBoxDbl* PosFrac2; + QAD_SpinBoxDbl* Rot1; + QAD_SpinBoxDbl* Rot2; + QRadioButton* RBzx; + QRadioButton* RByz; + QRadioButton* RBxy; + //QGroupBox* GBplan1; + //QGroupBox* GBplan2; + + double X1, X2; + double Y1, Y2; + double Z1, Z2; + //int nbPold; + + +private slots: + void editScalarBar(); + void orientationChanged( int ); + //void nbPlanChanged( int ); + //void fracChanged( double ); + //void posChanged( double ); +}; + +#endif // VISUGUI_CUTPLANESDLG_H + + + + + + + diff --git a/src/VISUGUI/VisuGUI_InitMeshDlg.cxx b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx new file mode 100644 index 00000000..251ff08e --- /dev/null +++ b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx @@ -0,0 +1,360 @@ +using namespace std; +// File : VisuGUI_InitMeshDlg.cxx +// Created : Mon May 27 10:20:11 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : Visu +// Copyright : Open CASCADE 2002 +// $Header$ + +#include "VisuGUI_InitMeshDlg.h" +#include "VisuGUI.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +//================================================================================= +// class : VisuGUI_InitMeshDlg() +// purpose : Constructs a VisuGUI_InitMeshDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +VisuGUI_InitMeshDlg::VisuGUI_InitMeshDlg( QWidget* parent, const char* name, SALOME_Selection* Sel = 0, bool modal, WFlags fl ) + : QDialog( parent, name, modal, fl ) +{ + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "VisuGUI",tr("ICON_DLG_INIT_MESH"))); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "VisuGUI",tr("ICON_SELECT"))); + if ( !name ) + setName( "VisuGUI_InitMeshDlg" ); + resize( 303, 175 ); + setCaption( tr( "Visu_INIT_MESH" ) ); + VisuGUI_InitMeshDlgLayout = new QGridLayout( this ); + VisuGUI_InitMeshDlgLayout->setSpacing( 6 ); + VisuGUI_InitMeshDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "Visu_INIT" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image1 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + VisuGUI_InitMeshDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "Visu_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "Visu_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "Visu_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + VisuGUI_InitMeshDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "Visu_ARGUMENTS" ) ); + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "Visu_OBJECT_GEOM" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image0 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + TextLabel_NameMesh = new QLabel( GroupC1, "TextLabel_NameMesh" ); + TextLabel_NameMesh->setText( tr( "Visu_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameMesh, 1, 0 ); + LineEdit_NameMesh = new QLineEdit( GroupC1, "LineEdit_NameMesh" ); + GroupC1Layout->addWidget( LineEdit_NameMesh, 1, 2 ); + + VisuGUI_InitMeshDlgLayout->addWidget( GroupC1, 1, 0 ); + /***************************************************************/ + + Init(Sel) ; +} + + +//================================================================================= +// function : ~VisuGUI_InitMeshDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +VisuGUI_InitMeshDlg::~VisuGUI_InitMeshDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::Init( SALOME_Selection* Sel ) +{ + GroupC1->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + myVisuGUI = VisuGUI::GetVisuGUI() ; + myVisuGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myGeomFilter = new SALOME_TypeFilter( "GEOM" ); + mySelection->AddFilter( myGeomFilter ); + + myNameMesh = "Mesh"; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( pressed() ), this, SLOT( ClickOnOk() ) ); + connect( buttonApply, SIGNAL( pressed() ), this, SLOT(ClickOnApply() ) ); + connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( ClickOnCancel() ) ) ; + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButtonC1A1, SIGNAL (pressed() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( LineEdit_NameMesh, SIGNAL (textChanged(const QString&) ), this, SLOT( TextChangedInLineEdit(const QString&) ) ) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + connect( myVisuGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( myVisuGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + +// int x, y ; +// myVisuGUI->DefineDlgPosition( this, x, y ) ; +// this->move( x, y ) ; + this->show() ; + + return ; +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void VisuGUI_InitMeshDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + + return ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::ClickOnApply() +{ + switch(myConstructorId) + { + case 0 : + { + if ( !myNameMesh.isEmpty() && !myNameMesh.isNull() && !myGeomShape->_is_nil() ) + myVisuGUI->InitMesh( mySMeshMesh, myNameMesh ) ; + break ; + } + } +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::ClickOnCancel() +{ + mySelection->ClearFilters() ; + disconnect( mySelection, 0, this, 0 ); + myVisuGUI->ResetState() ; + reject() ; + return ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void VisuGUI_InitMeshDlg::SelectionIntoArgument() +{ + myEditCurrentArgument->setText("") ; + QString aString = ""; + myGeomShape = GEOM::GEOM_Shape::_nil(); + + int nbSel = myVisuGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + if ( nbSel != 1 ) { + return ; + } else { + Standard_Boolean testResult ; + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + myGeomShape = myVisuGUI->ConvertIOinGEOMShape(IO, testResult) ; + if( !testResult ) return ; + } + + myEditCurrentArgument->setText(aString) ; +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; + break; + } + } + return ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + disconnect( mySelection, 0, this, 0 ); + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::ActivateThisDialog() +{ + myVisuGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + return ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::closeEvent( QCloseEvent* e ) +{ + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : TextChangedInLineEdit() +// purpose : +//================================================================================= +void VisuGUI_InitMeshDlg::TextChangedInLineEdit(const QString& newText) +{ + QLineEdit* send = (QLineEdit*)sender(); + QString newT = strdup(newText) ; + + if (send == LineEdit_NameMesh) { + myNameMesh = newText; + } + return ; +} diff --git a/src/VISUGUI/VisuGUI_InitMeshDlg.h b/src/VISUGUI/VisuGUI_InitMeshDlg.h new file mode 100644 index 00000000..bd32536d --- /dev/null +++ b/src/VISUGUI/VisuGUI_InitMeshDlg.h @@ -0,0 +1,98 @@ +// File : VisuGUI_InitMeshDlg.h +// Created : Mon May 27 10:23:17 2002 +// Author : Nicolas REJNERI + +// Project : SALOME +// Module : Visu +// Copyright : Open CASCADE 2002 +// $Header$ + +#ifndef DIALOGBOX_INIT_MESH_H +#define DIALOGBOX_INIT_MESH_H + +#include "SALOME_Selection.h" +#include "SALOME_TypeFilter.hxx" + +// QT Includes +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(GEOM_Shape) + +class QVBoxLayout; +class QHBoxLayout; +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class VisuGUI; + + +//================================================================================= +// class : VisuGUI_InitMeshDlg +// purpose : +//================================================================================= +class VisuGUI_InitMeshDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_InitMeshDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_InitMeshDlg(); + +private: + + void Init( SALOME_Selection* Sel ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + VisuGUI* myVisuGUI ; + SALOME_Selection* mySelection ; + + GEOM::GEOM_Shape_var myGeomShape ; + int myConstructorId ; + QLineEdit* myEditCurrentArgument; + + QString myNameMesh ; + + Handle(SALOME_TypeFilter) myGeomFilter; + + QButtonGroup* GroupConstructors; + QRadioButton* Constructor1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupC1; + QLabel* TextLabel_NameMesh ; + QLineEdit* LineEdit_NameMesh ; + QLabel* TextLabelC1A1; + QPushButton* SelectButtonC1A1; + QLineEdit* LineEditC1A1; + +private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void TextChangedInLineEdit(const QString& newText) ; + +protected: + QGridLayout* VisuGUI_InitMeshDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupC1Layout; +}; + +#endif // DIALOGBOX_INIT_MESH_H diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx new file mode 100644 index 00000000..3e8222a9 --- /dev/null +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -0,0 +1,104 @@ +using namespace std; +// File : VisuGUI_IsoSurfacesDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_IsoSurfacesDlg.h" +#include +#include +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +/*! + Constructor +*/ +VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg() + : QDialog( QAD_Application::getDesktop(), "VisuGUI_IsoSurfacesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "Iso Surfaces Definition" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" ); + TopGroupLayout->addWidget( LabelMin, 0, 0 ); + MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinIso->setMinimumSize( 70, 0 ); + TopGroupLayout->addWidget( MinIso, 0, 1 ); + + QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" ); + TopGroupLayout->addWidget( LabelMax, 1, 0 ); + MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1); + MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxIso->setMinimumSize( 70, 0 ); + TopGroupLayout->addWidget( MaxIso, 1, 1 ); + + QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" ); + TopGroupLayout->addWidget( LabelNbr, 2, 0 ); + NbrIso = new QSpinBox( 1, 100, 1, TopGroup, "NbrIso" ); + NbrIso->setValue( 1 ); + TopGroupLayout->addWidget( NbrIso, 2, 1 ); + + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg() +{ +} + + +void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) { + NbrIso->setValue(thePrs->GetNbSurfaces()); + MinIso->setValue(thePrs->GetRangeMin()); + MaxIso->setValue(thePrs->GetRangeMax()); +} + + +void VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) { + thePrs->SetNbSurfaces(NbrIso->value()); + thePrs->SetRange(MinIso->value(), MaxIso->value()); + thePrs->Update(); +} diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h new file mode 100644 index 00000000..68ca04cd --- /dev/null +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h @@ -0,0 +1,38 @@ +// File : VisuGUI_IsoSurfacesDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_ISOSURFACESDLG_H +#define VISUGUI_ISOSURFACESDLG_H + +#include +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" +#include "VISU_PrsObject_i.hh" + + +class VisuGUI_IsoSurfacesDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_IsoSurfacesDlg(); + ~VisuGUI_IsoSurfacesDlg(); + + void initFromPrsObject(VISU::IsoSurfaces_i* thePrs); + void storeToPrsObject(VISU::IsoSurfaces_i* thePrs); + + private: + QAD_SpinBoxDbl* MinIso; + QAD_SpinBoxDbl* MaxIso; + QSpinBox* NbrIso; +}; + +#endif // VISUGUI_ISOSURFACESDLG_H diff --git a/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx b/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx new file mode 100644 index 00000000..d1b60b60 --- /dev/null +++ b/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx @@ -0,0 +1,95 @@ +using namespace std; +// File : VisuGUI_MagnitudeDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_MagnitudeDlg.h" +#include +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +/*! + Constructor +*/ +VisuGUI_MagnitudeDlg::VisuGUI_MagnitudeDlg() + : QDialog( QAD_Application::getDesktop(), "VisuGUI_MagnitudeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "Deformed Shape" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + QLabel* ScaleLabel = new QLabel( tr( "Scale Factor:" ), TopGroup, "ScaleLabel" ); + TopGroupLayout->addWidget( ScaleLabel, 0, 0 ); + + ScalFact = new QAD_SpinBoxDbl( TopGroup, 0, 1.0E+38, 0.1, 5); + ScalFact->setValue( 0.1 ); + TopGroupLayout->addWidget( ScalFact, 0, 1 ); + + UseMagn = new QCheckBox( tr( "Magnitude coloring" ), TopGroup, "UseMagn" ); + UseMagn->setChecked( true ); + TopGroupLayout->addMultiCellWidget( UseMagn, 1, 1, 0, 1 ); + //if (!enableUM) + // UseMagn->hide(); + + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_MagnitudeDlg::~VisuGUI_MagnitudeDlg() +{ +} + + +void VisuGUI_MagnitudeDlg::initFromPrsObject(VISU::DeformedShape_i* thePrs) { + setFactor(thePrs->GetScale()); + UseMagn->setChecked(thePrs->isColored()); +} + + +void VisuGUI_MagnitudeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) { + thePrs->SetScale(getFactor()); + thePrs->setColored(isColored()); +} + diff --git a/src/VISUGUI/VisuGUI_MagnitudeDlg.h b/src/VISUGUI/VisuGUI_MagnitudeDlg.h new file mode 100644 index 00000000..2ae11299 --- /dev/null +++ b/src/VISUGUI/VisuGUI_MagnitudeDlg.h @@ -0,0 +1,44 @@ +// File : VisuGUI_MagnitudeDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_MAGNITUDEDLG_H +#define VISUGUI_MAGNITUDEDLG_H + +#include +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" +#include "VISU_PrsObject_i.hh" + +class VisuGUI_MagnitudeDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_MagnitudeDlg(); + ~VisuGUI_MagnitudeDlg(); + + double getFactor() + { return ScalFact->value(); } + void setFactor(double theFactor) + { ScalFact->setValue(theFactor); } + + bool isColored() + { return UseMagn->isChecked(); } + + void initFromPrsObject(VISU::DeformedShape_i* thePrs); + void storeToPrsObject(VISU::DeformedShape_i* thePrs); + + private: + QAD_SpinBoxDbl* ScalFact; + QCheckBox* UseMagn; +}; + +#endif // VISUGUI_MAGNITUDEDLG_H diff --git a/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx new file mode 100644 index 00000000..ab983f84 --- /dev/null +++ b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx @@ -0,0 +1,464 @@ +using namespace std; +// File : SALOMEGUI_NonIsometricDlg.cxx +// Created : Thu Dec 18 12:01:00 2002 +// Author : Vasily Rusyaev +// Project : SALOME PRO +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#include "VisuGUI_NonIsometricDlg.h" + +#include +#include +#include +#include +#include +#include +#include +//#include + +#include "QAD_SpinBoxDbl.h" +#include "utilities.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_StudyFrame.h" +#include "QAD_RightFrame.h" +#include "VTKViewer_ViewFrame.h" +#include "VISU_Actor.h" + +#include +#include + +/*! + Constructor +*/ +VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + + QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); + VTKViewer_NonIsometricTransform *aTransform = NULL; + if ( sf->getTypeView() == VIEW_VTK ) + { + VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*) ( sf->getRightFrame()->getViewFrame() ); + aTransform = vf->getNonIsometricTransform(); + } + + if ( !name ) + setName( "NonIsometricDlg" ); + setCaption( tr( "Scaling" ) ); + setSizeGripEnabled( TRUE ); + + // Create layout for this dialog + QGridLayout* layoutDlg = new QGridLayout( this ); + layoutDlg->setSpacing(6); + layoutDlg->setMargin(11); + + // Create croup box with grid layout + QGroupBox* GroupBox = new QGroupBox( this, "GroupBox" ); + + QGridLayout* glGroupBox = new QGridLayout( GroupBox ); + glGroupBox->setMargin(11); + glGroupBox->setSpacing(6); + + //Create font: 14pnts, bold, italic + //It will be used for all labels in this group box + QFont m_font14bi = font(); + m_font14bi.setPointSize((int)(m_font14bi.pointSize()*1.4)); +// m_font14bi.setItalic( TRUE ); + m_font14bi.setBold( TRUE ); + + // Create "Choose function" label + QLabel* TextLabel1 = new QLabel( tr( "Choose function:" ), GroupBox, "TextLabel1" ); + glGroupBox->addWidget ( TextLabel1, 1, 0 ); + + // Create "Type the coefficient" label + QLabel* TextLabel2 = new QLabel( tr( "Coefficient:" ), GroupBox, "TextLabel2" ); + glGroupBox->addWidget ( TextLabel2, 2, 0 ); + + // Create "Applying function" label + QLabel* TextLabel3 = new QLabel( tr( "Applying function:" ), GroupBox, "TextLabel3" ); + glGroupBox->addWidget ( TextLabel3, 3, 0 ); + + glGroupBox->addColSpacing ( 1, 10 ); + + // Create "X" label + QLabel* TextLabelX = new QLabel( "X", GroupBox, "TextLabelX" ); + TextLabelX->setAlignment( int( QLabel::AlignCenter ) ); + //NRI TextLabelX->setFont( m_font14bi ); + glGroupBox->addWidget ( TextLabelX, 0, 2 ); + + // Create combobox for selecting scaling function on a X axis + m_cbXfunction = new QComboBox( FALSE, GroupBox, "m_cbXFunction"); + m_cbXfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_cbXfunction->setMinimumWidth( 80 ); + glGroupBox->addWidget(m_cbXfunction, 1, 2 ); + + // Create double spinbox for changing coef. in the scaling function on a X axis + m_sbXcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbXcoeff" ); + m_sbXcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbXcoeff->setMinimumWidth( 80 ); + glGroupBox->addWidget(m_sbXcoeff, 2, 2 ); + + // Create informative label about the applying scaling function on a X axis + m_lXFunction = new QLabel( GroupBox, "m_lXFunction" ); + //NRI m_lXFunction->setFont( m_font14bi ); + m_lXFunction->setAlignment( int( QLabel::AlignCenter ) ); + glGroupBox->addWidget(m_lXFunction, 3, 2 ); + + FillComboBox( m_cbXfunction ); + + // Create "Y" label + QLabel* TextLabelY = new QLabel( "Y", GroupBox, "TextLabelY" ); + TextLabelY->setAlignment( int( QLabel::AlignCenter ) ); + //NRI TextLabelY->setFont( m_font14bi ); + glGroupBox->addWidget ( TextLabelY, 0, 3 ); + + // Create combobox for selecting scaling function on a Y axis + m_cbYfunction = new QComboBox( FALSE, GroupBox, "m_cbYFunction"); + m_cbYfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_cbYfunction->setMinimumWidth( 80 ); + glGroupBox->addWidget(m_cbYfunction, 1, 3 ); + + // Create double spinbox for changing coef. in the scaling function on a Y axis + m_sbYcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbYcoeff" ); + m_sbYcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbYcoeff->setMinimumWidth( 80 ); + glGroupBox->addWidget(m_sbYcoeff, 2, 3 ); + + // Create informative label about the applying scaling function on a Y axis + m_lYFunction = new QLabel( GroupBox, "m_lYFunction" ); + m_lYFunction->setAlignment( int( QLabel::AlignCenter ) ); + //NRI m_lYFunction->setFont( m_font14bi ); + glGroupBox->addWidget(m_lYFunction, 3, 3 ); + + FillComboBox( m_cbYfunction ); + + // Create "Z" label + QLabel* TextLabelZ = new QLabel( "Z", GroupBox, "TextLabelZ" ); + TextLabelZ->setAlignment( int( QLabel::AlignCenter ) ); + //NRI TextLabelZ->setFont( m_font14bi ); + glGroupBox->addWidget ( TextLabelZ, 0, 4 ); + + // Create combobox for selecting scaling function on a Z axis + m_cbZfunction = new QComboBox( FALSE, GroupBox, "m_cbZFunction"); + m_cbZfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_cbZfunction->setMinimumWidth( 80 ); + glGroupBox->addWidget(m_cbZfunction, 1, 4 ); + + // Create double spinbox for changing coef. in the scaling function on a Z axis + m_sbZcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbZcoeff" ); + m_sbZcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbZcoeff->setMinimumWidth( 80 ); + glGroupBox->addWidget(m_sbZcoeff, 2, 4 ); + + // Create informative label about the applying scaling function on a Z axis + m_lZFunction = new QLabel( GroupBox, "m_lZFunction" ); + m_lZFunction->setAlignment( int( QLabel::AlignCenter ) ); + //NRI m_lZFunction->setFont( m_font14bi ); + glGroupBox->addWidget(m_lZFunction, 3, 4 ); + + FillComboBox( m_cbZfunction ); + + if ( aTransform ) { + int item = aTransform->GetFunctionType(AxisFunction::XAxis); + m_cbXfunction->setCurrentItem(item); + if (item) { + m_sbXcoeff ->setEnabled (TRUE); + FunctionChanged( m_cbXfunction); + } + item = aTransform->GetFunctionType(AxisFunction::YAxis); + m_cbYfunction->setCurrentItem(item); + if (item) { + m_sbYcoeff ->setEnabled (TRUE); + FunctionChanged( m_cbYfunction ); + } + item = aTransform->GetFunctionType(AxisFunction::ZAxis); + m_cbZfunction->setCurrentItem(item); + if (item) { + m_sbZcoeff ->setEnabled (TRUE); + FunctionChanged( m_cbZfunction); + } + m_sbXcoeff -> setValue(aTransform->GetCoeff(AxisFunction::XAxis)); + m_sbYcoeff -> setValue(aTransform->GetCoeff(AxisFunction::YAxis)); + m_sbZcoeff -> setValue(aTransform->GetCoeff(AxisFunction::ZAxis)); + } + + // Create button + QPushButton* m_bReset = new QPushButton( tr( "&Reset" ), GroupBox, "m_bReset" ); + glGroupBox->addWidget( m_bReset, 4, 4 ); + + layoutDlg->addWidget(GroupBox,0,0); + + // OK, CANCEL, Apply button + QGroupBox* aWgt = new QGroupBox( this ); + QHBoxLayout* aHBoxLayout = new QHBoxLayout( aWgt ); + aHBoxLayout->setMargin(11); + aHBoxLayout->setSpacing(6); + + // Create button + QPushButton* m_bOk = new QPushButton( tr( "O&K" ), aWgt, "m_bOk" ); + m_bOk->setDefault( TRUE ); + m_bOk->setAutoDefault( TRUE ); + aHBoxLayout->addWidget( m_bOk ); + aHBoxLayout->addStretch(); + + // Create button + QPushButton* m_bApply = new QPushButton( tr( "&Apply" ), aWgt, "m_bApply" ); + m_bApply->setAutoDefault( TRUE ); + aHBoxLayout->addWidget( m_bApply ); + aHBoxLayout->addStretch(); + + // Create button + QPushButton* m_bCancel = new QPushButton( tr( "&Cancel" ), aWgt, "m_bCancel" ); + m_bCancel->setAutoDefault( TRUE ); + aHBoxLayout->addWidget( m_bCancel ); + + layoutDlg->addWidget(aWgt,1,0); + + // signals and slots connections + connect( m_bCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( m_bOk, SIGNAL( clicked() ), this, SLOT( onClickOk( ) ) ); + connect( m_bApply, SIGNAL( clicked() ), this, SLOT( onClickApply( ) ) ); + connect( m_bReset, SIGNAL( clicked() ), this, SLOT( onClickReset( ) ) ); +} + +/* + * Destroys the object and frees any allocated resources + */ +VisuGUI_NonIsometricDlg::~VisuGUI_NonIsometricDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +void VisuGUI_NonIsometricDlg::onClickOk() +{ + //apply changes + onClickApply(); + //Close dialog + accept(); +} + +void VisuGUI_NonIsometricDlg::onClickApply() +{ + bool changed = false; + QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); + if ( sf->getTypeView() == VIEW_VTK ) + { + int Xfunction = m_cbXfunction->currentItem(); + int Yfunction = m_cbYfunction->currentItem(); + int Zfunction = m_cbZfunction->currentItem(); + + + VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*) ( sf->getRightFrame()->getViewFrame() ); + VTKViewer_NonIsometricTransform *aTransform = vf->getNonIsometricTransform(); + + vtkRenderer* Renderer = vf->getRenderer(); + vtkActorCollection* theActors = Renderer->GetActors(); + theActors->InitTraversal(); + vtkActor *actor = theActors->GetNextActor(); + + aTransform->SetFunction( AxisFunction::XAxis, + (VTKViewer_NonIsometricTransform::Function) Xfunction, + m_sbXcoeff->value() ); + + aTransform->SetFunction( AxisFunction::YAxis, + (VTKViewer_NonIsometricTransform::Function) Yfunction, + m_sbYcoeff->value() ); + + aTransform->SetFunction( AxisFunction::ZAxis, + (VTKViewer_NonIsometricTransform::Function) Zfunction, + m_sbZcoeff->value() ); + + while( actor ) + { + //SALOME_Actor* pSA = dynamic_cast (actor); + SALOME_Actor* pSA = dynamic_cast (actor); + if (pSA) + { + //MESSAGE (actor->GetMapper()->GetClassName ()) + vtkPolyDataMapper* mapper = NULL; + vtkMapper* initialMapper = pSA->GetInitialMapper(); + if ( initialMapper == NULL ) + initialMapper = actor->GetMapper(); + if ( initialMapper->IsA("vtkDataSetMapper") ) + mapper = vtkDataSetMapper::SafeDownCast( initialMapper )->GetPolyDataMapper (); + else + mapper = vtkPolyDataMapper::SafeDownCast( initialMapper ); + //MESSAGE (mapper->GetClassName ()) + + if (mapper) + { + //create transformation + + //create Filter + vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); + aTransformFilter->SetInput ( mapper->GetInput() ); + aTransformFilter->SetTransform (aTransform); + + //create new mapper + vtkDataSetMapper *aMapper = vtkDataSetMapper::New(); + aMapper->SetInput (aTransformFilter->GetOutput()); + aMapper->ShallowCopy ( actor->GetMapper()); + + //set new mapper + actor->SetMapper (aMapper); + + aTransformFilter->Delete(); + aMapper->Delete(); + changed = true; + } + } + actor = theActors->GetNextActor(); + } + if (changed) + vf->Repaint(); + //in order to improve perfomance + if ( !Xfunction && !Yfunction && !Zfunction ) + vf->setNonIsometricTransform( NULL ); + } +} + +void VisuGUI_NonIsometricDlg::onClickReset() +{ + //it's workaround for QComboBox - it doesn't send activated signal using setCurrentItem function + //therefore we connect on highlighted signal, use setCurrentItem() and disconnect highlighted signal + + connect (m_cbXfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); + + m_cbXfunction->setCurrentItem ( 0 ); + m_cbXfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); + + connect (m_cbYfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); + m_cbYfunction->setCurrentItem ( 0 ); + m_cbYfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); + + connect (m_cbZfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); + m_cbZfunction->setCurrentItem ( 0 ); + m_cbZfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); +} + +//Populates combobox and makes all needed connects +void VisuGUI_NonIsometricDlg::FillComboBox(QComboBox* cb) +{ + cb->insertItem( tr ("None") ); + cb->insertItem ( tr ("Linear") ); +// cb->insertItem ( tr ("Logarithmic") ); + + + connect (cb, SIGNAL( activated ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); + + //it's workaround for QComboBox - it doesn't send activated signal using setCurrentItem function + //therefore we connect on highlighted signal, use setCurrentItem() and disconnect highlighted signal + cb->setCurrentItem ( 1 ); + connect (cb, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); + cb->setCurrentItem ( 0 ); + cb->disconnect( SIGNAL( highlighted ( const QString& ) ) ); + +} + +void VisuGUI_NonIsometricDlg::onFunctionChanged() +{ + //TODO + const QComboBox* cbFunction = (const QComboBox* ) sender(); + FunctionChanged(cbFunction); +} + +void VisuGUI_NonIsometricDlg::FunctionChanged(const QComboBox* cbFunction ) +{ + //TODO + const QString & function = cbFunction-> currentText(); + QAD_SpinBoxDbl* sbCoeff; + QLabel* lFunction; + QString axis; + QString formula; + //this variable stores index in bounds array for vtkRenderer + // 0 - xmin, xmax + // 2 - ymin, ymax + // 4 - zmin, zmax + int boundIndex; + + if (cbFunction == m_cbXfunction) + { + sbCoeff = m_sbXcoeff; + lFunction = m_lXFunction; + axis = "x"; + boundIndex = 0; + } + else + if (cbFunction == m_cbYfunction) + { + sbCoeff = m_sbYcoeff; + lFunction = m_lYFunction; + axis = "y"; + boundIndex = 2; + } + else + if (cbFunction == m_cbZfunction) + { + sbCoeff = m_sbZcoeff; + lFunction = m_lZFunction; + axis = "z"; + boundIndex = 4; + } + else + return ; + + sbCoeff->setEnabled (TRUE); + formula = axis; + + if ( function == tr ("None") ) + { + sbCoeff->setMinValue( 1.0 ); + sbCoeff->setMaxValue( 1.0 ); + sbCoeff->setValue( 1.0 ); + sbCoeff->setEnabled ( FALSE ); + formula += QString(" = "); + formula += axis; + lFunction->setText( formula ); + } + else + if ( function == tr ("Linear") ) + { + sbCoeff->setMinValue( -1.7E308 ); + sbCoeff->setMaxValue( 1.7E+308 ); + // sbCoeff->setValue( 1.0 ); + formula += QString(" = k"); + formula += axis; + lFunction->setText( formula ); + } + else + if ( function == tr ("Logarithmic") ) + { + // TODO + QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); + if ( sf->getTypeView() == VIEW_VTK ) + { + vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + float bounds[6]; + Renderer->ComputeVisiblePropBounds (bounds); + //we use following formula lg (x+a) and x+a >= 1 + //therefore a >= 1-x + double minValue; + if ( bounds[boundIndex] > 0 && bounds[boundIndex+1] > 0 ) + minValue = 1 - bounds[boundIndex+1]; + else + minValue = 1 - bounds[boundIndex]; + MESSAGE ( "Bounds " << bounds[0] << " " << bounds[1] << " " << bounds[2] << " " << bounds[3] << " " << bounds[4] << " " << bounds[5] << " " ) + sbCoeff->setMinValue( minValue ); + sbCoeff->setMaxValue( 1.7E+308 ); + sbCoeff->setValue( minValue ); + formula += QString(" = lg("); + formula += axis; + formula += QString("+a), a >= %1").arg( minValue ); + } + else + { + sbCoeff->setEnabled (FALSE); + formula = ""; + } + lFunction->setText( formula ); + } +} diff --git a/src/VISUGUI/VisuGUI_NonIsometricDlg.h b/src/VISUGUI/VisuGUI_NonIsometricDlg.h new file mode 100644 index 00000000..074b5b3c --- /dev/null +++ b/src/VISUGUI/VisuGUI_NonIsometricDlg.h @@ -0,0 +1,51 @@ +// File : VisuGUI_NonIsometricDlg.h +// Created : Thu Dec 18 12:01:00 2002 +// Author : Vasily Rusyaev +// Project : SALOME PRO +// Module : SALOMEGUI +// Copyright : Open CASCADE +// $Header$ + +#ifndef VisuGUI_NONISOMETRICDLG_H +#define VisuGUI_NONISOMETRICDLG_H + +#include +class QLabel; +class QAD_SpinBoxDbl; +class QComboBox; + +class VisuGUI_NonIsometricDlg : public QDialog +{ + Q_OBJECT + + public: + VisuGUI_NonIsometricDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_NonIsometricDlg(); + + private: + + QComboBox* m_cbXfunction; + QAD_SpinBoxDbl* m_sbXcoeff; + QLabel* m_lXFunction; + + QComboBox* m_cbYfunction; + QAD_SpinBoxDbl* m_sbYcoeff; + QLabel* m_lYFunction; + + QComboBox* m_cbZfunction; + QAD_SpinBoxDbl* m_sbZcoeff; + QLabel* m_lZFunction; + + //Populates combobox and makes all needed connects + void FillComboBox(QComboBox* cb); + + void FunctionChanged( const QComboBox* cbox); + + private slots: + void onClickApply(); + void onClickReset(); + void onClickOk(); + void onFunctionChanged(); +}; + +#endif // VisuGUI_NONISOMETRICDLG_H diff --git a/src/VISUGUI/VisuGUI_PartialScaDlg.cxx b/src/VISUGUI/VisuGUI_PartialScaDlg.cxx new file mode 100644 index 00000000..e3e8557c --- /dev/null +++ b/src/VISUGUI/VisuGUI_PartialScaDlg.cxx @@ -0,0 +1,119 @@ +using namespace std; +// File : VisuGUI_PartialScaDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_PartialScaDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + Constructor +*/ +VisuGUI_PartialScaDlg::VisuGUI_PartialScaDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_PartialScaDlg" ); + setCaption( tr( "Partial Scale" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + MinLabel = new QLabel( tr( "Min:" ), TopGroup, "MinLabel" ); + MinSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 ); + MinSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinSpin->setMinimumSize( 70, 0 ); + MinSpin->setValue( 0.0 ); + + MaxLabel = new QLabel( tr( "Max:" ), TopGroup, "MaxLabel" ); + MaxSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 ); + MaxSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxSpin->setMinimumSize( 70, 0 ); + MaxSpin->setValue( 0.0 ); + + TopGroupLayout->addWidget( MinLabel, 0, 0 ); + TopGroupLayout->addWidget( MinSpin, 0, 1 ); + TopGroupLayout->addWidget( MaxLabel, 1, 0 ); + TopGroupLayout->addWidget( MaxSpin, 1, 1 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_PartialScaDlg::~VisuGUI_PartialScaDlg() +{ +} + +/*! + Sets min, max values +*/ +void VisuGUI_PartialScaDlg::setMinMax( const double min, const double max ) +{ + MinSpin->setValue( min ); + MaxSpin->setValue( max ); +} + +/*! + Gets min value +*/ +double VisuGUI_PartialScaDlg::getMin() +{ + return MinSpin->value(); +} + +/*! + Gets max value +*/ +double VisuGUI_PartialScaDlg::getMax() +{ + return MaxSpin->value(); +} + diff --git a/src/VISUGUI/VisuGUI_PartialScaDlg.h b/src/VISUGUI/VisuGUI_PartialScaDlg.h new file mode 100644 index 00000000..b1ec05de --- /dev/null +++ b/src/VISUGUI/VisuGUI_PartialScaDlg.h @@ -0,0 +1,41 @@ +// File : VisuGUI_PartialScaDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_PARTIALSCADLG_H +#define VISUGUI_PARTIALSCADLG_H + +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" + +class VisuGUI_PartialScaDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_PartialScaDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_PartialScaDlg(); + + void setMinMax( const double min, const double max ); + double getMin(); + double getMax(); + +private: + QGroupBox* TopGroup; + QLabel* MinLabel; + QAD_SpinBoxDbl* MinSpin; + QLabel* MaxLabel; + QAD_SpinBoxDbl* MaxSpin; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; +}; + +#endif // VISUGUI_PARTIALSCADLG_H diff --git a/src/VISUGUI/VisuGUI_PhaseDlg.cxx b/src/VISUGUI/VisuGUI_PhaseDlg.cxx new file mode 100644 index 00000000..74746811 --- /dev/null +++ b/src/VISUGUI/VisuGUI_PhaseDlg.cxx @@ -0,0 +1,93 @@ +using namespace std; +// File : VisuGUI_PhaseDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_PhaseDlg.h" +#include + +/*! + Constructor +*/ +VisuGUI_PhaseDlg::VisuGUI_PhaseDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_PhaseDlg" ); + setCaption( tr( "Set Phase" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + PhaseLabel = new QLabel( tr( "VISU_MEN_PHASE" ), TopGroup, "PhaseLabel" ); + PhaseSpin = new QAD_SpinBoxDbl( TopGroup, -360.00, 360.00, 1.0 ); + PhaseSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + PhaseSpin->setMinimumSize( 70, 0 ); + PhaseSpin->setValue( 0.0 ); + + TopGroupLayout->addWidget( PhaseLabel, 0, 0 ); + TopGroupLayout->addWidget( PhaseSpin, 0, 1 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_PhaseDlg::~VisuGUI_PhaseDlg() +{ +} + +/*! + Sets phase value +*/ +void VisuGUI_PhaseDlg::setPhase( const double ph ) +{ + PhaseSpin->setValue( ph ); +} + +/*! + Gets phase value +*/ +double VisuGUI_PhaseDlg::getPhase() +{ + return PhaseSpin->value(); +} diff --git a/src/VISUGUI/VisuGUI_PhaseDlg.h b/src/VISUGUI/VisuGUI_PhaseDlg.h new file mode 100644 index 00000000..1a0933c2 --- /dev/null +++ b/src/VISUGUI/VisuGUI_PhaseDlg.h @@ -0,0 +1,38 @@ +// File : VisuGUI_PhaseDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_PHASEDLG_H +#define VISUGUI_PHASEDLG_H + +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" + +class VisuGUI_PhaseDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_PhaseDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_PhaseDlg(); + + void setPhase( const double ph ); + double getPhase(); + +private: + QGroupBox* TopGroup; + QLabel* PhaseLabel; + QAD_SpinBoxDbl* PhaseSpin; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; +}; + +#endif // VISUGUI_PHASEDLG_H diff --git a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx new file mode 100644 index 00000000..b3d6ece2 --- /dev/null +++ b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx @@ -0,0 +1,126 @@ +using namespace std; +// File : VisuGUI_PhaseMagnitudeDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_PhaseMagnitudeDlg.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +/*! + Constructor +*/ +VisuGUI_PhaseMagnitudeDlg::VisuGUI_PhaseMagnitudeDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_PhaseMagnitudeDlg" ); + setCaption( tr( "Phase Magnitude" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + PhaseLabel = new QLabel( tr( "Phase:" ), TopGroup, "PhaseLabel" ); + PhaseSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 ); + PhaseSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + PhaseSpin->setMinimumSize( 70, 0 ); + PhaseSpin->setValue( 0.0 ); + + MagnLabel = new QLabel( tr( "Magnitude:" ), TopGroup, "MagnLabel" ); + MagnSpin = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 ); + MagnSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MagnSpin->setMinimumSize( 70, 0 ); + MagnSpin->setValue( 0.0 ); + + TopGroupLayout->addWidget( PhaseLabel, 0, 0 ); + TopGroupLayout->addWidget( PhaseSpin, 0, 1 ); + TopGroupLayout->addWidget( MagnLabel, 1, 0 ); + TopGroupLayout->addWidget( MagnSpin, 1, 1 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_PhaseMagnitudeDlg::~VisuGUI_PhaseMagnitudeDlg() +{ +} + +/*! + Sets phase value +*/ +void VisuGUI_PhaseMagnitudeDlg::setPhase( const double ph ) +{ + PhaseSpin->setValue( ph ); +} + +/*! + Gets phase value +*/ +double VisuGUI_PhaseMagnitudeDlg::getPhase() +{ + return PhaseSpin->value(); +} + +/*! + Sets magnitude value +*/ +void VisuGUI_PhaseMagnitudeDlg::setMagnitude( const double magn ) +{ + MagnSpin->setValue( magn ); +} + +/*! + Gets magnitude value +*/ +double VisuGUI_PhaseMagnitudeDlg::getMagnitude() +{ + return MagnSpin->value(); +} + diff --git a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h new file mode 100644 index 00000000..0c9baa48 --- /dev/null +++ b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h @@ -0,0 +1,42 @@ +// File : VisuGUI_PhaseMagnitudeDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_PHASEMAGNITUDEDLG_H +#define VISUGUI_PHASEMAGNITUDEDLG_H + +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" + +class VisuGUI_PhaseMagnitudeDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_PhaseMagnitudeDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_PhaseMagnitudeDlg(); + + void setPhase( const double ph ); + double getPhase(); + void setMagnitude( const double magn ); + double getMagnitude(); + +private: + QGroupBox* TopGroup; + QLabel* PhaseLabel; + QAD_SpinBoxDbl* PhaseSpin; + QLabel* MagnLabel; + QAD_SpinBoxDbl* MagnSpin; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; +}; + +#endif // VISUGUI_PHASEMAGNITUDEDLG_H diff --git a/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx b/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx new file mode 100644 index 00000000..7231f86f --- /dev/null +++ b/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx @@ -0,0 +1,122 @@ +using namespace std; +// File : VisuGUI_PointsResultsDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_PointsResultsDlg.h" +#include + +/*! + Constructor +*/ +VisuGUI_PointsResultsDlg::VisuGUI_PointsResultsDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_PointsResultsDlg" ); + setCaption( tr( "Results at selected point" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + GroupLimit = new QGroupBox( this, "GroupLimit" ); + GroupLimit->setTitle( tr( "Results at Point" ) ); + GroupLimit->setColumnLayout(0, Qt::Vertical ); + GroupLimit->layout()->setSpacing( 0 ); + GroupLimit->layout()->setMargin( 0 ); + QGridLayout* GroupLimitLayout = new QGridLayout( GroupLimit->layout() ); + GroupLimitLayout->setAlignment( Qt::AlignTop ); + GroupLimitLayout->setSpacing( 6 ); + GroupLimitLayout->setMargin( 11 ); + + IdPoint = new QLabel( tr( "IdPoint" ), GroupLimit, "IdPoint" ); + QFont IdPoint_font = IdPoint->font(); + IdPoint_font.setBold( TRUE ); + IdPoint->setFont( IdPoint_font ); + IdPoint->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); + IdPoint->setFrameStyle( QLabel::Box | QLabel::Plain ); + IdPoint->setMargin( 5 ); + QHBoxLayout* IdLayout = new QHBoxLayout; + IdLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + IdLayout->addWidget( IdPoint ); + GroupLimitLayout->addMultiCellLayout( IdLayout, 0, 0, 0, 2 ); + + CoordPointX = new QLabel( tr( "X:" ), GroupLimit, "CoordPointX" ); + CoordX = new QLineEdit( GroupLimit ); + CoordX->setReadOnly( true ); + + CoordPointY = new QLabel( tr( "Y:" ), GroupLimit, "CoordPointY" ); + CoordY = new QLineEdit( GroupLimit ); + CoordY->setReadOnly( true ); + + CoordPointZ = new QLabel( tr( "Z:" ), GroupLimit, "CoordPointZ" ); + CoordZ = new QLineEdit( GroupLimit ); + CoordZ->setReadOnly( true ); + + QHBoxLayout* XYZLayout = new QHBoxLayout; XYZLayout->setMargin( 0 ); XYZLayout->setSpacing( 6 ); + XYZLayout->addWidget( CoordPointX ); + XYZLayout->addWidget( CoordX ); + XYZLayout->addWidget( CoordPointY ); + XYZLayout->addWidget( CoordY ); + XYZLayout->addWidget( CoordPointZ ); + XYZLayout->addWidget( CoordZ ); + GroupLimitLayout->addMultiCellLayout( XYZLayout, 1, 1, 0, 2 ); + + GroupLimitLayout->addRowSpacing( 2, 10 ); + + Scalar_Results = new QLabel( tr( "Scalar result :" ), GroupLimit, "Scalar_Results" ); + GroupLimitLayout->addWidget( Scalar_Results, 3, 0 ); + ScalValue = new QLabel( tr( "Scalar Value" ), GroupLimit, "ScalValue" ); + GroupLimitLayout->addWidget( ScalValue, 3, 1 ); + GroupLimitLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 3, 2 ); + + Vector_Results = new QLabel( tr( "Vector result :" ), GroupLimit, "Vector_Results" ); + GroupLimitLayout->addWidget( Vector_Results, 4, 0 ); + VectTxt = new QLabel( tr( "Vector Txt" ), GroupLimit, "VectTxt" ); + GroupLimitLayout->addWidget( VectTxt, 4, 1 ); + GroupLimitLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 4, 2 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 0 ); + GroupButtonsLayout->addWidget( buttonOk, 0, 1 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 2 ); + + TopLayout->addWidget( GroupLimit, 0, 0 ); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); +} + +/*! + Destructor +*/ +VisuGUI_PointsResultsDlg::~VisuGUI_PointsResultsDlg() +{ +} + + + + + + + diff --git a/src/VISUGUI/VisuGUI_PointsResultsDlg.h b/src/VISUGUI/VisuGUI_PointsResultsDlg.h new file mode 100644 index 00000000..76be17c8 --- /dev/null +++ b/src/VISUGUI/VisuGUI_PointsResultsDlg.h @@ -0,0 +1,42 @@ +// File : VisuGUI_PointsResultsDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_POINTSRESULTSDLG_H +#define VISUGUI_POINTSRESULTSDLG_H + +#include +#include +#include +#include +#include + +class VisuGUI_PointsResultsDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_PointsResultsDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_PointsResultsDlg(); + + QGroupBox* GroupLimit; + QLabel* IdPoint; + QLabel* Scalar_Results; + QLabel* ScalValue; + QLabel* Vector_Results; + QLabel* VectTxt; + QLabel* CoordPointX; + QLabel* CoordPointY; + QLabel* CoordPointZ; + QLineEdit* CoordX; + QLineEdit* CoordY; + QLineEdit* CoordZ; + QGroupBox* GroupButtons; + QPushButton* buttonOk; +}; + +#endif // VISUGUI_POINTSRESULTSDLG_H diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx new file mode 100644 index 00000000..26be0c44 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -0,0 +1,651 @@ +using namespace std; +// File : VisuGUI_ScalarBarDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_ScalarBarDlg.h" +#include +#include +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" +#include "VISU_Convertor.hxx" + + +/*! + Constructor +*/ +VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) + : QDialog( QAD_Application::getDesktop(), 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setName( "VisuGUI_ScalarBarDlg" ); + setCaption( SetPref ? tr( "Scalar Bar Preferences" ) : tr( "Scalar Bar Properties" ) ); + setSizeGripEnabled( TRUE ); + + myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80; + myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12; + + QVBoxLayout* TopLayout = new QVBoxLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + // Range ============================================================ + QButtonGroup* RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" ); + RangeGroup->setColumnLayout(0, Qt::Vertical ); + RangeGroup->layout()->setSpacing( 0 ); + RangeGroup->layout()->setMargin( 0 ); + QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() ); + RangeGroupLayout->setAlignment( Qt::AlignTop ); + RangeGroupLayout->setSpacing( 6 ); + RangeGroupLayout->setMargin( 11 ); + + myModeLbl = new QLabel("Scalar Mode", RangeGroup); + + myModeCombo = new QComboBox(RangeGroup); + myModeCombo->insertItem("Modulus"); + myModeCombo->insertItem("Component 1"); + myModeCombo->insertItem("Component 2"); + myModeCombo->insertItem("Component 3"); + + CBLog = new QCheckBox( tr( "Logarithmic scaling" ), RangeGroup ); + CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + RBFrange = new QRadioButton( tr( "Use field range" ), RangeGroup, "RBFrange" ); + RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" ); + RBIrange->setChecked( true ); + + MinSpin = new QAD_SpinBoxDbl( RangeGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MinSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinSpin->setMinimumWidth( 70 ); + MinSpin->setValue( 0 ); + QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" ); + MinLabel->setBuddy(MinSpin); + + MaxSpin = new QAD_SpinBoxDbl( RangeGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MaxSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxSpin->setMinimumWidth( 70 ); + MaxSpin->setValue( 0 ); + QLabel* MaxLabel = new QLabel( tr( "Max:" ), RangeGroup, "MaxLabel" ); + MaxLabel->setBuddy(MaxSpin); + + RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); + RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3); + RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3); + RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1); + RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3); + RangeGroupLayout->addWidget( MinLabel, 3, 0 ); + RangeGroupLayout->addWidget( MinSpin, 3, 1 ); + RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); + RangeGroupLayout->addWidget( MaxSpin, 3, 3 ); + + TopLayout->addWidget( RangeGroup ); + + // Colors and Labels ======================================================== + QGroupBox* ColLabGroup = new QGroupBox( tr( "Colors and labels" ), this, "ColLabGroup" ); + ColLabGroup->setColumnLayout(0, Qt::Vertical ); + ColLabGroup->layout()->setSpacing( 0 ); + ColLabGroup->layout()->setMargin( 0 ); + QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() ); + ColLabGroupLayout->setAlignment( Qt::AlignTop ); + ColLabGroupLayout->setSpacing( 6 ); + ColLabGroupLayout->setMargin( 11 ); + + QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" ); + ColorSpin = new QSpinBox( 2, 64, 1, ColLabGroup ); + ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + ColorSpin->setMinimumWidth( 70 ); + ColorSpin->setValue( 64 ); + + QLabel* LabelLabel = new QLabel( tr( "Nb. of labels:" ), ColLabGroup, "LabelLabel" ); + LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup ); + LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + LabelSpin->setMinimumWidth( 70 ); + LabelSpin->setValue( 5 ); + + ColLabGroupLayout->addWidget( ColorLabel, 0, 0); + ColLabGroupLayout->addWidget( ColorSpin, 0, 1); + ColLabGroupLayout->addWidget( LabelLabel, 0, 2); + ColLabGroupLayout->addWidget( LabelSpin, 0, 3); + + TopLayout->addWidget( ColLabGroup ); + + // Orientation ========================================================== + QButtonGroup* OrientGroup = new QButtonGroup( tr( "Orientation" ), this, "OrientGroup" ); + OrientGroup->setColumnLayout(0, Qt::Vertical ); + OrientGroup->layout()->setSpacing( 0 ); + OrientGroup->layout()->setMargin( 0 ); + QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() ); + OrientGroupLayout->setAlignment( Qt::AlignTop ); + OrientGroupLayout->setSpacing( 6 ); + OrientGroupLayout->setMargin( 11 ); + + RBvert = new QRadioButton( tr( "Vertical" ), OrientGroup, "RBvert" ); + RBvert->setChecked( true ); + RBhori = new QRadioButton( tr( "Horizontal" ), OrientGroup, "RBhori" ); + OrientGroupLayout->addWidget( RBvert, 0, 0 ); + OrientGroupLayout->addWidget( RBhori, 0, 1 ); + + TopLayout->addWidget( OrientGroup ); + + // Origin =============================================================== + QGroupBox* OriginGroup = new QGroupBox( tr( "Origin" ), this, "OriginGroup" ); + OriginGroup->setColumnLayout(0, Qt::Vertical ); + OriginGroup->layout()->setSpacing( 0 ); + OriginGroup->layout()->setMargin( 0 ); + QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() ); + OriginGroupLayout->setAlignment( Qt::AlignTop ); + OriginGroupLayout->setSpacing( 6 ); + OriginGroupLayout->setMargin( 11 ); + + QLabel* XLabel = new QLabel( tr( "X:" ), OriginGroup, "XLabel" ); + XSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 ); + XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + XSpin->setMinimumWidth( 70 ); + XSpin->setValue( 0.01 ); + + QLabel* YLabel = new QLabel( tr( "Y:" ), OriginGroup, "YLabel" ); + YSpin = new QAD_SpinBoxDbl( OriginGroup, 0.0, 1.0, 0.1 ); + YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + YSpin->setMinimumWidth( 70 ); + YSpin->setValue( 0.01 ); + + OriginGroupLayout->addWidget( XLabel, 0, 0); + OriginGroupLayout->addWidget( XSpin, 0, 1); + OriginGroupLayout->addWidget( YLabel, 0, 2); + OriginGroupLayout->addWidget( YSpin, 0, 3); + + TopLayout->addWidget( OriginGroup ); + + // Dimensions ========================================================= + QGroupBox* DimGroup = new QGroupBox( tr( "Dimensions" ), this, "DimGroup" ); + DimGroup->setColumnLayout(0, Qt::Vertical ); + DimGroup->layout()->setSpacing( 0 ); + DimGroup->layout()->setMargin( 0 ); + QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() ); + DimGroupLayout->setAlignment( Qt::AlignTop ); + DimGroupLayout->setSpacing( 6 ); + DimGroupLayout->setMargin( 11 ); + + QLabel* WidthLabel = new QLabel( tr( "Width:" ), DimGroup, "WidthLabel" ); + WidthSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 ); + WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + WidthSpin->setMinimumWidth( 70 ); + WidthSpin->setValue( 0.1 ); + + QLabel* HeightLabel = new QLabel( tr( "Height:" ), DimGroup, "HeightLabel" ); + HeightSpin = new QAD_SpinBoxDbl( DimGroup, 0.0, 1.0, 0.1 ); + HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + HeightSpin->setMinimumWidth( 70 ); + HeightSpin->setValue( 0.8 ); + + DimGroupLayout->addWidget( WidthLabel, 0, 0); + DimGroupLayout->addWidget( WidthSpin, 0, 1); + DimGroupLayout->addWidget( HeightLabel, 0, 2); + DimGroupLayout->addWidget( HeightSpin, 0, 3); + + TopLayout->addWidget( DimGroup ); + + // Save check box =========================================================== + if ( !SetPref ) { + CBSave = new QCheckBox( tr( "Save as default values" ), this, "CBSave" ); + TopLayout->addWidget( CBSave ); + } + else { + CBSave = 0; + } + + // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( GroupButtons ); + + // signals and slots connections =========================================== + connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) ); + connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) ); + connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); + connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + changeRange( 0 ); + changeDefaults( 0 ); +} + +/*! + Destructor +*/ +VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg() +{ +} + + +/** + * Initializes dialog box values from resources + */ +void VisuGUI_ScalarBarDlg::initFromResources() { + int sbCol=64,sbLab=5,orient=1; + float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8; + float sbVmin=0., sbVmax=0.; + bool sbRange=false; + + QString Orientation = QAD_CONFIG->getSetting("Visu:SBOrientation"); + if ( !Orientation.isEmpty() ) { + orient = Orientation.toInt(); + if(orient != 1) { + orient=0; + sbX1=0.2; + sbY1=0.01; + sbW=0.6; + sbH=0.12; + } + } + + QString SBXorigin = QAD_CONFIG->getSetting("Visu:SBXorigin"); + if ( !SBXorigin.isEmpty() ) + sbX1 = SBXorigin.toFloat(); + + QString SBYorigin = QAD_CONFIG->getSetting("Visu:SBYorigin"); + if ( !SBYorigin.isEmpty() ) + sbY1 = SBYorigin.toFloat(); + + QString SBWidth = QAD_CONFIG->getSetting("Visu:SBWidth"); + if ( !SBWidth.isEmpty() ) + sbW = SBWidth.toFloat(); + + QString SBHeight = QAD_CONFIG->getSetting("Visu:SBHeight"); + if ( !SBHeight.isEmpty() ) + sbH = SBHeight.toFloat(); + + QString SBColors = QAD_CONFIG->getSetting("Visu:SBNumberOfColors"); + if ( !SBColors.isEmpty() ) + sbCol = SBColors.toInt(); + + QString SBLabels = QAD_CONFIG->getSetting("Visu:SBNumberOfLabels"); + if ( !SBLabels.isEmpty() ) + sbLab = SBLabels.toInt(); + + QString ImpRange = QAD_CONFIG->getSetting("Visu:SBImposeRange"); + if ( ImpRange.compare("true") == 0 ) + sbRange=true; + + QString SBVmin = QAD_CONFIG->getSetting("Visu:SBMinimumValue"); + if ( !SBVmin.isEmpty() ) + sbVmin = SBVmin.toFloat(); + + QString SBVmax = QAD_CONFIG->getSetting("Visu:SBMaximumValue"); + if ( !SBVmax.isEmpty() ) + sbVmax = SBVmax.toFloat(); + + QString aScaling = QAD_CONFIG->getSetting("Visu:SBScaling"); + if(aScaling.compare("LOGARITHMIC") == 0) + setLogarithmic(true); + else + setLogarithmic(false); + + if((sbX1 < 0.) || (sbY1 < 0.) || + ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { + if(orient == 1) { + sbX1=0.01; + sbY1=0.1; + sbW=0.1; + sbH=0.8; + } else { + sbX1=0.2; + sbY1=0.01; + sbW=0.6; + sbH=0.12; + } + } + if(sbCol < 2) sbCol=2; + if(sbCol > 64) sbCol=64; + if(sbLab < 2) sbLab=2; + if(sbLab > 65) sbLab=65; + + if(sbVmin > sbVmax) { + sbVmin=0.; + sbVmax=0.; + } + + setRange( sbVmin, sbVmax, 0.0, 0.0, sbRange ); + setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1); + setScalarBarData( sbCol, sbLab ); +} + + + +/** + * Stores dialog values to resources + */ +void VisuGUI_ScalarBarDlg::storeToResources() { + int orient = (RBvert->isChecked())? 1 : 0; + float sbX1 = XSpin->value(); + float sbY1 = YSpin->value(); + float sbW = WidthSpin->value(); + float sbH = HeightSpin->value(); + int sbCol = ColorSpin->value(); + int sbLab = LabelSpin->value(); + + if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { + if(orient == 1) { + sbX1=0.01; + sbY1=0.1; + sbW=0.17; + sbH=0.8; + } else { + sbX1=0.2; + sbY1=0.01; + sbW=0.6; + sbH=0.12; + } + } + + bool sbRange = RBIrange->isChecked(); + float sbVmin = MinSpin->value(); + float sbVmax = MaxSpin->value(); + + if(sbVmin > sbVmax) { + sbVmin=0.; + sbVmax=0.; + } + + QAD_CONFIG->addSetting("Visu:SBOrientation",orient); + QAD_CONFIG->addSetting("Visu:SBXorigin",sbX1); + QAD_CONFIG->addSetting("Visu:SBYorigin",sbY1); + QAD_CONFIG->addSetting("Visu:SBWidth",sbW); + QAD_CONFIG->addSetting("Visu:SBHeight",sbH); + QAD_CONFIG->addSetting("Visu:SBNumberOfColors",sbCol); + QAD_CONFIG->addSetting("Visu:SBNumberOfLabels",sbLab); + if(sbRange) + QAD_CONFIG->addSetting("Visu:SBImposeRange", "true"); + else + QAD_CONFIG->addSetting("Visu:SBImposeRange", "false"); + QAD_CONFIG->addSetting("Visu:SBMinimumValue",sbVmin); + QAD_CONFIG->addSetting("Visu:SBMaximumValue",sbVmax); + if(isLogarithmic()) + QAD_CONFIG->addSetting("Visu:SBScaling", "LOGARITHMIC"); + else + QAD_CONFIG->addSetting("Visu:SBScaling", "LINEAR"); +} + + +/** + * Initialise dialog box from presentation object + */ +void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) { + myModeCombo->setCurrentItem(thePrs->GetScalarMode()); + setPosAndSize( thePrs->GetPosX(), + thePrs->GetPosY(), + thePrs->GetWidth(), + thePrs->GetHeight(), + thePrs->GetOrientation()); + switch(thePrs->GetScaling()){ + case VISU::LOGARITHMIC : + setLogarithmic(true); + break; + default: + setLogarithmic(false); + } + setRange( thePrs->GetMin(), thePrs->GetMax(), + 0.0, 0.0, thePrs->isRangeFixed() ); + setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() ); + bool isScalarMode = (thePrs->GetField()->myNbComp > 1); + myModeLbl->setEnabled(isScalarMode); + myModeCombo->setEnabled(isScalarMode); +} + + +/** + * Store values to presentation object + */ +void VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) { + thePrs->SetScalarMode(myModeCombo->currentItem()); + thePrs->SetPosition(XSpin->value(), YSpin->value()); + thePrs->SetSize(WidthSpin->value(), HeightSpin->value()); + thePrs->SetOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL); + if(isLogarithmic()) + thePrs->SetScaling(VISU::LOGARITHMIC); + else + thePrs->SetScaling(VISU::LINEAR); + if (RBFrange->isChecked()) { + thePrs->CalculateRange(); + } else { + thePrs->SetRange(MinSpin->value(), MaxSpin->value()); + } + thePrs->SetNbColors(ColorSpin->value()); + thePrs->SetLabels(LabelSpin->value()); + thePrs->Update(); + + if (isToSave()) storeToResources(); +} + + + +/*! + Called when orientation is changed +*/ +void VisuGUI_ScalarBarDlg::changeDefaults( int ) +{ + if ( RBvert->isChecked() ) { + XSpin->setValue( myVerX ); + YSpin->setValue( myVerY ); + WidthSpin->setValue( myVerW ); + HeightSpin->setValue( myVerH ); + } + else { + XSpin->setValue( myHorX ); + YSpin->setValue( myHorY ); + WidthSpin->setValue( myHorW ); + HeightSpin->setValue( myHorH ); + } +} + +/*! + Called when Range mode is changed +*/ +void VisuGUI_ScalarBarDlg::changeRange( int ) +{ + //MinSpin->setMaxValue( Fmin ); + //MaxSpin->setMinValue( Fmax ); + if ( RBFrange->isChecked() ) { + //MinLabel->setEnabled( false ); + MinSpin->setEnabled( false ); + //MaxLabel->setEnabled( false ); + MaxSpin->setEnabled( false ); + MinSpin->setValue( Fmin ); + MaxSpin->setValue( Fmax ); + } + else { + //MinLabel->setEnabled( true ); + MinSpin->setEnabled( true ); + //MaxLabel->setEnabled( true ); + MaxSpin->setEnabled( true ); + MinSpin->setValue( Imin ); + MaxSpin->setValue( Imax ); + } +} + +/*! + Called when X,Y position is changed +*/ +void VisuGUI_ScalarBarDlg::XYChanged( double ) +{ + QAD_SpinBoxDbl* snd = (QAD_SpinBoxDbl*)sender(); + if ( snd == XSpin ) { + WidthSpin->setMaxValue( 1.0 - XSpin->value() ); + } + if ( snd == YSpin ) { + HeightSpin->setMaxValue( 1.0 - YSpin->value() ); + } +} + +/*! + Sets default values and range mode +*/ +void VisuGUI_ScalarBarDlg::setRange( double imin, double imax, double fmin, double fmax, bool sbRange ) +{ + Imin = imin; Imax = imax; Fmin = fmin; Fmax = fmax; + if( sbRange ) + RBIrange->setChecked( true ); + else + RBFrange->setChecked( true ); + changeRange( 0 ); +} + +/*! + Sets size and position +*/ +void VisuGUI_ScalarBarDlg::setPosAndSize( double x, double y, double w, double h, bool vert ) +{ + if ( vert ) { + myVerX = x; + myVerY = y; + myVerW = w; + myVerH = h; + RBvert->setChecked( true ); + } + else { + myHorX = x; + myHorY = y; + myHorW = w; + myHorH = h; + RBhori->setChecked( true ); + } + changeDefaults( 0 ); +} + +/*! + Sets colors and labels number +*/ +void VisuGUI_ScalarBarDlg::setScalarBarData( int colors, int labels ) +{ + ColorSpin->setValue( colors ); + LabelSpin->setValue( labels ); +} + +/*! + Gets orientation +*/ +int VisuGUI_ScalarBarDlg::getOrientation() +{ + if (RBvert->isChecked() ) + return 1; + else + return 0; +} + +/*! + Gets Scalar Bar's x position +*/ +double VisuGUI_ScalarBarDlg::getX() +{ + return XSpin->value(); +} + +/*! + Gets Scalar Bar's y position +*/ +double VisuGUI_ScalarBarDlg::getY() +{ + return YSpin->value(); +} + +/*! + Gets Scalar Bar's width +*/ +double VisuGUI_ScalarBarDlg::getWidth() +{ + return WidthSpin->value(); +} + +/*! + Gets Scalar Bar's height +*/ +double VisuGUI_ScalarBarDlg::getHeight() +{ + return HeightSpin->value(); +} + +/*! + Gets Scalar Bar's number of colors +*/ +int VisuGUI_ScalarBarDlg::getNbColors() +{ + return ColorSpin->value(); +} + +/*! + Gets Scalar Bar's number of labels +*/ +int VisuGUI_ScalarBarDlg::getNbLabels() +{ + return LabelSpin->value(); +} + +/*! + Returns true if imposed range is used +*/ +bool VisuGUI_ScalarBarDlg::isIRange() +{ + return RBIrange->isChecked(); +} + +/*! + Gets Min value +*/ +double VisuGUI_ScalarBarDlg::getMin() +{ + return MinSpin->value(); +} + +/*! + Gets Max value +*/ +double VisuGUI_ScalarBarDlg::getMax() +{ + return MaxSpin->value(); +} + +/*! + return true if "save pref" flag is on +*/ +bool VisuGUI_ScalarBarDlg::isToSave() +{ + return CBSave ? CBSave->isChecked() : false; +} + +/*! + Returns true if "Logarithmic scaling" check box is on +*/ +bool VisuGUI_ScalarBarDlg::isLogarithmic() +{ + return CBLog->isChecked(); +} + +/*! + Sets "Logarithmic scaling" check box on/off +*/ +void VisuGUI_ScalarBarDlg::setLogarithmic( bool on ) +{ + CBLog->setChecked( on ); +} diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h new file mode 100644 index 00000000..ec665bb8 --- /dev/null +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -0,0 +1,92 @@ +// File : VisuGUI_ScalarBarDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_SCALARBARDLG_H +#define VISUGUI_SCALARBARDLG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "QAD_SpinBoxDbl.h" +#include "VISU_PrsObject_i.hh" + + +class VisuGUI_ScalarBarDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_ScalarBarDlg( bool SetPref = FALSE ); + ~VisuGUI_ScalarBarDlg(); + + void setRange( double imin, double imax, double fmin, double fmax, bool sbRange ); + bool isIRange(); + double getMin(); + double getMax(); + int getOrientation(); + void setPosAndSize( double x, double y, double w, double h, bool vert ); + double getX(); + double getY(); + double getWidth(); + double getHeight(); + void setScalarBarData( int colors, int labels ); + int getNbColors(); + int getNbLabels(); + bool isLogarithmic(); + void setLogarithmic( bool on ); + bool isToSave(); + + void initFromResources(); + void storeToResources(); + + void initFromPrsObject(VISU::ScalarMap_i* thePrs); + void storeToPrsObject(VISU::ScalarMap_i* thePrs); + + +protected: + QRadioButton* RBFrange; + QRadioButton* RBIrange; + QAD_SpinBoxDbl* MinSpin; + QAD_SpinBoxDbl* MaxSpin; + + QRadioButton* RBhori; + QRadioButton* RBvert; + + QAD_SpinBoxDbl* XSpin; + QAD_SpinBoxDbl* YSpin; + + QAD_SpinBoxDbl* WidthSpin; + QAD_SpinBoxDbl* HeightSpin; + + QSpinBox* ColorSpin; + QSpinBox* LabelSpin; + + QCheckBox* CBSave; + QCheckBox* CBLog; + QLabel* myModeLbl; + QComboBox* myModeCombo; + + double Imin, Imax, Fmin, Fmax; + double myHorX, myHorY, myHorW, myHorH; + double myVerX, myVerY, myVerW, myVerH; + +private slots: + void changeDefaults( int ); + void changeRange( int ); + void XYChanged( double ); +}; + +#endif // VISUGUI_SCALARBARDLG_H diff --git a/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx b/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx new file mode 100644 index 00000000..9644578d --- /dev/null +++ b/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx @@ -0,0 +1,109 @@ +using namespace std; +// File : VisuGUI_SelVectCompDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_SelVectCompDlg.h" +#include + +/*! + Constructor +*/ +VisuGUI_SelVectCompDlg::VisuGUI_SelVectCompDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_SelVectCompDlg" ); + setCaption( tr( "Vector Field" ) ); + setSizeGripEnabled( true ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + Comment1_2 = new QLabel( tr( "Select a component of the vector, or modulus," ), this, "Comment1_2" ); + Comment1_2->setAlignment( AlignCenter ); + + Comment2_2 = new QLabel( tr( "to be displayed as a scalar result" ), this, "Comment2_2" ); + Comment2_2->setAlignment( AlignCenter ); + + SelComp = new QButtonGroup( this, "SelComp" ); + SelComp->setColumnLayout(0, Qt::Vertical ); + SelComp->layout()->setSpacing( 0 ); + SelComp->layout()->setMargin( 0 ); + QGridLayout* SelCompLayout = new QGridLayout( SelComp->layout() ); + SelCompLayout->setAlignment( Qt::AlignTop ); + SelCompLayout->setSpacing( 6 ); + SelCompLayout->setMargin( 11 ); + + Comp1 = new QRadioButton( tr( "Component 1" ), SelComp, "Comp1" ); + SelCompLayout->addWidget( Comp1, 0, 0 ); + + Modulus = new QRadioButton( tr( "Modulus" ), SelComp, "Modulus" ); + Modulus->setChecked( TRUE ); + SelCompLayout->addWidget( Modulus, 0, 1 ); + + Comp2 = new QRadioButton( tr( "Component 2" ), SelComp, "Comp2" ); + SelCompLayout->addWidget( Comp2, 1, 0 ); + + Comp3 = new QRadioButton( tr( "Component 3" ), SelComp, "Comp3" ); + SelCompLayout->addWidget( Comp3, 2, 0 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( Comment1_2, 0, 0 ); + TopLayout->addWidget( Comment2_2, 1, 0 ); + TopLayout->addWidget( SelComp, 2, 0 ); + TopLayout->addWidget( GroupButtons, 3, 0 ); + + // signals and slots connections + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_SelVectCompDlg::~VisuGUI_SelVectCompDlg() +{ +} + +/*! + Gets selection +*/ +int VisuGUI_SelVectCompDlg::whatIsChecked() +{ + int ret = 0; + if ( Modulus->isChecked() ) + ret = 0; + else if ( Comp1->isChecked() ) + ret = 1; + else if ( Comp2->isChecked() ) + ret = 2; + else if ( Comp3->isChecked() ) + ret = 3; + return ret; +} + diff --git a/src/VISUGUI/VisuGUI_SelVectCompDlg.h b/src/VISUGUI/VisuGUI_SelVectCompDlg.h new file mode 100644 index 00000000..f11ad40d --- /dev/null +++ b/src/VISUGUI/VisuGUI_SelVectCompDlg.h @@ -0,0 +1,42 @@ +// File : VisuGUI_SelVectCompDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_SELVECTCOMPDLG_H +#define VISUGUI_SELVECTCOMPDLG_H + +#include +#include +#include +#include +#include +#include + +class VisuGUI_SelVectCompDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_SelVectCompDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_SelVectCompDlg(); + + int whatIsChecked(); + +private: + QLabel* Comment1_2; + QLabel* Comment2_2; + QButtonGroup* SelComp; + QRadioButton* Comp1; + QRadioButton* Modulus; + QRadioButton* Comp2; + QRadioButton* Comp3; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; +}; + +#endif // VISUGUI_SELVECTCOMPDLG_H diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx new file mode 100644 index 00000000..8e72c078 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -0,0 +1,356 @@ +using namespace std; +// File : VisuGUI_Selection.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "utilities.h" +#include +#include +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SALOME_Selection.h" +#include "VISU_Actor.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "VisuGUI_CellsResultsDlg.h" +#include "VisuGUI_PointsResultsDlg.h" +#include "VisuGUI_Selection.h" + + int mode=0; + int scal=0; + int vect=0; + char Msg[80]=""; + + int id=0; + char Msg_1[150]=""; + char Msg_2[150]=""; + float Coord[3]; + float ScalarValue=0; + float VectorValue[3]; + +int VisuGUI_Selection::PickViewer(QAD_Study *ActiveStudy, int mode) +{ + SALOME_Selection *Sel = SALOME_Selection::Selection(ActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(;It.More();It.Next()) + { + Handle(SALOME_InteractiveObject)IObject = It.Value(); + if (Sel->SelectionMode() == mode ) // Selection MODE + { + if (Sel->HasIndex(IObject)) + { + TColStd_MapOfInteger MapIndex ; + Sel->GetIndex(IObject, MapIndex) ; + TColStd_MapIteratorOfMapOfInteger ite(MapIndex); + for (;ite.More(); ite.Next()) + { + MESSAGE("Cell ID =" << ite.Key()) + return (ite.Key()); + } + } + } + } + return (-1); +} + +void VisuGUI_Selection::PickingResults(QAD_Study *ActiveStudy, int mode, VISU_Actor *Actor) +{ + + if ( (mode == SelectionCell) || (mode == SelectionEdge) ) // Cell mode + { + PickingCell(ActiveStudy, Actor); + } + + else if (mode == SelectionPoint) // Point Mode + { + PickingPoint(ActiveStudy, Actor); + } +} + +// ============================================================================================ // +// PICKING CELL // +// ============================================================================================ // + +void VisuGUI_Selection::PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor) +{ + vtkDataSet *Data ; + vtkScalars *Scalar; + vtkVectors *Vector; + vtkCell *Cell; + vtkIdList *PointList; + vtkCellData *CellData; + vtkPointData *PointData; + vtkPoints *Points = vtkPoints::New(); + float Point_Coord[12][3]; + float CoordCurrent[3]; + int idCurrent; + + mode = SelectionCell; + + vtkActor* anActor = vtkActor::SafeDownCast( Actor ); + id=PickViewer(ActiveStudy,mode); + if (id >= 0) // Cell exist + { + VisuGUI_CellsResultsDlg *ResultsDlg = new VisuGUI_CellsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); + + vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (anActor->GetMapper()); + Mapper->SetInput(anActor->GetMapper()->GetInput()); + Data=Mapper->GetInput(); + Cell=Data->GetCell(id); + CellData=Data->GetCellData(); + int NbOfPoints=Cell->GetNumberOfPoints(); + PointList=Cell->GetPointIds(); + QListViewItem* item = 0; + for(int i=0; iGetId(i); + Data->GetPoint(idCurrent,CoordCurrent); + for (int j=0; j<3; j++) + Point_Coord[i][j]=CoordCurrent[j]; + item = new QListViewItem(ResultsDlg->ListPoints, + item, + QString::number( idCurrent ), + QString::number( Point_Coord[i][0] ), + QString::number( Point_Coord[i][1] ), + QString::number( Point_Coord[i][2] )); + } + + // Scalar result + Scalar=CellData->GetScalars(); + if (Scalar!=NULL) + { + scal = 1; + ScalarValue=Scalar->GetScalar(id); + sprintf(Msg_1,"( %s ) %4f",Actor->FieldName,ScalarValue); + } + else + { + scal = 2; + sprintf(Msg_1,"No scalar on Cell"); + } + + // Vector result + Vector=CellData->GetVectors(); + if (Vector!=NULL) + { + vect = 1; + Vector->GetVector(id,VectorValue); + sprintf(Msg_2,"( %s ) %.4f %.4f %.4f",Actor->FieldName,VectorValue[0],VectorValue[1],VectorValue[2]); + } + else + { + vect = 2; + sprintf(Msg_2,"No Vector on Cell"); + } + + ResultsDlg->IdCell->setText( QString::number( id ) ); + ResultsDlg->NbPoint->setText( QString::number( NbOfPoints ) ); + ResultsDlg->ScalValue->setText( Msg_1 ); + ResultsDlg->VectTxt->setText( Msg_2 ); + ResultsDlg->exec(); + delete ResultsDlg; + } +} + + +// ============================================================================================ // +// PICKING POINT // +// ============================================================================================ // + +void VisuGUI_Selection::PickingPoint(QAD_Study *ActiveStudy, VISU_Actor *Actor) +{ + vtkDataSet *Data ; + vtkScalars *Scalar; + vtkVectors *Vector; + vtkPointData *PointData; + + mode = SelectionPoint; + + id=PickViewer(ActiveStudy,mode); + if (id >= 0) + { + VisuGUI_PointsResultsDlg *ResultsDlg = new VisuGUI_PointsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); + vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (Actor->GetMapper()); + Data=Mapper->GetInput(); + PointData=Data->GetPointData(); + + Data->GetPoint(id,Coord); + ResultsDlg->CoordX->setText( QString::number( Coord[0] ) ); + ResultsDlg->CoordY->setText( QString::number( Coord[1] ) ); + ResultsDlg->CoordZ->setText( QString::number( Coord[2] ) ); +// ActiveStudy->setMessage(Msg); + + Scalar=PointData->GetScalars(); + if (Scalar!=NULL) + { + scal = 1; + ScalarValue=Scalar->GetScalar(id); + sprintf(Msg_1,"( %s ) %4f",Actor->FieldName,ScalarValue); + } + else + { + scal = 2; + sprintf(Msg_1,"No scalar at Point"); + } +// ActiveStudy->setMessage(Msg_1); + + // Vector result + Vector=PointData->GetVectors(); + if (Vector!=NULL) + { + vect = 1; + Vector->GetVector(id,VectorValue); + sprintf(Msg_2,"( %s ) %.4f %.4f %.4f",Actor->FieldName,VectorValue[0],VectorValue[1],VectorValue[2]); + } + else + { + vect = 2; + sprintf(Msg_2,"No Vector at Point"); + } + ResultsDlg->IdPoint->setText( QString::number(id) ); + ResultsDlg->ScalValue->setText(Msg_1); + ResultsDlg->VectTxt->setText(Msg_2); + ResultsDlg->exec(); + delete ResultsDlg; + +// ActiveStudy->setMessage( Msg_2 ) ; + } +} + +// ============================================================================================ // +// HIGHLIGHT CELL // +// ============================================================================================ // +// +void VisuGUI_Selection::HighlightCell(int idCell, VISU_Actor *Actor, vtkRenderer *ren) +{ + MESSAGE("HighlightCell") + vtkActor *Cell_Actor = vtkActor::New(); + + vtkUnstructuredGrid* Cell_UGrid = vtkUnstructuredGrid::New(); + if ( Actor->GetMapper()->GetInput()->IsA("vtkUnstructuredGrid") ) { + vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( Actor->GetMapper()->GetInput() ); +// if (UGrid != NULL) // LCO 1707 +// { + vtkIdList *ptIds = vtkIdList::New(); ptIds->Allocate(12); + vtkDataSetMapper* Cell_Mapper = vtkDataSetMapper::New(); + + Cell_UGrid->SetPoints( UGrid->GetPoints() ); + UGrid->GetCellPoints( idCell, ptIds ); + Cell_UGrid->InsertNextCell(Actor->GetMapper()->GetInput()->GetCellType( idCell ), ptIds); + + Cell_Mapper->SetInput(Cell_UGrid); + Cell_Actor->SetMapper(Cell_Mapper); + + ren->AddActor( Cell_Actor ); + + Cell_Actor->GetProperty()->SetColor(1,1,0); + Cell_Actor->GetProperty()->SetRepresentationToSurface(); + Cell_Actor->VisibilityOn(); + + ren->Render(); + } // LCO + Cell_Actor->Delete(); +} + +// ============================================================================================ // +// HIGHLIGHT POINT // +// ============================================================================================ // +// +void VisuGUI_Selection::HighlightPoint(int idPoint, int nbPoints, VISU_Actor *Actor, vtkRenderer *ren) +{ + vtkActor *Point_Actor = vtkActor::New(); + + MESSAGE("HighlightPoint") + if ( Actor->GetMapper()->GetInput()->IsA("vtkUnstructuredGrid") ) { + vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( Actor->GetMapper()->GetInput() ); +// if (UGrid != NULL) // LCO 1707 +// { + vtkUnstructuredGrid* Point_UGrid = vtkUnstructuredGrid::New(); + float pts[3]; + + vtkPoints *Points = vtkPoints::New(); + vtkMaskPoints* verts = vtkMaskPoints::New(); + vtkPolyDataMapper* vertMapper = vtkPolyDataMapper::New(); + Points->SetNumberOfPoints(nbPoints); + + UGrid->GetPoint( idPoint, pts) ; + // Points->SetPoint(idPoint, 0., 0., 0. ); + Points->SetPoint(idPoint, pts); + Point_UGrid->SetPoints(Points); + verts->SetInput(Point_UGrid); + verts->SetGenerateVertices(1); + verts->SetOnRatio(1); + vertMapper->SetInput(verts->GetOutput()); + Point_Actor->SetMapper(vertMapper); + ren->AddActor( Point_Actor ); + Point_Actor->GetProperty()->SetColor(1,1,0); + Point_Actor->GetProperty()->SetRepresentationToSurface(); + Point_Actor->VisibilityOn(); + ren->Render(); + } //LCO + Point_Actor->Delete(); +} + +// ============================================================================================ // +// Function to return results individual // +// ============================================================================================ // + +int VisuGUI_Selection::getId() +{ + return (id); +} + +char *VisuGUI_Selection::getMsg(int nb) +{ + if (nb==1) + return (Msg_1); + else + return (Msg_2); +} + +float *VisuGUI_Selection::getCoord() +{ + return (Coord); +} + +float VisuGUI_Selection::getScalar() +{ + if (scal == 1) + return (ScalarValue); + else + return (0); +} + +float *VisuGUI_Selection::getVector() +{ + if (vect == 1) + return (VectorValue); + else + return (0); +} + +int VisuGUI_Selection::getMode() +{ + return (mode ); +} diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h new file mode 100644 index 00000000..c4aeed1b --- /dev/null +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -0,0 +1,73 @@ +// File : VisuGUI_Selection.h +// Created : Wed Apr 03 10:23:06 2002 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VisuGUI_Selection_HeaderFile +#define VisuGUI_Selection_HeaderFile + +#ifndef _Standard_HeaderFile +#include +#endif + +#include "QAD_Desktop.h" +#include +#include + +#include +#include "VISU_Actor.h" + +#define SelectionPoint 1 +#define SelectionEdge 2 +#define SelectionCell 3 +#define SelectionActor 4 + +class VisuGUI_Selection +{ + +public : + +// Methods PUBLIC +// +// + +int PickViewer(QAD_Study *ActiveStudy, int mode); +void PickingResults(QAD_Study *ActiveStudy, int mode, VISU_Actor *Actor); + +void PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor); +void PickingPoint(QAD_Study *ActiveStudy, VISU_Actor *Actor); +void HighlightCell(int idCell, VISU_Actor *Actor, vtkRenderer *ren); +void HighlightPoint(int idPoint, int nbPoints, VISU_Actor *Actor, vtkRenderer *ren); + +int getId(); +char *getMsg(int nb); +float *getCoord(); +float getScalar(); +float *getVector(); +int getMode(); + +protected: + + // Methods PROTECTED + // + + + // Fields PROTECTED + // + + +private: + + // Methods PRIVATE + // + + + // Fields PRIVATE + // + +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx new file mode 100644 index 00000000..aaa91c6f --- /dev/null +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -0,0 +1,175 @@ +// File : VisuGUI_StreamLinesDlg.cxx +// Created : 06 / 03 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : VISUGUI +// Copyright : Open CASCADE + + +#include "VisuGUI_StreamLinesDlg.h" +#include +#include +#include +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_Config.h" + + +VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg() + : QDialog( QAD_Application::getDesktop(), "VisuGUI_StreamLinesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption("Stream lines Preferences"); + setSizeGripEnabled( TRUE ); + + QGridLayout* TopLayout = new QGridLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + QLabel* aStepLenLbl = new QLabel( tr( "Step Length" ), this); + TopLayout->addWidget(aStepLenLbl, 0, 0); + myStepLen = new QAD_SpinBoxDbl( this); + myStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TopLayout->addWidget(myStepLen, 0, 1); + + QLabel* aIntegStepLenLbl = new QLabel( tr( "Integration Step" ), this); + TopLayout->addWidget(aIntegStepLenLbl, 1, 0); + myIntegStepLen = new QAD_SpinBoxDbl( this); + myIntegStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TopLayout->addWidget(myIntegStepLen, 1, 1); + + QLabel* aPropagationLbl = new QLabel( tr( "Propagation Time" ), this); + TopLayout->addWidget(aPropagationLbl, 2, 0); + myPropTime = new QAD_SpinBoxDbl( this, 0, 1000, 10); + myPropTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TopLayout->addWidget(myPropTime, 2, 1); + + QLabel* aDirLbl = new QLabel( tr( "Direction" ), this); + TopLayout->addWidget(aDirLbl, 3, 0); + myDirCombo = new QComboBox(this); + myDirCombo->insertItem("Forward"); + myDirCombo->insertItem("Backward"); + myDirCombo->insertItem("Both"); + TopLayout->addWidget(myDirCombo, 3, 1); + + myUseScalar = new QCheckBox( tr( "Magnitude coloring" ), this, "UseMagn" ); + // TopLayout->addMultiCellWidget(myUseScalar, 4, 4, 0, 1); + connect( myUseScalar, SIGNAL( clicked() ), this, SLOT( enableSetColor() ) ); + TopLayout->addWidget(myUseScalar, 4, 0); + + SelColor = new QPushButton( tr( "Use Color" ), this, "SelColor" ); + connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) ); + TopLayout->addWidget( SelColor, 4, 1); + + QGroupBox* aGroupButtons = new QGroupBox( this, "GroupButtons" ); + aGroupButtons->setColumnLayout(0, Qt::Vertical ); + aGroupButtons->layout()->setSpacing( 0 ); + aGroupButtons->layout()->setMargin( 0 ); + + QGridLayout* aGroupButtonsLayout = new QGridLayout( aGroupButtons->layout() ); + aGroupButtonsLayout->setAlignment( Qt::AlignTop ); + aGroupButtonsLayout->setSpacing( 6 ); + aGroupButtonsLayout->setMargin( 11 ); + + QPushButton* aOkBtn = new QPushButton( tr( "&OK" ), aGroupButtons, "buttonOk" ); + aOkBtn->setAutoDefault( TRUE ); + aOkBtn->setDefault( TRUE ); + aGroupButtonsLayout->addWidget( aOkBtn, 0, 0 ); + aGroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* aCancelBtn = new QPushButton( tr( "&Cancel" ) , aGroupButtons, "buttonCancel" ); + aCancelBtn->setAutoDefault( TRUE ); + aGroupButtonsLayout->addWidget( aCancelBtn, 0, 2 ); + connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); + TopLayout->addMultiCellWidget( aGroupButtons, 5, 5, 0, 1 ); + enableSetColor(); +} + + + +void VisuGUI_StreamLinesDlg::initFromPrsObject(VISU::StreamLines_i* thePrs) { + myStepLen->setValue(thePrs->GetStepLength()); + myIntegStepLen->setValue(thePrs->GetIntegrationStep()); + myPropTime->setValue(thePrs->GetPropagationTime()); + switch (thePrs->GetDirection()) { + case VISU::StreamLines::FORWARD: + myDirCombo->setCurrentItem(0); + break; + case VISU::StreamLines::BACKWARD: + myDirCombo->setCurrentItem(1); + break; + case VISU::StreamLines::BOTH: + myDirCombo->setCurrentItem(2); + } + myUseScalar->setChecked(thePrs->isColored()); + + setColor(QColor(thePrs->GetColor()[0]*255, + thePrs->GetColor()[1]*255, + thePrs->GetColor()[2]*255)); + enableSetColor(); +} + + + +void VisuGUI_StreamLinesDlg::storeToPrsObject(VISU::StreamLines_i* thePrs) { + thePrs->SetStepLength(myStepLen->value()); + thePrs->SetIntegrationStep(myIntegStepLen->value()); + thePrs->SetPropagationTime(myPropTime->value()); + switch (myDirCombo->currentItem()) { + case 0: + thePrs->SetDirection(VISU::StreamLines::FORWARD); + break; + case 1: + thePrs->SetDirection(VISU::StreamLines::BACKWARD); + break; + case 2: + thePrs->SetDirection(VISU::StreamLines::BOTH); + } + thePrs->setColored(myUseScalar->isChecked()); + + float aColor[3]; + aColor[0] = myColor.red()/255.; + aColor[1] = myColor.green()/255.; + aColor[2] = myColor.blue()/255.; + + thePrs->SetColor(aColor); +} + +/*! + Sets color +*/ +void VisuGUI_StreamLinesDlg::setColor( QColor color ) +{ + myColor = color; + SelColor->setPaletteBackgroundColor(myColor); +} + + +/*! + Called when "Select Color" buttonx clicked +*/ +void VisuGUI_StreamLinesDlg::setVColor() +{ + QColor cnew = QColorDialog::getColor( myColor, this ); + if ( cnew.isValid() ) + setColor( cnew ); +} + + +/*! + Enbled/disables magnitude coloring +*/ +void VisuGUI_StreamLinesDlg::enableMagnColor( bool enable ) +{ + myUseScalar->setEnabled( enable ); + enableSetColor(); +} + +/*! + Called when "Magnitude Coloring" check box clicked +*/ +void VisuGUI_StreamLinesDlg::enableSetColor() +{ + SelColor->setEnabled(!myUseScalar->isChecked() ); +} + diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.h b/src/VISUGUI/VisuGUI_StreamLinesDlg.h new file mode 100644 index 00000000..94a6a1b0 --- /dev/null +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.h @@ -0,0 +1,45 @@ +// File : VisuGUI_StreamLinesDlg.h +// Created : 06 / 03 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : VISUGUI +// Copyright : Open CASCADE + + +#ifndef VISUGUI_STREAMLINESDLG_H +#define VISUGUI_STREAMLINESDLG_H + +#include +#include +#include +#include "QAD_SpinBoxDbl.h" +#include "VISU_PrsObject_i.hh" + + +class VisuGUI_StreamLinesDlg: public QDialog +{ + Q_OBJECT +public: + VisuGUI_StreamLinesDlg(); + ~VisuGUI_StreamLinesDlg() {}; + + void initFromPrsObject(VISU::StreamLines_i* thePrs); + void storeToPrsObject(VISU::StreamLines_i* thePrs); + void setColor( QColor color ); + void enableMagnColor( bool enable ); + +private: + QAD_SpinBoxDbl* myStepLen; + QAD_SpinBoxDbl* myIntegStepLen; + QAD_SpinBoxDbl* myPropTime; + QComboBox* myDirCombo; + QCheckBox* myUseScalar; + QPushButton* SelColor; + QColor myColor; + +private slots: + void setVColor(); + void enableSetColor(); +}; + +#endif //VISUGUI_STREAMLINESDLG_H diff --git a/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx b/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx new file mode 100644 index 00000000..afce7cfc --- /dev/null +++ b/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx @@ -0,0 +1,141 @@ +using namespace std; +// File : VisuGUI_SweepPrefDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_SweepPrefDlg.h" +#include + +/*! + Constructor +*/ +VisuGUI_SweepPrefDlg::VisuGUI_SweepPrefDlg( QWidget* parent, const char* name, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_SweepPrefDlg" ); + setCaption( tr( "Sweeping Preferences" ) ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + TimeLabel = new QLabel( tr( "Time step (second):" ), TopGroup, "TimeLabel" ); + TimeSpin = new QAD_SpinBoxDbl( TopGroup, 0.1, 1000.0, 0.1 ); + TimeSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TimeSpin->setMinimumSize( 70, 0 ); + TimeSpin->setValue( 0.2 ); + + CyclesLabel = new QLabel( tr( "Number of cycles:" ), TopGroup, "CyclesLabel" ); + CyclesSpin = new QSpinBox( 1, 100, 1, TopGroup, "CyclesSpin" ); + CyclesSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + CyclesSpin->setMinimumSize( 70, 0 ); + CyclesSpin->setValue( 1 ); + + StepsLabel = new QLabel( tr( "Number of steps:" ), TopGroup, "StepsLabel" ); + StepsSpin = new QSpinBox( 1, 200, 1, TopGroup, "StepsSpin" ); + StepsSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + StepsSpin->setMinimumSize( 70, 0 ); + StepsSpin->setValue( 20 ); + + TopGroupLayout->addWidget( TimeLabel, 0, 0 ); + TopGroupLayout->addWidget( TimeSpin, 0, 1 ); + TopGroupLayout->addWidget( CyclesLabel, 1, 0 ); + TopGroupLayout->addWidget( CyclesSpin, 1, 1 ); + TopGroupLayout->addWidget( StepsLabel, 2, 0 ); + TopGroupLayout->addWidget( StepsSpin, 2, 1 ); + + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + TopLayout->addWidget( TopGroup, 0, 0); + TopLayout->addWidget( GroupButtons, 1, 0 ); + + // signals and slots connections =========================================== + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); +} + +/*! + Destructor +*/ +VisuGUI_SweepPrefDlg::~VisuGUI_SweepPrefDlg() +{ +} + +/*! + Sets Time step +*/ +void VisuGUI_SweepPrefDlg::setTimeStep( double step ) +{ + TimeSpin->setValue( step ); +} + +/*! + Gets Time step +*/ +double VisuGUI_SweepPrefDlg::getTimeStep() +{ + return TimeSpin->value(); +} + +/*! + Sets Nb of cycles +*/ +void VisuGUI_SweepPrefDlg::setNbCycles( int nbc ) +{ + CyclesSpin->setValue( nbc ); +} + +/*! + Gets Nb of cycles +*/ +int VisuGUI_SweepPrefDlg::getNbCycles() +{ + return CyclesSpin->value(); +} + +/*! + Sets Nb of Steps +*/ +void VisuGUI_SweepPrefDlg::setNbSteps( int nbs ) +{ + StepsSpin->setValue( nbs ); +} + +/*! + Gets Nb of Steps +*/ +int VisuGUI_SweepPrefDlg::getNbSteps() +{ + return StepsSpin->value(); +} diff --git a/src/VISUGUI/VisuGUI_SweepPrefDlg.h b/src/VISUGUI/VisuGUI_SweepPrefDlg.h new file mode 100644 index 00000000..5e3c3fd5 --- /dev/null +++ b/src/VISUGUI/VisuGUI_SweepPrefDlg.h @@ -0,0 +1,47 @@ +// File : VisuGUI_SweepPrefDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_SWEEPPREFDLG_H +#define VISUGUI_SWEEPPREFDLG_H + +#include +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" + +class VisuGUI_SweepPrefDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_SweepPrefDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_SweepPrefDlg(); + + void setTimeStep( double step ); + double getTimeStep(); + void setNbCycles( int nbc ); + int getNbCycles(); + void setNbSteps ( int nbs ); + int getNbSteps (); + +private: + QGroupBox* TopGroup; + QLabel* TimeLabel; + QAD_SpinBoxDbl* TimeSpin; + QLabel* CyclesLabel; + QSpinBox* CyclesSpin; + QLabel* StepsLabel; + QSpinBox* StepsSpin; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; +}; + +#endif // VISUGUI_SWEEPPREFDLG_H diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx new file mode 100644 index 00000000..b7a04f4c --- /dev/null +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -0,0 +1,697 @@ +// File : VisuGUI_TimeAnimation.cxx +// Created : 28 / 03 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : VISUGUI +// Copyright : Open CASCADE + + +#include "VisuGUI_TimeAnimation.h" +#include "VisuGUI.h" + +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_FileDlg.h" + +#include "VTKViewer_ViewFrame.h" +#include "VISU_ScalarBarActor.hxx" + +#include "VisuGUI_MagnitudeDlg.h" +#include "VisuGUI_CutPlanesDlg.h" +#include "VisuGUI_VectorsDlg.h" +#include "VisuGUI_IsoSurfacesDlg.h" +#include "VisuGUI_StreamLinesDlg.h" +#include "VISU_TimeAnimation.h" + +static double MAXVALUE = 1.0E+300; + + + +SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) + : QDialog( theParent, "SetupDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption("Setup Animation"); + setSizeGripEnabled( TRUE ); + myAnimator = theAnimator; + + QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6); + aMainLayout->setSpacing(5); + + + QFrame* aRangeGrp = new QFrame(this); + QGridLayout* aRangeLayout = new QGridLayout( aRangeGrp ); + aRangeLayout->setSpacing( 6 ); + aRangeLayout->setMargin( 11 ); + aRangeGrp->setFrameStyle(QFrame::Box | QFrame::Raised); + + myUseRangeChk = new QCheckBox("Use range of time stamps", aRangeGrp); + aRangeLayout->addMultiCellWidget(myUseRangeChk, 0, 0, 0, 3); + myUseRangeChk->setChecked(myAnimator->isRangeDefined()); + + QLabel* aMinLbl = new QLabel("From", aRangeGrp); + aMinLbl->setEnabled(myUseRangeChk->isChecked()); + aRangeLayout->addWidget(aMinLbl, 1, 0); + myMinVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); + myMinVal->setEnabled(myUseRangeChk->isChecked()); + myMinVal->setValue( myAnimator->getMinRange() ); + connect(myMinVal, SIGNAL( valueChanged(double)), + this, SLOT( onMinValue(double) )); + aRangeLayout->addWidget(myMinVal, 1, 1); + + QLabel* aMaxLbl = new QLabel("To", aRangeGrp); + aMaxLbl->setEnabled(myUseRangeChk->isChecked()); + aRangeLayout->addWidget(aMaxLbl, 1, 2); + myMaxVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); + myMaxVal->setEnabled(myUseRangeChk->isChecked()); + myMaxVal->setValue( myAnimator->getMaxRange() ); + connect(myMaxVal, SIGNAL( valueChanged(double)), + this, SLOT( onMaxValue(double) )); + aRangeLayout->addWidget(myMaxVal, 1, 3); + + connect(myUseRangeChk, SIGNAL( toggled(bool)), + aMinLbl, SLOT( setEnabled(bool) )); + connect(myUseRangeChk, SIGNAL( toggled(bool)), + aMaxLbl, SLOT( setEnabled(bool) )); + connect(myUseRangeChk, SIGNAL( toggled(bool)), + this, SLOT( onRangeCheck(bool) )); + + aMainLayout->addWidget(aRangeGrp); + + + QHBox* aPropFrame = new QHBox(this); + aPropFrame->setSpacing(5); + + QVGroupBox* aNamesBox = new QVGroupBox("Fields",aPropFrame); + myFieldLst = new QListBox(aNamesBox); + QStringList aFieldNames; + // Find names of fields + for (int i = 0; i < theAnimator->getNbFields(); i++) { + aFieldNames.append(VisuGUI::getValue(theAnimator->getFieldData(i).myField, "myName")); + } + myFieldLst->insertStringList(aFieldNames); + myFieldLst->setSelected(0, true); + connect( myFieldLst, SIGNAL( highlighted(int) ), + this, SLOT( onFieldChange(int) ) ); + + + QVGroupBox* aPropBox = new QVGroupBox("Properties", aPropFrame); + myTypeCombo = new QComboBox(aPropBox); + connect( myTypeCombo, SIGNAL( activated(int) ), + this, SLOT( onTypeChanged(int) ) ); + + QPushButton* aBarBtn = new QPushButton("Scalar Bar...", aPropBox); + connect( aBarBtn, SIGNAL( clicked() ), + this, SLOT( onScalarBarDlg() ) ); + + myPropBtn = new QPushButton("Properties...", aPropBox); + myPropBtn->setEnabled(theAnimator->getFieldData(0).myPrsType != VISU::TSCALARMAP); + connect( myPropBtn, SIGNAL( clicked() ), + this, SLOT( onPreferencesDlg() ) ); + + onFieldChange(0); + aMainLayout->addWidget(aPropFrame); + + QHBox* aBtnBox = new QHBox(this); + QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout()); + aBtnLayout->addStretch(); + + QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close())); + + aMainLayout->addWidget(aBtnBox); +} + + +//************************************************************************ +void SetupDlg::onFieldChange(int theIndex) { + FieldData& aData = myAnimator->getFieldData(theIndex); + myTypeCombo->clear(); + myTypeCombo->insertItem("Scalar Map"); + myTypeCombo->insertItem("Iso Surfaces"); + myTypeCombo->insertItem("Cut Planes"); + + SALOMEDS::SObject_var aSObject = aData.myField; + long aNumComp = VisuGUI::getValue(aSObject, "myNumComponent").toLong(); + if (aNumComp > 1) { + myTypeCombo->insertItem("Deformed Shape"); + myTypeCombo->insertItem("Vectors"); + myTypeCombo->insertItem("Stream Lines"); + } + switch (aData.myPrsType) { + case VISU::TSCALARMAP: //Scalar Map + myTypeCombo->setCurrentItem(0); + break; + case VISU::TISOSURFACE: //Iso Surfaces + myTypeCombo->setCurrentItem(1); + break; + case VISU::TCUTPLANES: //Cut Planes + myTypeCombo->setCurrentItem(2); + break; + case VISU::TDEFORMEDSHAPE: //Deformed Shape + myTypeCombo->setCurrentItem(3); + break; + case VISU::TVECTORS: //Vectors + myTypeCombo->setCurrentItem(4); + break; + case VISU::TSTREAMLINES: //Stream Lines + myTypeCombo->setCurrentItem(5); + aData.myPrsType = VISU::TSTREAMLINES; + break; + } + myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP); +} + +//************************************************************************ +void SetupDlg::onTypeChanged(int theIndex) { + FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem()); + switch (theIndex) { + case 0: //Scalar Map + aData.myPrsType = VISU::TSCALARMAP; + break; + case 1: //Iso Surfaces + aData.myPrsType = VISU::TISOSURFACE; + break; + case 2: //Cut Planes + aData.myPrsType = VISU::TCUTPLANES; + break; + case 3: //Deformed Shape + aData.myPrsType = VISU::TDEFORMEDSHAPE; + break; + case 4: //Vectors + aData.myPrsType = VISU::TVECTORS; + break; + case 5: //Stream Lines + aData.myPrsType = VISU::TSTREAMLINES; + break; + } + myAnimator->clearData(aData); + myPropBtn->setEnabled(aData.myPrsType != VISU::TSCALARMAP); + //myAnimator->generatePresentations(myFieldLst->currentItem()); +} + + +//************************************************************************ +void SetupDlg::onScalarBarDlg() { + QApplication::setOverrideCursor( Qt::waitCursor ); + FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem()); + if (aData.myPrs == 0) + myAnimator->generatePresentations(myFieldLst->currentItem()); + QApplication::restoreOverrideCursor(); + + VisuGUI_ScalarBarDlg* aScalarBarDlg = new VisuGUI_ScalarBarDlg(); + aScalarBarDlg->initFromPrsObject(aData.myPrs[0]); + if (aScalarBarDlg->exec()) { + for (int i = 0; i < aData.myNbTimes; i++) + aScalarBarDlg->storeToPrsObject(aData.myPrs[i]); + } +} + +//************************************************************************ +void SetupDlg::onPreferencesDlg() { + QApplication::setOverrideCursor( Qt::waitCursor ); + FieldData& aData = myAnimator->getFieldData(myFieldLst->currentItem()); + if (aData.myPrs == 0) + myAnimator->generatePresentations(myFieldLst->currentItem()); + QApplication::restoreOverrideCursor(); + + switch (myTypeCombo->currentItem()) { + case 1: //Iso Surfaces + { + VisuGUI_IsoSurfacesDlg* aDlg = new VisuGUI_IsoSurfacesDlg(); + aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); + if (aDlg->exec()) { + for (int i = 0; i < aData.myNbTimes; i++) + aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); + } + } + break; + case 2: //Cut Planes + { + VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(); + aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); + if (aDlg->exec()) { + for (int i = 0; i < aData.myNbTimes; i++) + aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); + } + } + break; + case 3: //Deformed Shape + { + VisuGUI_MagnitudeDlg* aDlg = new VisuGUI_MagnitudeDlg(); + aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); + if (aDlg->exec()) { + for (int i = 0; i < aData.myNbTimes; i++) + aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); + } + } + break; + case 4: //Vectors + { + VisuGUI_VectorsDlg* aDlg = new VisuGUI_VectorsDlg(); + aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); + if (aDlg->exec()) { + for (int i = 0; i < aData.myNbTimes; i++) + aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); + } + } + break; + case 5: //Stream Lines + { + VisuGUI_StreamLinesDlg* aDlg = new VisuGUI_StreamLinesDlg(); + aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); + if (aDlg->exec()) { + for (int i = 0; i < aData.myNbTimes; i++) + aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); + } + } + break; + } +} + +//************************************************************************ +void SetupDlg::onRangeCheck(bool theCheck) { + for (int i = 0; i < myAnimator->getNbFields(); i++) + myAnimator->clearData(myAnimator->getFieldData(i)); + + myMinVal->setEnabled(theCheck); + myMaxVal->setEnabled(theCheck); + + if (!theCheck) + myAnimator->setAnimationRange(0, 0); +} + +//************************************************************************ +void SetupDlg::onMinValue(double theVal) { + for (int i = 0; i < myAnimator->getNbFields(); i++) + myAnimator->clearData(myAnimator->getFieldData(i)); + myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange()); +} + +//************************************************************************ +void SetupDlg::onMaxValue(double theVal) { + for (int i = 0; i < myAnimator->getNbFields(); i++) + myAnimator->clearData(myAnimator->getFieldData(i)); + myAnimator->setAnimationRange(myAnimator->getMinRange(), theVal); +} + + +static const char * firstIco[] = { +"18 10 2 1", +" g None", +". g #000000", +" . . ", +" .. .. .. ", +" .. ... ... ", +" .. .... .... ", +" .. ..... ..... ", +" .. ..... ..... ", +" .. .... .... ", +" .. ... ... ", +" .. .. .. ", +" . . "}; + + +static const char * lastIco[] = { +"18 10 2 1", +" g None", +". g #000000", +" . . ", +" .. .. .. ", +" ... ... .. ", +" .... .... .. ", +" ..... ..... .. ", +" ..... ..... .. ", +" .... .... .. ", +" ... ... .. ", +" .. .. .. ", +" . . "}; + + +static const char * leftIco[] = { +"11 10 2 1", +" g None", +". g #000000", +" . .", +" .. ..", +" ... ...", +" .... ....", +"..... .....", +"..... .....", +" .... ....", +" ... ...", +" .. ..", +" . ."}; + +static const char * playIco[] = { +"14 14 2 1", +" g None", +". g #000000", +" ", +" ", +" .. ", +" .... ", +" ...... ", +" ........ ", +" .......... ", +" .......... ", +" ........ ", +" ...... ", +" .... ", +" .. ", +" ", +" "}; + +static QPixmap MYplayPixmap(playIco); + + + +static const char * rightIco[] = { +"11 10 2 1", +" g None", +". g #000000", +". . ", +".. .. ", +"... ... ", +".... .... ", +"..... .....", +"..... .....", +".... .... ", +"... ... ", +".. .. ", +". . "}; + + +static const char * pauseIco[] = { +"14 14 2 1", +" g None", +". g #000000", +" ", +" ", +" .. .. ", +" .. .. ", +" .. .. ", +" .. .. ", +" .. .. ", +" .. .. ", +" .. .. ", +" .. .. ", +" .. .. ", +" .. .. ", +" ", +" "}; + +static QPixmap MYpausePixmap(pauseIco); + + +VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) + : QDialog( QAD_Application::getDesktop(), "VisuGUI_TimeAnimationDlg", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose) +{ + setCaption("Animation"); + setSizeGripEnabled( TRUE ); + + myStudy = theStudy; + myAnimator = new VISU_TimeAnimation(theStudy); + myAnimator->setSpeed(1); + myAnimator->setViewer(VisuGUI::GetVtkViewFrame()); + connect( myAnimator, SIGNAL( frameChanged(long, double) ), + this, SLOT( onExecution(long, double) ) ); + + QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6); + aMainLayout->setSpacing(5); + + QPushButton* aSetupBtn = new QPushButton("Setup Animation...", this); + connect( aSetupBtn, SIGNAL( clicked() ), + this, SLOT( onSetupDlg() ) ); + aMainLayout->addWidget(aSetupBtn); + + QPushButton* aGenBtn = new QPushButton("Generate frames", this); + connect( aGenBtn, SIGNAL( clicked() ), + this, SLOT( createFrames() ) ); + aMainLayout->addWidget(aGenBtn); + + myPlayFrame = new QFrame(this); + myPlayFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); + myPlayFrame->setLineWidth( 1 ); + + + // --- Play controls --- + QGridLayout* TopLayout = new QGridLayout( myPlayFrame ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + myTimeLbl = new QLabel("0", myPlayFrame); + TopLayout->addMultiCellWidget(myTimeLbl, 0, 0, 0, 2, Qt::AlignHCenter); + + mySlider = new QSlider(Qt::Horizontal, myPlayFrame); + mySlider->setMinValue(0); + mySlider->setMaxValue(3); + mySlider->setTickInterval(1); + //mySlider->setTickmarks(QSlider::Below); + mySlider->setTracking(false); + connect( mySlider, SIGNAL( valueChanged(int) ), + this, SLOT( onFrameChanged(int) ) ); + TopLayout->addMultiCellWidget(mySlider, 1, 1, 0, 2); + + myPlayBtn = new QToolButton(myPlayFrame); + myPlayBtn->setIconSet(MYplayPixmap); + myPlayBtn->setToggleButton(true); + connect( myPlayBtn, SIGNAL( clicked() ), + this, SLOT( onPlayPressed() ) ); + TopLayout->addMultiCellWidget(myPlayBtn, 2, 2, 0, 1); + + QToolButton* aBackBtn = new QToolButton(myPlayFrame); + aBackBtn->setIconSet(QPixmap(leftIco)); + connect( aBackBtn, SIGNAL( clicked() ), + this, SLOT( onBackPressed() ) ); + TopLayout->addWidget(aBackBtn, 3, 0); + + QToolButton* aForvardBtn = new QToolButton(myPlayFrame); + aForvardBtn->setIconSet(QPixmap(rightIco)); + connect( aForvardBtn, SIGNAL( clicked() ), + this, SLOT( onForvardPressed() ) ); + TopLayout->addWidget(aForvardBtn, 3, 1); + + QToolButton* aFirstBtn = new QToolButton(myPlayFrame); + aFirstBtn->setIconSet(QPixmap(firstIco)); + connect( aFirstBtn, SIGNAL( clicked() ), + this, SLOT( onFirstPressed() ) ); + TopLayout->addWidget(aFirstBtn, 4, 0); + + QToolButton* aLastBtn = new QToolButton(myPlayFrame); + aLastBtn->setIconSet(QPixmap(lastIco)); + connect( aLastBtn, SIGNAL( clicked() ), + this, SLOT( onLastPressed() ) ); + TopLayout->addWidget(aLastBtn, 4, 1); + + QLabel* aSpeedLbl = new QLabel("Speed", myPlayFrame); + TopLayout->addWidget(aSpeedLbl, 4, 2, Qt::AlignRight); + + QLCDNumber* aSpeedNum = new QLCDNumber( 2, myPlayFrame ); + aSpeedNum->setSegmentStyle(QLCDNumber::Flat); + aSpeedNum->display(1); + TopLayout->addWidget(aSpeedNum, 4, 3); + + QwtWheel* aWheel = new QwtWheel(myPlayFrame); + aWheel->setOrientation(Qt::Vertical); + aWheel->setRange(1, 99, 1); + connect( aWheel, SIGNAL(valueChanged(double)), + aSpeedNum, SLOT(display(double)) ); + connect( aWheel, SIGNAL(valueChanged(double)), + this, SLOT(onSpeedChange(double)) ); + TopLayout->addMultiCellWidget(aWheel, 1, 3, 3, 3, Qt::AlignRight); + + QCheckBox* aPropCheck = new QCheckBox("Use proportional timing",myPlayFrame); + aPropCheck->setChecked(myAnimator->isProportional()); + connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportional(bool))); + TopLayout->addMultiCellWidget(aPropCheck, 5, 5, 0, 3); + + mySaveCheck = new QCheckBox("Save pictures to directory",myPlayFrame); + TopLayout->addMultiCellWidget(mySaveCheck, 6, 6, 0, 3); + + QLabel* aPathLbl = new QLabel("Path:", myPlayFrame); + connect(mySaveCheck, SIGNAL( toggled(bool)), + aPathLbl, SLOT( setEnabled(bool) )); + TopLayout->addWidget(aPathLbl, 7, 0); + + myPathEdit = new QLineEdit(myPlayFrame); + connect(mySaveCheck, SIGNAL( toggled(bool)), + myPathEdit, SLOT( setEnabled(bool) )); + TopLayout->addMultiCellWidget(myPathEdit, 7, 7, 1, 2); + + QPushButton* aBrowseBtn = new QPushButton("Browse...", myPlayFrame); + connect(mySaveCheck, SIGNAL( toggled(bool)), + aBrowseBtn, SLOT( setEnabled(bool) )); + connect(aBrowseBtn, SIGNAL( clicked()), + this, SLOT( onBrowse() )); + + mySaveCheck->setChecked(false); + TopLayout->addWidget(aBrowseBtn, 7, 3); + + aMainLayout->addWidget(myPlayFrame); + + QHBox* aBtnBox = new QHBox(this); + QHBoxLayout* aBtnLayout = new QHBoxLayout(aBtnBox->layout()); + aBtnLayout->addStretch(); + + QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(close())); + + aMainLayout->addWidget(aBtnBox); + + myPlayFrame->setEnabled(false); +} + + +//************************************************************************ +VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg() { + VTKViewer_ViewFrame* aView = myAnimator->getViewer(); + delete myAnimator; + aView->Repaint(); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onTypeChange(int index) { + stopAnimation(); + myPropBtn->setEnabled(index != 0); + + clearView(); + myPlayFrame->setEnabled(false); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::addField(SALOMEDS::SObject_var theSObject) { + myPlayFrame->setEnabled(false); + myAnimator->addField(theSObject); +} + + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::createFrames() { + stopAnimation(); + QApplication::setOverrideCursor( Qt::waitCursor ); + + for (int i = 0; i < myAnimator->getNbFields(); i++) { + if (myAnimator->getFieldData(i).myPrs == 0) + myAnimator->generatePresentations(i); + } + mySlider->setMaxValue(myAnimator->getNbFrames()-1); + if (!myAnimator->generateFrames()) { + QApplication::restoreOverrideCursor(); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), "Defined presentation can not be created"); + return; + } + myPlayFrame->setEnabled(true); + QApplication::restoreOverrideCursor(); +} + + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onPlayPressed() { + if (myPlayBtn->isOn()) { + myPlayBtn->setIconSet(MYpausePixmap); + if (mySaveCheck->isChecked()) + myAnimator->dumpTo(myPathEdit->text()); + else + myAnimator->dumpTo(""); + myAnimator->startAnimation(); + } else { + myPlayBtn->setIconSet(MYplayPixmap); + myAnimator->stopAnimation(); + } +} + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onBackPressed() { + stopAnimation(); + myAnimator->prevFrame(); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onForvardPressed() { + stopAnimation(); + myAnimator->nextFrame(); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onLastPressed() { + stopAnimation(); + myAnimator->lastFrame(); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onFirstPressed() { + stopAnimation(); + myAnimator->firstFrame(); +} + + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::clearView() { + myAnimator->clearView(); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::closeEvent(QCloseEvent* theEvent) { + stopAnimation(); + clearView(); + QDialog::closeEvent(theEvent); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onFrameChanged(int index) { + if (myAnimator->isRunning()) return; + myAnimator->gotoFrame(index); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onSpeedChange(double theSpeed) { + myAnimator->setSpeed((int)theSpeed); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::stopAnimation() { + myAnimator->stopAnimation(); + myPlayBtn->setOn(false); + myPlayBtn->setIconSet(MYplayPixmap); +} + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onExecution(long theNewFrame, double theTime) { + myTimeLbl->setText(QString("%1").arg(theTime)); + mySlider->setValue(theNewFrame); +} + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onSetupDlg() { + SetupDlg* aDlg = new SetupDlg(this, myAnimator); + aDlg->exec(); + delete aDlg; +} + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onBrowse() { + myPathEdit->setText(QAD_FileDlg::getExistingDirectory(this, "/","Select path")); +} diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h new file mode 100644 index 00000000..5299cb42 --- /dev/null +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -0,0 +1,95 @@ +// File : VisuGUI_TimeAnimation.h +// Created : 28 / 03 / 2003 +// Author : Vitaly SMETANNIKOV +// Project : SALOME +// Module : VISUGUI +// Copyright : Open CASCADE + +#ifndef VISUGUI_TIMEANIMATION_H +#define VISUGUI_TIMEANIMATION_H + +#include +#include +#include +#include +#include + +#include "VisuGUI_ScalarBarDlg.h" + +class VISU_TimeAnimation; + + +/** + * Auxilliary class for presentations definition + */ +class SetupDlg: public QDialog { + Q_OBJECT + +public: + SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator); + ~SetupDlg() {}; + +private slots: + void onFieldChange(int theIndex); + void onTypeChanged(int theIndex); + void onScalarBarDlg(); + void onPreferencesDlg(); + void onRangeCheck(bool theCheck); + void onMinValue(double theVal); + void onMaxValue(double theVal); + +private: + VISU_TimeAnimation* myAnimator; + QListBox* myFieldLst; + QComboBox* myTypeCombo; + QPushButton* myPropBtn; + QCheckBox* myUseRangeChk; + QAD_SpinBoxDbl* myMinVal; + QAD_SpinBoxDbl* myMaxVal; +}; + + + +class VisuGUI_TimeAnimationDlg: public QDialog +{ + Q_OBJECT + public: + VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy); + ~VisuGUI_TimeAnimationDlg(); + + void addField(SALOMEDS::SObject_var theField); + void clearView(); + + protected: + virtual void closeEvent(QCloseEvent* theEvent); + void stopAnimation(); + + private slots: + void onTypeChange(int index); + void onPlayPressed(); + void onBackPressed(); + void onForvardPressed(); + void onLastPressed(); + void onFirstPressed(); + void onSetupDlg(); + void onFrameChanged(int index); + void createFrames(); + void onSpeedChange(double theSpeed); + void onExecution(long theNewFrame, double theTime); + void onBrowse(); + + private: + QSlider* mySlider; + QComboBox* myTypeCombo; + QPushButton* myPropBtn; + QToolButton* myPlayBtn; + QLabel* myTimeLbl; + + QFrame* myPlayFrame; + SALOMEDS::Study_var myStudy; + + VISU_TimeAnimation* myAnimator; + QCheckBox* mySaveCheck; + QLineEdit* myPathEdit; +}; +#endif //VISUGUI_TIMEANIMATION_H diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx new file mode 100644 index 00000000..9771df6f --- /dev/null +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -0,0 +1,372 @@ +using namespace std; +// File : VisuGUI_VectorsDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_VectorsDlg.h" +#include +#include +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +/*! + Constructor +*/ +VisuGUI_VectorsDlg::VisuGUI_VectorsDlg() + : QDialog( QAD_Application::getDesktop(), "VisuGUI_VectorsDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "Vector Field Representation" ) ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + TopGroup = new QButtonGroup( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + // Scale factor + ScaleLabel = new QLabel( tr( "Scale factor:" ), TopGroup, "ScaleLabel" ); + + ScalFact = new QAD_SpinBoxDbl( TopGroup, 1e-20, 1.0E+38, 0.1, 5); + ScalFact->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + ScalFact->setValue( 0.1 ); + + TopGroupLayout->addWidget( ScaleLabel, 0, 0 ); + TopGroupLayout->addWidget( ScalFact, 0, 1 ); + + // Line width + LineWidLabel = new QLabel( tr( "Line width:" ), TopGroup, "LineWidLabel" ); + + LinWid = new QSpinBox( 1, 10, 1, TopGroup, "LinWid" ); + LinWid->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + LinWid->setValue( 1 ); + + TopGroupLayout->addWidget( LineWidLabel, 1, 0 ); + TopGroupLayout->addWidget( LinWid, 1, 1 ); + + // Color + UseMagn = new QCheckBox( tr( "Magnitude coloring" ), TopGroup, "UseMagn" ); + UseMagn->setText( tr( "Magnitude coloring" ) ); + SelColor = new QPushButton( tr( "Select Color" ), TopGroup, "SelColor" ); + + /* ColorLab = new QLabel( TopGroup, "ColorLab" ); + ColorLab->setFixedSize( SelColor->sizeHint().height(), SelColor->sizeHint().height() ); + ColorLab->setFrameStyle( QLabel::Plain | QLabel::Box ); + */ + TopGroupLayout->addWidget( UseMagn, 2, 0 ); + //TopGroupLayout->addWidget( ColorLab, 2, 1 ); + TopGroupLayout->addWidget( SelColor, 2, 1 ); + + // Gliphs + UseGlyph = new QCheckBox( tr( "Use glyphs" ), TopGroup, "UseGlyph" ); + + TypeGlyph = new QButtonGroup( tr( "Glyph type" ), TopGroup, "TypeGlyph" ); + TypeGlyph->setColumnLayout(0, Qt::Vertical ); + TypeGlyph->layout()->setSpacing( 0 ); + TypeGlyph->layout()->setMargin( 0 ); + QGridLayout* TypeGlyphLayout = new QGridLayout( TypeGlyph->layout() ); + TypeGlyphLayout->setAlignment( Qt::AlignTop ); + TypeGlyphLayout->setSpacing( 6 ); + TypeGlyphLayout->setMargin( 11 ); + + RBArrows = new QRadioButton( tr( "Arrows" ), TypeGlyph, "RBArrows" ); + TypeGlyphLayout->addWidget( RBArrows, 0, 0 ); + RBCones2 = new QRadioButton( tr( "Cones (2)" ), TypeGlyph, "RBCones2" ); + TypeGlyphLayout->addWidget( RBCones2, 1, 0 ); + RBCones6 = new QRadioButton( tr( "Cones (6)" ), TypeGlyph, "RBCones6" ); + TypeGlyphLayout->addWidget( RBCones6, 2, 0 ); + + PosGlyph = new QButtonGroup( tr( "Glyph position" ), TopGroup, "PosGlyph" ); + PosGlyph->setColumnLayout(0, Qt::Vertical ); + PosGlyph->layout()->setSpacing( 0 ); + PosGlyph->layout()->setMargin( 0 ); + QGridLayout* PosGlyphLayout = new QGridLayout( PosGlyph->layout() ); + PosGlyphLayout->setAlignment( Qt::AlignTop ); + PosGlyphLayout->setSpacing( 6 ); + PosGlyphLayout->setMargin( 11 ); + + RBTail = new QRadioButton( tr( "Tail" ), PosGlyph, "RBTail" ); + PosGlyphLayout->addWidget( RBTail, 0, 0 ); + RBCent = new QRadioButton( tr( "Center" ), PosGlyph, "RBCent" ); + PosGlyphLayout->addWidget( RBCent, 1, 0 ); + RBHead = new QRadioButton( tr( "Head" ), PosGlyph, "RBHead" ); + PosGlyphLayout->addWidget( RBHead, 2, 0 ); + + TopGroupLayout->addMultiCellWidget( UseGlyph, 3, 3, 0, 2 ); + TopGroupLayout->addWidget( TypeGlyph, 4, 0 ); + TopGroupLayout->addMultiCellWidget( PosGlyph, 4, 4, 1, 2 ); + + // Common buttons =========================================================== + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + // top layout + TopLayout->addWidget( TopGroup ); + TopLayout->addWidget( GroupButtons ); + + // signals and slots connections + connect( UseGlyph, SIGNAL( clicked() ), this, SLOT( enableGlyphType() ) ); + connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) ); + connect( UseMagn, SIGNAL( clicked() ), this, SLOT( enableSetColor() ) ); + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + // default values + UseMagn->setChecked( TRUE ); + UseGlyph->setChecked( TRUE ); + RBArrows->setChecked( TRUE ); + RBTail->setChecked( TRUE ); + setColor( QColor( 255, 0, 0 ) ); + enableGlyphType(); + enableSetColor(); +} + +/*! + Destructor +*/ +VisuGUI_VectorsDlg::~VisuGUI_VectorsDlg() +{ +} + + +void VisuGUI_VectorsDlg::initFromPrsObject(VISU::Vectors_i* thePrs) { + setScaleFactor(thePrs->GetScale()); + setLineWidth(thePrs->GetLineWidth()); + setUseMagnColor(thePrs->isColored()); + setColor(QColor(thePrs->GetColor()[0]*255, + thePrs->GetColor()[1]*255, + thePrs->GetColor()[2]*255)); + + if (thePrs->GetGlyphType() != VISU::Vectors::NONE) { + setUseGlyphs(true); + setGlyphType(thePrs->GetGlyphType()); + setGlyphPos(thePrs->GetGlyphPos()); + } else + setUseGlyphs(false); + + enableSetColor(); +} + + +void VisuGUI_VectorsDlg::storeToPrsObject(VISU::Vectors_i* thePrs) { + thePrs->SetScale(getScaleFactor()); + thePrs->SetLineWidth(getLineWidth()); + thePrs->setColored(getUseMagnColor()); + + float aColor[3]; + aColor[0] = myColor.red()/255.; + aColor[1] = myColor.green()/255.; + aColor[2] = myColor.blue()/255.; + + thePrs->SetColor(aColor); + + if (getUseGlyphs()) { + thePrs->SetGlyphPos(getGlyphPos()); + thePrs->SetGlyphType(getGlyphType()); + } else + thePrs->SetGlyphType(VISU::Vectors::NONE); +} + + + +/*! + Called when "Use glyphs" check box clicked +*/ +void VisuGUI_VectorsDlg::enableGlyphType() +{ + TypeGlyph->setEnabled( UseGlyph->isChecked() ); + PosGlyph->setEnabled( UseGlyph->isChecked() ); +} + +/*! + Called when "Magnitude Coloring" check box clicked +*/ +void VisuGUI_VectorsDlg::enableSetColor() +{ + SelColor->setEnabled(!UseMagn->isChecked() ); + //ColorLab->setEnabled( UseMagn->isEnabled() && !UseMagn->isChecked() ); +} + +/*! + Called when "Select Color" buttonx clicked +*/ +void VisuGUI_VectorsDlg::setVColor() +{ + QColor cnew = QColorDialog::getColor( myColor, this ); + if ( cnew.isValid() ) + setColor( cnew ); +} + +/*! + Sets Scale factor +*/ +void VisuGUI_VectorsDlg::setScaleFactor( double sf ) +{ + ScalFact->setValue( sf ); +} + +/*! + Gets Scale factor +*/ +double VisuGUI_VectorsDlg::getScaleFactor() +{ + return ScalFact->value(); +} + +/*! + Sets Line width +*/ +void VisuGUI_VectorsDlg::setLineWidth( int lw ) +{ + LinWid->setValue( lw ); +} + +/*! + Gets Line width +*/ +int VisuGUI_VectorsDlg::getLineWidth() +{ + return LinWid->value(); +} + +/*! + Sets "Use Magnitude Coloring" flag +*/ +void VisuGUI_VectorsDlg::setUseMagnColor( bool on ) +{ + UseMagn->setChecked( on ); + enableSetColor(); +} + +/*! + Gets "Use Magnitude Coloring" flag state +*/ +bool VisuGUI_VectorsDlg::getUseMagnColor() +{ + return UseMagn->isChecked(); +} + +/*! + Sets "Use Glyphs" flag +*/ +void VisuGUI_VectorsDlg::setUseGlyphs( bool on ) +{ + UseGlyph->setChecked( on ); + enableGlyphType(); +} + +/*! + Gets "Use Glyphs" flag state +*/ +bool VisuGUI_VectorsDlg::getUseGlyphs() +{ + return UseGlyph->isChecked(); +} + +/*! + Sets color +*/ +void VisuGUI_VectorsDlg::setColor( QColor color ) +{ + myColor = color; + SelColor->setPaletteBackgroundColor(myColor); +/* QPalette pal = ColorLab->palette(); + QColorGroup ca = pal.active(); + ca.setColor( QColorGroup::Background, myColor ); + pal.setActive( ca ); + ColorLab->setPalette( pal );*/ +} + +/*! + Sets glyphs type : 0 - arrows, 1 - cones2, 2 - cones6 +*/ +void VisuGUI_VectorsDlg::setGlyphType(VISU::Vectors::GlyphType type ) +{ + if ( type == VISU::Vectors::CONE2) + RBCones2->setChecked( true ); + else if ( type == VISU::Vectors::CONE6) + RBCones6->setChecked( true ); + else + RBArrows->setChecked( true ); +} + +/*! + Gets glyphs type : 0 - arrows, 1 - cones2, 2 - cones6 +*/ +VISU::Vectors::GlyphType VisuGUI_VectorsDlg::getGlyphType() +{ + VISU::Vectors::GlyphType type; + if ( RBCones2->isChecked() ) + type = VISU::Vectors::CONE2; + else if ( RBCones6->isChecked() ) + type = VISU::Vectors::CONE6; + else + type = VISU::Vectors::ARROW; + return type; +} + +/*! + Sets glyph position : -1 - tail, 0 - center, 1 - head +*/ +void VisuGUI_VectorsDlg::setGlyphPos(VISU::Vectors::GlyphPos pos) +{ + if ( pos == VISU::Vectors::TAIL) + RBTail->setChecked(true); + else if ( pos == VISU::Vectors::HEAD) + RBHead->setChecked(true); + else + RBCent->setChecked(true); +} + +/*! + Gets glyph position : -1 - tail, 0 - center, 1 - head +*/ +VISU::Vectors::GlyphPos VisuGUI_VectorsDlg::getGlyphPos() +{ + VISU::Vectors::GlyphPos pos; + if ( RBTail->isChecked() ) + pos = VISU::Vectors::TAIL; + else if ( RBHead->isChecked() ) + pos = VISU::Vectors::HEAD; + else + pos = VISU::Vectors::CENTER; + return pos; +} + +/*! + Enbled/disables magnitude coloring +*/ +void VisuGUI_VectorsDlg::enableMagnColor( bool enable ) +{ + UseMagn->setEnabled( enable ); + enableSetColor(); +} + + + diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.h b/src/VISUGUI/VisuGUI_VectorsDlg.h new file mode 100644 index 00000000..0cebbaa7 --- /dev/null +++ b/src/VISUGUI/VisuGUI_VectorsDlg.h @@ -0,0 +1,84 @@ +// File : VisuGUI_VectorsDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_VECTORSDLG_H +#define VISUGUI_VECTORSDLG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include "QAD_SpinBoxDbl.h" +#include "VISU_PrsObject_i.hh" + + +class VisuGUI_VectorsDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_VectorsDlg(); + ~VisuGUI_VectorsDlg(); + + void setScaleFactor( double sf ); + double getScaleFactor(); + void setLineWidth( int lw ); + int getLineWidth(); + void setUseMagnColor( bool on ); + bool getUseMagnColor(); + void setUseGlyphs( bool on ); + bool getUseGlyphs(); + void setColor( QColor color); + QColor getColor(); + + void setGlyphType(VISU::Vectors::GlyphType type ); + VISU::Vectors::GlyphType getGlyphType(); + + void setGlyphPos(VISU::Vectors::GlyphPos pos); + VISU::Vectors::GlyphPos getGlyphPos(); + void enableMagnColor( bool enable ); + + void initFromPrsObject(VISU::Vectors_i* thePrs); + void storeToPrsObject(VISU::Vectors_i* thePrs); + + +private: + QGroupBox* TopGroup; + QCheckBox* UseMagn; + //QLabel* ColorLab; + QPushButton* SelColor; + QLabel* LineWidLabel; + QSpinBox* LinWid; + QLabel* ScaleLabel; + QAD_SpinBoxDbl* ScalFact; + QCheckBox* UseGlyph; + QButtonGroup* TypeGlyph; + QRadioButton* RBCones6; + QRadioButton* RBCones2; + QRadioButton* RBArrows; + QButtonGroup* PosGlyph; + QRadioButton* RBTail; + QRadioButton* RBCent; + QRadioButton* RBHead; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + + QColor myColor; + +private slots: + void enableGlyphType(); + void setVColor(); + void enableSetColor(); +}; + +#endif // VISUGUI_VECTORSDLG_H diff --git a/src/VISUGUI/VisuGUI_VisuAsDlg.cxx b/src/VISUGUI/VisuGUI_VisuAsDlg.cxx new file mode 100644 index 00000000..b61b507f --- /dev/null +++ b/src/VISUGUI/VisuGUI_VisuAsDlg.cxx @@ -0,0 +1,208 @@ +using namespace std; +// File : VisuGUI_VisuAsDlg.cxx +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#include "VisuGUI_VisuAsDlg.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_RightFrame.h" +#include "VTKViewer_ViewFrame.h" +#include + +/*! + Constructor +*/ +VisuGUI_VisuAsDlg::VisuGUI_VisuAsDlg( QWidget* parent, const char* name, bool modal, WFlags fl) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) + setName( "VisuGUI_VisuAsDlg" ); + setCaption( tr( "Visualize As" ) ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* TopLayout = new QVBoxLayout( this ); + TopLayout->setSpacing( 6 ); + TopLayout->setMargin( 11 ); + + TopGroup = new QGroupBox( this, "TopGroup" ); + TopGroup->setColumnLayout(0, Qt::Vertical ); + TopGroup->layout()->setSpacing( 0 ); + TopGroup->layout()->setMargin( 0 ); + QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() ); + TopGroupLayout->setAlignment( Qt::AlignTop ); + TopGroupLayout->setSpacing( 6 ); + TopGroupLayout->setMargin( 11 ); + + TypeLabel = new QLabel( tr( "Type of Object:" ), TopGroup, "TypeLabel" ); + TypeCombo = new QComboBox( FALSE, TopGroup, "TypeCombo" ); + TypeCombo->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + TypeCombo->setMinimumSize( 150, 0 ); + + ObjectsLabel = new QLabel( tr( "List of Objects" ), TopGroup, "ObjectsLabel" ); + ObjectsList = new QListBox( TopGroup, "ObjectsList" ); + ObjectsList->setSelectionMode( QListBox::Single ); + ObjectsList->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + ObjectsList->setMinimumSize( 150, 80 ); + + TopGroupLayout->addWidget( TypeLabel, 0, 0 ); + TopGroupLayout->addWidget( ObjectsLabel, 0, 1 ); + TopGroupLayout->addWidget( TypeCombo, 1, 0 ); + TopGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Minimum, QSizePolicy::Expanding), 2, 0 ); + TopGroupLayout->addMultiCellWidget( ObjectsList, 1, 2, 1, 1 ); + + // Common buttons =========================================================== + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + // top layout + TopLayout->addWidget( TopGroup ); + TopLayout->addWidget( GroupButtons ); + + // signals and slots connections + connect( TypeCombo, SIGNAL( activated( const QString& ) ), this, SLOT( RefreshListActors( const QString& ) ) ); + connect( ObjectsList, SIGNAL( selectionChanged() ), this, SLOT( updateButtonsState() ) ); + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + + addType( tr( "All" ) ); +} + +/*! + Destructor +*/ +VisuGUI_VisuAsDlg::~VisuGUI_VisuAsDlg() +{ +} + +/*! + Adds type +*/ +void VisuGUI_VisuAsDlg::addType( QString type ) +{ + int ind = TypeCombo->currentItem(); + if ( TypeCombo->count() <= 0 ) ind = -1; + TypeCombo->insertItem( type ); + if ( ind != TypeCombo->currentItem() ) + RefreshListActors( TypeCombo->currentText() ); +} + +/*! + Called when user selects objects type from combo box +*/ +void VisuGUI_VisuAsDlg::RefreshListActors( const QString &VAType ) +{ + int test = 0; + if ( VAType == QString( "All" ) ) + test = -1; + else if ( VAType == QString( "Deformed Shape" ) ) + test = VisuActorType_DeformedShape; + else if ( VAType == QString( "Vectors" ) ) + test = VisuActorType_Vectors; + else if ( VAType == QString( "Scalar Map" ) ) + test = VisuActorType_ScalarMap; + else if ( VAType == QString( "Iso-Surfaces" ) ) + test = VisuActorType_IsoSurfaces; + else if ( VAType == QString( "Cut Planes" ) ) + test = VisuActorType_CutPlanes; + else + return; + + ObjectsList->clear(); + + QAD_Study *myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); + int nbSf = myActiveStudy->getStudyFramesCount(); + for ( int i = 0; i < nbSf; i++ ) { + QAD_StudyFrame* sf = myActiveStudy->getStudyFrame(i); + if ( sf->getTypeView() == VIEW_VTK ) { + vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); + vtkActorCollection* ac = aRenderer->GetActors(); + vtkActor *anActor; + for( ac->InitTraversal(); ( anActor = ac->GetNextActor() ) != NULL; ) { + if ( anActor->IsA( "VISU_Actor" ) ) { + VISU_Actor* VISUActor = VISU_Actor::SafeDownCast( anActor ); + if ( ActorTypeIsValid( VISUActor, test ) ) + ObjectsList->insertItem( VISUActor->getName() ); + } + } + } + } + updateButtonsState(); +} + +/*! + Checks if type of actor is valid according to test value [ static ] +*/ +bool VisuGUI_VisuAsDlg::ActorTypeIsValid( VISU_Actor* Actor, int test ) +{ + if( test == -1 ) { + if( Actor->VisuActorType < VisuActorType_DeformedShape || + Actor->VisuActorType > VisuActorType_CutPlanes ) + return false; + else + return true; + } + else { + if( test < VisuActorType_DeformedShape || + test > VisuActorType_CutPlanes ) + return false; + else { + if( Actor->VisuActorType == test) + return true; + else + return false; + } + } +} + +/*! + Gets object selected +*/ +QString VisuGUI_VisuAsDlg::getObject() +{ + for( int i = 0; i < ObjectsList->count(); i++ ) { + if ( ObjectsList->isSelected( i ) ) { + return ObjectsList->text( i ); + } + } + return QString::null; +} + +/*! + Called when selection changed +*/ +void VisuGUI_VisuAsDlg::updateButtonsState() +{ + bool selected = false; + for( int i = 0; i < ObjectsList->count(); i++ ) { + if ( ObjectsList->isSelected( i ) ) { + selected = true; + break; + } + } + buttonOk->setEnabled( selected ); +} + + + + + diff --git a/src/VISUGUI/VisuGUI_VisuAsDlg.h b/src/VISUGUI/VisuGUI_VisuAsDlg.h new file mode 100644 index 00000000..ff48404f --- /dev/null +++ b/src/VISUGUI/VisuGUI_VisuAsDlg.h @@ -0,0 +1,48 @@ +// File : VisuGUI_VisuAsDlg.h +// Created : Wed Aug 01 10:23:06 2001 +// Author : Laurent CORNABE & Hubert ROLLAND +// Project : SALOME +// Module : VISUGUI +// Copyright : PRINCIPIA +// $Header$ + +#ifndef VISUGUI_VISUASDLG_H +#define VISUGUI_VISUASDLG_H + +#include "VISU_Actor.h" + +#include +#include +#include +#include +#include +#include + +class VisuGUI_VisuAsDlg : public QDialog +{ + Q_OBJECT + +public: + VisuGUI_VisuAsDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); + ~VisuGUI_VisuAsDlg(); + + void addType( QString type ); + QString getObject(); + static bool ActorTypeIsValid(VISU_Actor *Actor, int test); + +private: + QGroupBox* TopGroup; + QLabel* TypeLabel; + QComboBox* TypeCombo; + QLabel* ObjectsLabel; + QListBox* ObjectsList; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + void RefreshListActors( const QString &VAType ); + void updateButtonsState(); +}; + +#endif // VISUGUI_VISUASDLG_H diff --git a/src/VISU_SWIG/Makefile.in b/src/VISU_SWIG/Makefile.in new file mode 100644 index 00000000..6b950765 --- /dev/null +++ b/src/VISU_SWIG/Makefile.in @@ -0,0 +1,35 @@ +#============================================================================== +# File : Makefile.in +# Created : mar nov 27 17:54:36 CET 2001 +# Author : Paul RASCLE, EDF +# Project : SALOME +# Copyright : EDF 2001 +# $Header$ +#============================================================================== + +# source path +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl + + +@COMMENCE@ + +# Libraries targets + +LIB = libVISU_Swigcmodule.la +LIB_SRC = + +#SWIG_DEF = libVisuGUI_Swig.i +#EXPORT_PYSCRIPTS = libVisuGUI_Swig.py visu.py visu_view3d.py batchmode_visu.py +EXPORT_PYSCRIPTS = batchmode_visu.py visu.py \ + visu_med.py visu_view3d.py batchmode_visu_view3d.py \ + visu_table.py visu_big_table.py visu_view.py + +LIB_CLIENT_IDL = + +CPPFLAGS += $(PYTHON_INCLUDES) -DHAVE_CONFIG_H +LDFLAGS += $(PYTHON_LIBS) -lVISUGUI + +@CONCLUDE@ diff --git a/src/VISU_SWIG/batchmode_visu.py b/src/VISU_SWIG/batchmode_visu.py new file mode 100644 index 00000000..06dd539c --- /dev/null +++ b/src/VISU_SWIG/batchmode_visu.py @@ -0,0 +1,70 @@ +import os +import SALOME_MED +import batchmode_salome +from omniORB import CORBA +import SALOMEDS + +mySession = batchmode_salome.naming_service.Resolve("/Kernel/Session") +mySession.GetInterface() +myVisu = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") + +def getMedObjectFromStudy(): + mySO = batchmode_salome.myStudy.FindObject("Objet MED") + anAttr = mySO.FindAttribute("AttributeIOR")[1] + obj = batchmode_salome.orb.string_to_object(anAttr.Value()) + myObj = obj._narrow(SALOME_MED.MED) + return myObj + +def getFieldObjectFromStudy(number,subnumber): + mySO = batchmode_salome.myStudy.FindObject("MEDFIELD") + if mySO is None: + raise Runtime, "getFieldObjectFromStudy mySO is None" + mysub = mySO.FindSubObject(number)[1] + if mysub: + mysubsub = mysub.FindSubObject(subnumber)[1] + if mysubsub: + Builder = batchmode_salome.myStudy.NewBuilder() + anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") + obj = batchmode_salome.orb.string_to_object(anAttr.Value()) + myObj = obj._narrow(SALOME_MED.FIELDINT) + if (myObj == None): + myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) + return myObj + else: + print "ERROR: No Field Object stored in this Study" + return None + + + +def SObjectToObject(theSObject) : + if theSObject is None : + print "SObjectToObject : argument is None" + anObj = None + res,Attr = theSObject.FindAttribute("AttributeIOR") + if (res != 0) and (Attr is not None) : + anIOR = Attr._narrow(SALOMEDS.AttributeIOR); + aValue = anIOR.Value(); + if(len(aValue) != 0) : + anObj = orb.string_to_object(aValue); + else: + print "SObjectToObject - IOR = ''" + return anObj; + +med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "Med") + + +#med_obj = getMedObjectFromStudy() + +#myBuilder = batchmode_salome.myStudy.NewBuilder() +#father = batchmode_salome.myStudy.FindComponent("VISU") +#myVisu.SetCurrentStudy(batchmode_salome.myStudy) +#father = batchmode_salome.myStudy.FindComponent("VISU") +#if father is None: +# father = myBuilder.NewComponent("VISU") +# A1 = myBuilder.FindOrCreateAttribute(father, "AttributeName"); +# FName = A1._narrow(SALOMEDS.AttributeName) +# FName.SetValue("Visu") +# A2 = myBuilder.FindOrCreateAttribute(father, "AttributePixMap"); +# aPixmap = A2._narrow(SALOMEDS.AttributePixMap); +# aPixmap.SetPixMap( "ICON_OBJBROWSER_Visu" ); +# myBuilder.DefineComponentInstance(father,myVisu) diff --git a/src/VISU_SWIG/batchmode_visu_view3d.py b/src/VISU_SWIG/batchmode_visu_view3d.py new file mode 100644 index 00000000..63842862 --- /dev/null +++ b/src/VISU_SWIG/batchmode_visu_view3d.py @@ -0,0 +1,63 @@ +import os +import batchmode_salome +from VISU import * +import SALOMEDS + +mySession = batchmode_salome.naming_service.Resolve("/Kernel/Session") +mySession.GetInterface() +myVisu = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myVisu.SetCurrentStudy(batchmode_salome.myStudy); + +#medFile = "fra.med" +#myFieldName = "VITESSE"; + +medFile = "minimail.dat" +myFieldName = "Pressures"; + +#medFile = "brideResultats.dat" +#myFieldName = "VM_Elem."; + +medFile = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + medFile +myResult = myVisu.ImportFile(medFile) + +aMesh = myVisu.CreateMesh(myResult); +aScalarMap = myVisu.CreateScalarMap(myResult,myFieldName,0) +aScalarMap.SetScaling(LOGARITHMIC) +aCutPlanes = myVisu.CreateCutPlanes(myResult,myFieldName,0) +aCutPlanes.SetScaling(LOGARITHMIC) +aIsoSurfaces = myVisu.CreateIsoSurfaces(myResult,myFieldName,0) +aIsoSurfaces.SetScaling(LINEAR) + +myViewManager = myVisu.GetViewManager(); +#myView = myViewManager.Create3DView(); +myView = myViewManager.GetCurrent3DView(); +myView.SetFocalPoint([0,0,0]); +myView.SetParallelScale(2); +aPoint = myView.GetPointOfView(); +aPoint[0] = aPoint[0] + 10; +myView.SetPointOfView(aPoint); +myView.ScaleView(View3D.YAxis,10.0); +myView.ScaleView(View3D.XAxis,3.0); +aColor = SALOMEDS.Color(0.0,0.3,1.0) +myView.SetBackground(aColor); +myView.Update(); +myView.Display(aScalarMap); +#myView.Erase(aScalarMap); +#myView.DisplayOnly(aCutPlanes); +myView.SaveViewParams('AAA') + +myView.RemoveScale(); +myView.FitAll(); +aColor = SALOMEDS.Color(0.0,0.0,0.0) +myView.SetBackground(aColor); +myView.SaveViewParams('BBB'); + +aColor = SALOMEDS.Color(1.0,1.0,1.0) +myView.SetBackground(aColor); +myView.ScaleView(View3D.ZAxis,0.5); +myView.SaveViewParams('CCC'); + +myView.RestoreViewParams('AAA'); + + + diff --git a/src/VISU_SWIG/libVISU_Swig.i b/src/VISU_SWIG/libVISU_Swig.i new file mode 100644 index 00000000..17ddcb26 --- /dev/null +++ b/src/VISU_SWIG/libVISU_Swig.i @@ -0,0 +1,12 @@ +//============================================================================= +// File : libVISU_Swig.i +// Created : mar nov 27 18:00:44 CET 2001 +// Author : Paul RASCLE, EDF +// Project : SALOME +// Copyright : EDF 2001 +// $Header$ +//============================================================================= + +%module libVISU_Swig + +//%include "VisuGUI_Swig.i" diff --git a/src/VISU_SWIG/visu.py b/src/VISU_SWIG/visu.py new file mode 100644 index 00000000..fb33546e --- /dev/null +++ b/src/VISU_SWIG/visu.py @@ -0,0 +1,78 @@ +import sys +import os +import salome +import SALOMEDS +import SALOME +import SALOME_MED + +from libSALOME_Swig import * +sg = SALOMEGUI_Swig() + +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") + +def getMedObjectFromStudy(): + mySO = salome.myStudy.FindObject("Objet MED") + anAttr = mySO.FindAttribute("AttributeIOR")[1] + obj = salome.orb.string_to_object(anAttr.Value()) + myObj = obj._narrow(SALOME_MED.MED) + return myObj + +def getFieldObjectFromStudy(number,subnumber): + mySO = salome.myStudy.FindObject("MEDFIELD") + mysub = mySO.FindSubObject(number)[1] + if mysub: + mysubsub = mysub.FindSubObject(subnumber)[1] + if mysubsub: + Builder = salome.myStudy.NewBuilder() + anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") + obj = salome.orb.string_to_object(anAttr.Value()) + myObj = obj._narrow(SALOME_MED.FIELDINT) + if (myObj == None): + myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) + return myObj + else: + print "ERROR: No Field Object stored in this Study" + return None + +#medFile = "mixte.med" +#medFile = "fra.med" +medFile = "pointe.med" +#medFile = "carre_en_quad4_seg2.med" +#medFile = "cube_hexa8_quad4.med" + +medFile = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + medFile +print medFile +studyCurrent = salome.myStudyName +med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "Med") +try: + if os.access(medFile, os.R_OK) : + if os.access(medFile, os.W_OK) : + med_comp.readStructFileWithFieldType(medFile,studyCurrent) + med_obj = getMedObjectFromStudy() + print "med_obj - ", med_obj + + myField = getFieldObjectFromStudy(2,1) + myResult1 = myVisu.ImportMed(myField) + aMesh1 = myVisu.CreateMesh(myResult1); + aScalarMap1 = myVisu.CreateScalarMap(myResult1,myField.getName(),0) + if(myField.getNumberOfComponents() > 1) : + aVectors = myVisu.CreateVectors(myResult1,myField.getName(),0) + + myResult2 = myVisu.ImportFile(medFile) + aMesh2 = myVisu.CreateMesh(myResult2); + aScalarMap2 = myVisu.CreateScalarMap(myResult2,myField.getName(),0) + if(myField.getNumberOfComponents() > 1) : + aCutPlanes = myVisu.CreateCutPlanes(myResult2,myField.getName(),0) + + sg.updateObjBrowser(1) + else : print "We have no permission to rewrite medFile, so readStructFileWithFieldType can't open this file"; + else : print "We have no permission to read medFile, it will not be opened"; + +except: + if sys.exc_type == SALOME.SALOME_Exception : + print "There is no permission to read " + medFile + else : + print sys.exc_type + print sys.exc_value + print sys.exc_traceback + diff --git a/src/VISU_SWIG/visu_big_table.py b/src/VISU_SWIG/visu_big_table.py new file mode 100644 index 00000000..0184c514 --- /dev/null +++ b/src/VISU_SWIG/visu_big_table.py @@ -0,0 +1,73 @@ +#============================================================================== +# File : visu_big_table.py +# Created : 20/01/03 +# Author : Vadim SANDLER +# Project : SALOME +# Copyright : Open CASCADE +# $Header$ +#============================================================================== + +# ============================================================================ +# Test large tables : ~200 curves ( 100 points in each ) +# ============================================================================ +import salome +import math +import SALOMEDS +import VISU + +# >>> Getting study builder ================================================== +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Getting (loading) VISU component ======================================= +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myComponent = myStudy.FindComponent("VISU") +myVisu.SetCurrentStudy(myStudy) +if not myComponent: + myComponent = myBuilder.NewComponent("VISU") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") +# aName.SetValue("Visu") + aName.SetValue( salome.sg.getComponentUserName("VISU") ) + myBuilder.DefineComponentInstance(myComponent,myVisu) + +# >>> Creating object with Table of real[ 200 * 20 ] ======================== +myTRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") +AName.SetValue("Table Of Real") +ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") +myHorNb = 10 +myVerNb = 200 + +k={} +for j in range(0,myHorNb): + k[j] = j*10+1 +ARealTable.AddRow(k.values()) +ARealTable.SetRowTitle(1, "Frequency") +ARealTable.SetRowUnit(1, "Hz") + +for i in range(1,myVerNb+1): + for j in range(0,myHorNb): + if j % 2 == 1: + k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5 + else: + k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 + ARealTable.AddRow(k.values()) + ARealTable.SetRowTitle(i+1, "Power " + str(i)) + ARealTable.SetRowUnit(i+1, "Wt") +ARealTable.SetTitle("Very useful data") + +# >>> Create Visu table +myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() ) + +# >>> Create container and insert curves +myContainer = myVisu.CreateContainer() + +# >>> Create curves +for i in range(1,myVerNb+1): + myCurve = myVisu.CreateCurve( myVisuTableReal, 1, i+1 ) + myContainer.AddCurve(myCurve) + +# >>> Updating Object Browser ================================================ +salome.sg.updateObjBrowser(1) + +# ============================================================================ diff --git a/src/VISU_SWIG/visu_med.py b/src/VISU_SWIG/visu_med.py new file mode 100644 index 00000000..d3a4813c --- /dev/null +++ b/src/VISU_SWIG/visu_med.py @@ -0,0 +1,61 @@ +import os +import salome +import SALOMEDS +import SALOME_MED +import VISU + +from libSALOME_Swig import * +sg = SALOMEGUI_Swig() + +def getMedObjectFromStudy(): + mySO = salome.myStudy.FindObject("Objet MED") + anAttr = mySO.FindAttribute("AttributeIOR")[1] + obj = salome.orb.string_to_object(anAttr.Value()) + myObj = obj._narrow(SALOME_MED.MED) + return myObj + +def getFieldObjectFromStudy(number,subnumber): + mySO = salome.myStudy.FindObject("MEDFIELD") + mysub = mySO.FindSubObject(number)[1] + if mysub: + mysubsub = mysub.FindSubObject(subnumber)[1] + if mysubsub: + Builder = salome.myStudy.NewBuilder() + anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") + obj = salome.orb.string_to_object(anAttr.Value()) + myObj = obj._narrow(SALOME_MED.FIELDINT) + if (myObj == None): + myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) + return myObj + else: + print "ERROR: No Field Object stored in this Study" + return None + +med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "Med") + +medDir = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + +def importMedFrom(medDir,medFile): + medFile = medDir + medFile + med_comp.readStructFileWithFieldType(medFile,salome.myStudyName) + sg.updateObjBrowser(1) + +def importMed(medFile): + importMedFrom(medDir,medFile) + +#med_obj = getMedObjectFromStudy() +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +print "Use importMed(medFile) or importMedFrom(medDir,medFile) functions !" + +#myField = getFieldObjectFromStudy(2,1) +#myResult = myVisu.ImportMed(myField) +#aMesh = myVisu.CreateMesh(myResult); +#aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0) +#if(myField.getNumberOfComponents() > 1) : +# aScalarMap = myVisu.CreateVectors(myResult,myField.getName(),0) + +#myResult = myVisu.ImportFile(medFile) +#aMesh = myVisu.CreateMesh(myResult); +#aScalarMap = myVisu.CreateScalarMap(myResult,myField.getName(),0) +#if(myField.getNumberOfComponents() > 1) : +# aScalarMap = myVisu.CreateCutPlanes(myResult,myField.getName(),0) diff --git a/src/VISU_SWIG/visu_table.py b/src/VISU_SWIG/visu_table.py new file mode 100644 index 00000000..b09b2901 --- /dev/null +++ b/src/VISU_SWIG/visu_table.py @@ -0,0 +1,158 @@ +#============================================================================== +# File : visu_table.py +# Created : 20/01/03 +# Author : Vadim SANDLER +# Project : SALOME +# Copyright : Open CASCADE +# $Header$ +#============================================================================== + +# ============================================================================ +# Check attributes creation : Integer, Real, Comment, Tables +# ============================================================================ +import salome +import math +import SALOMEDS +import VISU + +# >>> Getting study builder ================================================== +myStudy = salome.myStudy +myBuilder = myStudy.NewBuilder() + +# >>> Getting (loading) VISU component ======================================= +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") +myComponent = myStudy.FindComponent("VISU") +myVisu.SetCurrentStudy(myStudy) +if not myComponent: + myComponent = myBuilder.NewComponent("VISU") + aName = myBuilder.FindOrCreateAttribute(myComponent, "AttributeName") + aName.SetValue( salome.sg.getComponentUserName("VISU") ) + myBuilder.DefineComponentInstance(myComponent,myVisu) + +# >>> Creating object with Table of integer ================================== +myTIntObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeName") +AName.SetValue("Table Of Integer") +AIntTable = myBuilder.FindOrCreateAttribute(myTIntObject, "AttributeTableOfInteger") + +a=[1,2,3,4,5,6,7,8,9,10] +AIntTable.AddRow(a) +a=[110,120,130,140,150,160,170,180,190,200] +AIntTable.AddRow(a) +a=[-1,272,0,0,-642,10000,13,578,-578,99] +AIntTable.AddRow(a) +AIntTable.SetTitle("TEST table of integer") +AIntTable.SetRowTitle(1,"FR") +AIntTable.SetRowUnit(1,"m/h") +AIntTable.SetRowTitle(2,"SR") +AIntTable.SetRowUnit(2,"s") +AIntTable.SetRowTitle(3,"TR") +AIntTable.SetRowUnit(3,"$") +c=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"] +AIntTable.SetColumnTitles(c) + +# >>> Creating object with Table of real ===================================== +myTRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeName") +AName.SetValue("Table Of Real") +ARealTable = myBuilder.FindOrCreateAttribute(myTRealObject, "AttributeTableOfReal") + +k={} +l={} +for j in range(0,20): + k[j] = j*10+1 + l[j] = "C"+str(j+1) +ARealTable.AddRow(k.values()) +ARealTable.SetRowTitle(1, "Row 0") +ARealTable.SetRowUnit(1, "Hz") +ARealTable.SetColumnTitles(l.values()) +for i in range(1,11): + for j in range(1,21): + if j % 2 == 1: + k[j] = math.log10(j*30*math.pi/180) * 20 + i * 15 + j*5 + else: + k[j] = math.sin(j*30*math.pi/180) * 20 + i * 15 + j*5 + ARealTable.AddRow(k.values()) + ARealTable.SetRowTitle(i+1, "Row " + str(i)) + ARealTable.SetRowUnit(i+1, "Wt") +ARealTable.SetTitle("TEST table of real") + +# >>> Creating object with integer attribute ================================= +myIntObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeName") +AName.SetValue("Integer") +AInt = myBuilder.FindOrCreateAttribute(myIntObject, "AttributeInteger") +AInt.SetValue(123) + +# >>> Creating object with real attribute ==================================== +myRealObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeName") +AName.SetValue("Real") +AReal = myBuilder.FindOrCreateAttribute(myRealObject, "AttributeReal") +AReal.SetValue(-56.9634) + +# >>> Creating object with comment attribute ================================= +myCmtObject = myBuilder.NewObject(myComponent) +AName = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeName") +AName.SetValue("Comment") +ACmt = myBuilder.FindOrCreateAttribute(myCmtObject, "AttributeComment") +ACmt.SetValue("Just a comment") + +# >>> Create VISU presentable objects ======================================== +# >>> Create table of real +myVisuTableReal = myVisu.CreateTable( myTRealObject.GetID() ) + +# >>> Create curves +myCurve1 = myVisu.CreateCurve( myVisuTableReal, 1, 2 ) +myCurve2 = myVisu.CreateCurve( myVisuTableReal, 1, 3 ) +myCurve3 = myVisu.CreateCurve( myVisuTableReal, 1, 4 ) +myCurve4 = myVisu.CreateCurve( myVisuTableReal, 1, 6 ) +myCurve5 = myVisu.CreateCurve( myVisuTableReal, 1, 8 ) +myCurve6 = myVisu.CreateCurve( myVisuTableReal, 1, 11 ) + +# >>> Set curve parameters +myCurve4.SetMarker( VISU.Curve.RECTANGLE ) +myCurve4.SetLine( VISU.Curve.DASHLINE, 3 ) +myCurve4.SetColor( SALOMEDS.Color(0, 0.7, 0.3) ) +myCurve6.SetMarker( VISU.Curve.LTRIANGLE ) +myCurve6.SetLine( VISU.Curve.DOTLINE, 2 ) +myCurve6.SetColor( SALOMEDS.Color(0.2, 0.2, 0.9) ) + +# >>> Create container and insert curves +myContainer1 = myVisu.CreateContainer() +myContainer1.AddCurve(myCurve1) +myContainer1.AddCurve(myCurve2) +myContainer1.AddCurve(myCurve3) +myContainer1.AddCurve(myCurve4) +myContainer1.AddCurve(myCurve5) +myContainer1.AddCurve(myCurve6) + +# >>> Create container and insert curves +myContainer2 = myVisu.CreateContainer() +myContainer2.AddCurve(myCurve4) + +# >>> Create table of integer +myVisuTableInt = myVisu.CreateTable( myTIntObject.GetID() ) + +# >>> Create curves +myCurve101 = myVisu.CreateCurve( myVisuTableInt, 1, 1 ) +myCurve102 = myVisu.CreateCurve( myVisuTableInt, 1, 3 ) + +# >>> Set curve parameters +myCurve101.SetMarker( VISU.Curve.RECTANGLE ) +myCurve101.SetLine( VISU.Curve.DASHLINE, 3 ) +myCurve101.SetColor( SALOMEDS.Color(0, 0.7, 0.3) ) +myCurve101.SetTitle( "Very useful data" ) + +# >>> Create container and insert curves +myContainer3 = myVisu.CreateContainer() +myContainer3.AddCurve(myCurve101) +myContainer3.AddCurve(myCurve102) + +# >>> Updating Object Browser ================================================ +salome.sg.updateObjBrowser(1) + +# ============================================================================ + + + diff --git a/src/VISU_SWIG/visu_view.py b/src/VISU_SWIG/visu_view.py new file mode 100644 index 00000000..92ade37d --- /dev/null +++ b/src/VISU_SWIG/visu_view.py @@ -0,0 +1,60 @@ +#============================================================================== +# File : test_table.py +# Created : 20/01/03 +# Author : Alexey Petrov +# Project : SALOME +# Copyright : Open CASCADE +# $Header: +#============================================================================== + +import SALOMEDS +import VISU + +import salome +import SALOMEDS +from VISU import * + +from visu_table import * + +myViewMan = myVisu.GetViewManager() + +myTable = myViewMan.CreateTableView(myVisuTableReal) +myTitle = myTable.GetTitle() +myTable.SetTitle('Changed Title') + +myPlot = myViewMan.CreateXYPlot(myContainer1) +myTitle = myPlot.GetTitle() +myPlot.SetTitle('Change the title from python') + +mySubTitle = myPlot.GetSubTitle() +myPlot.SetSubTitle(myTitle) + +myXTitle = myPlot.GetXTitle() +myYTitle = myPlot.GetYTitle() +myPlot.SetXTitle(myYTitle) +myPlot.SetYTitle(myXTitle) + +myPlot.GetMarkerSize() +myPlot.SetMarkerSize(20) +myPlot.GetMarkerSize() +myPlot.ShowLegend(0) + +myPlot.SetCurveType(VISU.XYPlot.POINTS) +myPlot.SetCurveType(VISU.XYPlot.MULTYLINE) +myPlot.GetCurveType() +myPlot.SetCurveType(VISU.XYPlot.SPLINE) + +myPlot.SetHorScaling(VISU.LOGARITHMIC) +myPlot.EnableXGrid(1,3,1,4) +myPlot.SetHorScaling(VISU.LINEAR) +myPlot.EnableXGrid(1,10,1,10) +myPlot.GetHorScaling() + +myPlot.SetVerScaling(VISU.LOGARITHMIC) +myPlot.GetVerScaling() +myPlot.EnableYGrid(1,2,1,10) + +myPlot.ShowLegend(1) +myPlot.SetMarkerSize(5) +myPlot.GetMarkerSize() + diff --git a/src/VISU_SWIG/visu_view3d.py b/src/VISU_SWIG/visu_view3d.py new file mode 100644 index 00000000..d584fdae --- /dev/null +++ b/src/VISU_SWIG/visu_view3d.py @@ -0,0 +1,64 @@ +import os +import salome +from VISU import * +import SALOMEDS +from libSALOME_Swig import * +sg = SALOMEGUI_Swig() + +myVisu = salome.lcc.FindOrLoadComponent("FactoryServer", "VISU") + +#medFile = "fra.med" +#myFieldName = "VITESSE"; + +medFile = "minimail.dat" +myFieldName = "Pressures"; + +medFile = "brideResultats.dat" +myFieldName = "VM_Elem."; + +medFile = os.getenv('SALOME_ROOT_DIR') + '/../SALOME_ROOT/data/' + medFile +myResult = myVisu.ImportFile(medFile) + +aMesh = myVisu.CreateMesh(myResult); +aScalarMap = myVisu.CreateScalarMap(myResult,myFieldName,0) +aScalarMap.SetScaling(LOGARITHMIC) +aCutPlanes = myVisu.CreateCutPlanes(myResult,myFieldName,0) +aCutPlanes.SetScaling(LOGARITHMIC) +aIsoSurfaces = myVisu.CreateIsoSurfaces(myResult,myFieldName,0) +aIsoSurfaces.SetScaling(LINEAR) + +myViewManager = myVisu.GetViewManager(); +#myView = myViewManager.Create3DView(); +myView = myViewManager.GetCurrent3DView(); +myView.SetFocalPoint([0,0,0]); +myView.SetParallelScale(2); +aPoint = myView.GetPointOfView(); +aPoint[0] = aPoint[0] + 10; +myView.SetPointOfView(aPoint); +myView.ScaleView(View3D.YAxis,10.0); +myView.ScaleView(View3D.XAxis,3.0); +aColor = SALOMEDS.Color(0.0,0.3,1.0) +myView.SetBackground(aColor); +myView.Update(); +myView.Display(aScalarMap); +#myView.Erase(aScalarMap); +#myView.DisplayOnly(aCutPlanes); +myView.SaveViewParams('AAA') + +myView.RemoveScale(); +myView.FitAll(); +aColor = SALOMEDS.Color(0.0,0.0,0.0) +myView.SetBackground(aColor); +myView.SaveViewParams('BBB'); + +aColor = SALOMEDS.Color(1.0,1.0,1.0) +myView.SetBackground(aColor); +myView.ScaleView(View3D.ZAxis,0.5); +myView.SaveViewParams('CCC'); + +myView.RestoreViewParams('AAA'); + +sg.updateObjBrowser(0) + + +