From: ouv Date: Tue, 20 Apr 2010 07:45:37 +0000 (+0000) Subject: Refactoring (removing obsolete GUITOOLS and VVTK packages) + improvement of VISU_Tabl... X-Git-Tag: V5_1_4rc1~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=364a7c300d67725b8d09080ee7c0268f93cd530e;p=modules%2Fvisu.git Refactoring (removing obsolete GUITOOLS and VVTK packages) + improvement of VISU_TableDlg class, introducing edition and sorting features (intermediate state) --- diff --git a/configure.ac b/configure.ac index 63c66e53..fb8b8eae 100644 --- a/configure.ac +++ b/configure.ac @@ -387,8 +387,6 @@ AC_OUTPUT([ \ src/CONVERTOR/Makefile \ src/PIPELINE/Makefile \ src/OBJECT/Makefile \ - src/VVTK/Makefile \ - src/GUITOOLS/Makefile \ src/VISU_I/Makefile \ src/VISUGUI/Makefile \ src/VISU_SWIG/Makefile \ diff --git a/resources/Makefile.am b/resources/Makefile.am index c9ae4291..6a4eee14 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -58,14 +58,10 @@ Visu_import_med.png \ Visu_isosurfaces.png \ Visu_load_texture.png \ Visu_ok.png \ -Visu_PlaneSegmentation.png \ Visu_plot2d.png \ Visu_plot3d.png \ Visu_point_selection.png \ Visu_points.png \ -Visu_recording_pause.png \ -Visu_recording_play.png \ -Visu_recording_start.png \ Visu_recording_stop.png \ Visu_remove.png \ Visu_sameas.png \ @@ -82,7 +78,6 @@ Visu_selectioncell.png \ Visu_selectionedge.png \ Visu_selectionpoint.png \ Visu_selectonly.png \ -Visu_SphereSegmentation.png \ Visu_streamlines.png \ Visu_surface.png \ Visu_tree_container.png \ @@ -117,7 +112,6 @@ Visu_tree_vectors_gr.png \ Visu_tree_vectors.png \ Visu_tree_visu.png \ Visu_vectors.png \ -Visu_vvtk_switch.png \ Visu_wireframe.png \ Visu_slider_more.png \ Visu_slider_avi.png \ diff --git a/resources/Visu_PlaneSegmentation.png b/resources/Visu_PlaneSegmentation.png deleted file mode 100644 index 16bee54a..00000000 Binary files a/resources/Visu_PlaneSegmentation.png and /dev/null differ diff --git a/resources/Visu_SphereSegmentation.png b/resources/Visu_SphereSegmentation.png deleted file mode 100644 index 3b596448..00000000 Binary files a/resources/Visu_SphereSegmentation.png and /dev/null differ diff --git a/resources/Visu_recording_pause.png b/resources/Visu_recording_pause.png deleted file mode 100644 index f181a0f6..00000000 Binary files a/resources/Visu_recording_pause.png and /dev/null differ diff --git a/resources/Visu_recording_play.png b/resources/Visu_recording_play.png deleted file mode 100644 index 7724f48b..00000000 Binary files a/resources/Visu_recording_play.png and /dev/null differ diff --git a/resources/Visu_recording_start.png b/resources/Visu_recording_start.png deleted file mode 100644 index 5b71dc51..00000000 Binary files a/resources/Visu_recording_start.png and /dev/null differ diff --git a/resources/Visu_vvtk_switch.png b/resources/Visu_vvtk_switch.png deleted file mode 100644 index b0a9c807..00000000 Binary files a/resources/Visu_vvtk_switch.png and /dev/null differ diff --git a/src/Makefile.am b/src/Makefile.am index 7e23c911..19cc6988 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,4 +21,4 @@ # # $Header$ # -SUBDIRS = CONVERTOR PIPELINE OBJECT GUITOOLS VVTK VISU_I VISUGUI VISU_SWIG ENGINE +SUBDIRS = CONVERTOR PIPELINE OBJECT VISU_I VISUGUI VISU_SWIG ENGINE diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index aff94dc9..731f9769 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -70,7 +70,9 @@ salomeinclude_HEADERS= \ VisuGUI_Slider.h \ VisuGUI_InputPane.h \ VisuGUI_FieldFilter.h \ - VisuGUI_ValuesLabelingDlg.h + VisuGUI_ValuesLabelingDlg.h \ + VisuGUI_PrimitiveBox.h \ + VisuGUI_SizeBox.h dist_libVISU_la_SOURCES= \ VisuGUI.cxx \ @@ -123,7 +125,9 @@ dist_libVISU_la_SOURCES= \ VisuGUI_ClippingPanel.cxx \ VisuGUI_ClippingPlaneDlg.cxx \ VisuGUI_FilterScalarsDlg.cxx \ - VisuGUI_ValuesLabelingDlg.cxx + VisuGUI_ValuesLabelingDlg.cxx \ + VisuGUI_PrimitiveBox.cxx \ + VisuGUI_SizeBox.cxx MOC_FILES= \ VisuGUI_moc.cxx \ @@ -169,7 +173,9 @@ MOC_FILES= \ VisuGUI_ClippingPanel_moc.cxx \ VisuGUI_ClippingPlaneDlg_moc.cxx \ VisuGUI_FilterScalarsDlg_moc.cxx \ - VisuGUI_ValuesLabelingDlg_moc.cxx + VisuGUI_ValuesLabelingDlg_moc.cxx \ + VisuGUI_PrimitiveBox_moc.cxx \ + VisuGUI_SizeBox_moc.cxx nodist_libVISU_la_SOURCES=$(MOC_FILES) @@ -182,7 +188,7 @@ libVISU_la_CPPFLAGS= \ $(BOOST_CPPFLAGS) \ $(GUI_CXXFLAGS) \ $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \ - -I$(srcdir)/../VVTK -I$(srcdir)/../OBJECT -I$(srcdir)/../VISU_I -I$(srcdir)/../GUITOOLS \ + -I$(srcdir)/../OBJECT -I$(srcdir)/../VISU_I \ -I$(top_builddir)/idl -I$(srcdir)/../CONVERTOR -I$(srcdir)/../PIPELINE libVISU_la_LDFLAGS= \ @@ -190,8 +196,7 @@ libVISU_la_LDFLAGS= \ $(CAS_LDFLAGS) -lTKV3d \ $(KERNEL_LDFLAGS) -lSalomeNS -lSalomeDSClient \ $(GUI_LDFLAGS) -lSVTK -lSPlot2d -lSalomePrs -lOCCViewer \ - ../VVTK/libVVTK.la ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la \ - ../GUITOOLS/libVISUGUITOOLS.la \ + ../OBJECT/libVisuObject.la ../VISU_I/libVISUEngineImpl.la \ ../../idl/libSalomeIDLVISU.la if MED_ENABLE_MULTIPR diff --git a/src/VISUGUI/VISU_images.ts b/src/VISUGUI/VISU_images.ts index a5b74650..d7c807b7 100644 --- a/src/VISUGUI/VISU_images.ts +++ b/src/VISUGUI/VISU_images.ts @@ -327,42 +327,10 @@ ICON_VECTORS Visu_vectors.png - - ICON_VVTK_INTERACTOR_STYLE_SWITCH - Visu_vvtk_switch.png - - - ICON_VVTK_PLANE_SEGMENTATION_SWITCH - Visu_PlaneSegmentation.png - - - ICON_VVTK_RECORDING_PAUSE - Visu_recording_pause.png - - - ICON_VVTK_RECORDING_PLAY - Visu_recording_play.png - - - ICON_VVTK_RECORDING_START - Visu_recording_start.png - - - ICON_VVTK_RECORDING_STOP - Visu_recording_stop.png - ICON_SWEEP_STOP Visu_recording_stop.png - - ICON_VVTK_SELECTION_MODE_SWITCH - Visu_points.png - - - ICON_VVTK_SPHERE_SEGMENTATION_SWITCH - Visu_SphereSegmentation.png - ICON_WIREFRAME Visu_wireframe.png diff --git a/src/VISUGUI/VISU_msg_en.ts b/src/VISUGUI/VISU_msg_en.ts index 84bdd1e2..7350c5c2 100644 --- a/src/VISUGUI/VISU_msg_en.ts +++ b/src/VISUGUI/VISU_msg_en.ts @@ -585,418 +585,6 @@ Input value precision can be adjusted using No appropriate objects selected - - VVTK_MainWindow - - DSC_VVTK_RECORDING_PAUSE - Pause recording - - - DSC_VVTK_RECORDING_PLAY - Play recording - - - DSC_VVTK_RECORDING_START - Start recording - - - DSC_VVTK_RECORDING_STOP - Stop recording - - - LBL_TOOLBAR_RECORD_LABEL - Recording Operations - - - MNU_VVTK_RECORDING_PAUSE - Pause recording - - - MNU_VVTK_RECORDING_PLAY - Play recording - - - MNU_VVTK_RECORDING_START - Start recording - - - MNU_VVTK_RECORDING_STOP - Stop recording - - - MSG_NO_AVI_MAKER - Tool jpeg2yuv, necessary for AVI recording, is not available. -Please, refer to the documentation. - - - - VVTK_MainWindow1 - - DSC_VVTK_INTERACTOR_STYLE_SWITCH - Interaction Style Switch - - - DSC_VVTK_PLANE_SEGMENTATION_SWITCH - Plane Segmentation - - - DSC_VVTK_SELECTION_MODE_SWITCH - Selection Mode Switch - - - DSC_VVTK_SPHERE_SEGMENTATION_SWITCH - Sphere Segmentation - - - LBL_TOOLBAR_GAUSS_LABEL - Gauss Viewer Tools - - - MNU_VVTK_INTERACTOR_STYLE_SWITCH - Interaction Style Switch - - - MNU_VVTK_PLANE_SEGMENTATION_SWITCH - Plane Segmentation - - - MNU_VVTK_SELECTION_MODE_SWITCH - Selection Mode Switch - - - MNU_VVTK_SPHERE_SEGMENTATION_SWITCH - Sphere Segmentation - - - - VVTK_PickingDlg - - BELOW_POINT - Centered below the point - - - CAMERA_TITLE - Movement of the camera - - - CURSOR_SIZE - Size of the cursor : - - - CURSOR_TITLE - Cursor - - - DISPLAY_PARENT_MESH - Display parent mesh element - - - INFO_WINDOW_TITLE - Information window - - - PARENT_MESH_TITLE - Parent mesh element - - - PICKING_DLG_TITLE - Picking - - - POINT_TOLERANCE - Point tolerance : - - - POSITION - Position : - - - PYRAMID_HEIGHT - Height of the pyramids : - - - SELECTION_COLOR - Selection cursor color : - - - STEP_NUMBER - Number of steps between two positions : - - - TOLERANCE_TITLE - Tolerance - - - TOP_LEFT_CORNER - Top-left corner of the 3D view - - - TRANSPARENCY - Transparency : - - - ZOOM_FACTOR - Zoom at first selected point (ratio) : - - - DATA_POSITION - Position - - - PARENT_ELEMENT - Parent mesh element ID: - - - LOCAL_POINT - Local Gauss Point ID: - - - - VVTK_PrimitiveBox - - ALPHA_TEXTURE - Alpha Channel Texture (16x16) : - - - ALPHA_THRESHOLD - Alpha Channel Threshold : - - - CLAMP - Maximum Size (Clamp) : - - - FACE_LIMIT - Notify when number of faces exceeds : - - - FACE_NUMBER - Number of faces : - - - GEOMETRICAL_SPHERE - Geometrical Sphere - - - MAIN_TEXTURE - Main Texture (16x16) : - - - OPENGL_POINT - OpenGL Point - - - POINT_SPRITE - Point Sprite - - - PRIMITIVE_TITLE - Primitive - - - RESOLUTION - Resolution : - - - - VVTK_RecorderDlg - - ALL_DISLPAYED_FRAMES - Recording all displayed frames - - - CLOSE - Close - - - DLG_RECORDER_TITLE - Recorder - - - FILE_NAME - Save to file : - - - FLT_ALL_FILES - All Files (*.*) - - - FLT_AVI_FILES - AVI Files (*.avi) - - - FPS - FPS : - - - PROGRESSIVE - Progressive - - - QUALITY - Quality : - - - RECORDING_MODE - Mode : - - - SETTINGS - Settings - - - SKIPPED_FRAMES - Recording at a given FPS - - - START - Start - - - - VVTK_SegmentationCursorDlg - - DEPTH - Depth of the cursor: - - - DEPTH_TITLE - Depth - - - DIRECTION_DX - DX: - - - DIRECTION_DY - DY: - - - DIRECTION_DZ - DZ: - - - DIRECTION_TITLE - Direction - - - GAUSS_POINTS_TAB - Gauss Points - - - INCREMENT - +/- Ratio : - - - INSIDE_GAUSS_POINTS - Inside Cursor Gauss Points Presentation - - - MAGNIFICATION - Magnification (%) : - - - MAGNIFICATION_TITLE - Magnification - - - ORIGIN_TITLE - Origin - - - ORIGIN_X - X: - - - ORIGIN_Y - Y: - - - ORIGIN_Z - Z: - - - OUTSIDE_GAUSS_POINTS - Outside Cursor Gauss Points Presentation - - - RADIUS - Radius of the cursor : - - - RADIUS_TITLE - Radius - - - RATIO - +/- Ratio : - - - SEGMENTATION_CURSOR_DLG_TITLE - Segmentation Cursor - - - SEGMENTATION_CURSOR_TAB - Segmentation Cursor - - - - VVTK_SizeBox - - COLOR - Color : - - - COLOR_TITLE - Color - - - GEOM_SIZE - Size of points (%) : - - - INCREMENT - +/- Ratio : - - - MAGNIFICATION - Magnification (%) : - - - MAX_SIZE - max size (%) : - - - MIN_SIZE - Range values for min size (%) : - - - OUTSIDE_SIZE - Percentage of normal size(%) : - - - SIZE_TITLE - Size - - - UNIFORM_COLOR - Uniform Color - - - - VVTK_ViewManager - - VTK_VIEW_TITLE - Gauss scene:%1 - viewer:%2 - - - - VVTK_ViewWindow - - LBL_TOOLBAR_LABEL - GAUSS viewer tools - - VisuGUI @@ -3431,72 +3019,6 @@ Please select another field. Time step (second): - - VisuGUI_TableDlg - - EDIT_TABLE_TLT - Edit Table - - - ERR_TABLE_NOT_AVAILABLE - Table is not available - - - TABLE_OF_INTEGER_TLT - Table of integer - - - TABLE_OF_REAL_TLT - Table of real - - - VIEW_TABLE_TLT - View Table - - - - VisuGUI_TableWidget - - ADD_COLUMN_BTN - Add Column - - - ADD_ROW_BTN - Add Row - - - ADJUST_CELLS_BTN - Adjust Cells - - - CLEAR_BTN - Clear - - - REMOVE_COLUMN_BTN - Remove Column(s) - - - REMOVE_ROW_BTN - Remove Row(s) - - - SELECT_ALL_BTN - Select All - - - SET_TITLE_TLT - Set title - - - TITLE_LBL - Title: - - - UNITS_TLT - Units - - VisuGUI_TextPrefDlg @@ -4277,4 +3799,75 @@ Please, refer to the QT documentation. Shrink Factor: + + VISU_TableDlg + + ERR_TABLE_NOT_AVAILABLE + Table is not available + + + TABLE_OF_INTEGER_TLT + Table of integer + + + TABLE_OF_REAL_TLT + Table of real + + + TABLE_UNKNOWN_TLT + Table of unknown + + + VIEW_TABLE_TLT + View Table + + + ALLOW_EDIT_CHECK + Enable editing + + + DO_UPDATE_CHECK + Immediate update + + + ADD_COLUMN_BTN + Add Column + + + ADD_ROW_BTN + Add Row + + + ADJUST_CELLS_BTN + Adjust Cells + + + CLEAR_BTN + Clear + + + REMOVE_COLUMN_BTN + Remove Column(s) + + + REMOVE_ROW_BTN + Remove Row(s) + + + SELECT_ALL_BTN + Select All + + + SET_TITLE_TLT + Set title + + + TITLE_LBL + Title: + + + UNITS_TLT + Units + + diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index b36302cd..c801bfe2 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -151,7 +151,7 @@ #include "VISU_Vectors_i.hh" #include "VisuGUI_VectorsDlg.h" -#include "VisuGUI_TableDlg.h" +#include "VISU_TableDlg.h" #include "VisuGUI_FileInfoDlg.h" #include "SALOMEconfig.h" @@ -1512,19 +1512,19 @@ VisuGUI Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO; VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase; _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject; - if(VISU::Table_i* aTable = dynamic_cast(aBase)) + if(VISU::Table_i* aTable = dynamic_cast(aBase)) { aSObject = GetCStudy( GetAppStudy( this ) )->FindObjectID( aTable->GetObjectEntry() ); - - if( !IsSObjectTable( aSObject ) ) - return; - - VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ), - aSObject, - false, - //SAL2670 Orientation of show tables - VisuGUI_TableDlg::ttAuto, - Qt::Vertical ); - dlg->show(); + if( IsSObjectTable( aSObject ) ) { + VISU_TableDlg* dlg = new VISU_TableDlg( GetDesktop( this ), + GetCStudy( GetAppStudy( this ) ), + aTable, + false, + //SAL2670 Orientation of show tables + VISU_TableDlg::ttAuto, + Qt::Vertical ); + dlg->show(); + } + } } //---------------------------------------------------------------------------- diff --git a/src/VISUGUI/VisuGUI_CacheDlg.cxx b/src/VISUGUI/VisuGUI_CacheDlg.cxx index 1bdcc4eb..7fb6dcdc 100644 --- a/src/VISUGUI/VisuGUI_CacheDlg.cxx +++ b/src/VISUGUI/VisuGUI_CacheDlg.cxx @@ -28,8 +28,6 @@ #include "VisuGUI_Tools.h" -#include - #include "VISU_PipeLine.hxx" #include "SUIT_Desktop.h" diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 60e9f253..3ef4b9f4 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -25,8 +25,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" -#include - #include "VISU_Prs3d_i.hh" #include "VISU_Result_i.hh" #include "VISU_ColoredPrs3dHolder_i.hh" diff --git a/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx index 0f798a04..b31b2f8f 100644 --- a/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingPlaneDlg.cxx @@ -24,8 +24,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" -#include - #include #include diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index 10fc0ea7..3d922c03 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -31,7 +31,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" -#include #include "VISU_Gen_i.hh" #include "VISU_CutLines_i.hh" @@ -55,7 +54,7 @@ //TO DO //#include "OB_Browser.h" -#include "VisuGUI_TableDlg.h" +#include "VISU_TableDlg.h" #include #include diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index 412e8918..d94c761e 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -33,7 +33,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" -#include #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_CutPlanes_i.hh" @@ -42,7 +41,7 @@ //#include "OB_Browser.h" -#include "VisuGUI_TableDlg.h" +#include "VISU_TableDlg.h" #include "SVTK_ViewWindow.h" diff --git a/src/VISUGUI/VisuGUI_CutSegmentDlg.cxx b/src/VISUGUI/VisuGUI_CutSegmentDlg.cxx index e10b0284..11975e2a 100644 --- a/src/VISUGUI/VisuGUI_CutSegmentDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutSegmentDlg.cxx @@ -30,8 +30,6 @@ #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" -#include - #include "VISU_Gen_i.hh" #include "VISU_CutSegment_i.hh" #include "VISU_ColoredPrs3dFactory.hh" diff --git a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx index 40475de9..dd332c39 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeAndScalarMapDlg.cxx @@ -28,7 +28,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" -#include #include "VISU_Result_i.hh" #include "VISU_DeformedShapeAndScalarMap_i.hh" diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index 052b90dd..b903c85c 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -32,8 +32,6 @@ #include "VisuGUI.h" #include "VisuGUI_Prs3dTools.h" -#include - #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_DeformedShape_i.hh" #include "VisuGUI_ViewTools.h" diff --git a/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx b/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx index 291c412f..a9b6bb07 100644 --- a/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx +++ b/src/VISUGUI/VisuGUI_FeatureEdgesPanel.cxx @@ -30,8 +30,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" -#include - #include #include #include diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index ab9baad0..c37c7857 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -30,8 +30,8 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" - -#include +#include "VisuGUI_PrimitiveBox.h" +#include "VisuGUI_SizeBox.h" #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_GaussPoints_i.hh" @@ -40,9 +40,6 @@ #include "VISU_OpenGLPointSpriteMapper.hxx" #include "VISU_Convertor.hxx" -#include "VVTK_PrimitiveBox.h" -#include "VVTK_SizeBox.h" - #include "LightApp_Application.h" #include "SalomeApp_Module.h" #include "SalomeApp_IntSpinBox.h" @@ -853,11 +850,11 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule): aVBLay->setSpacing(6); // Primitive - myPrimitiveBox = new VVTK_PrimitiveBox( aBox ); + myPrimitiveBox = new VisuGUI_PrimitiveBox( aBox ); aVBLay->addWidget( myPrimitiveBox ); // Size - mySizeBox = new VVTK_SizeBox( aBox ); + mySizeBox = new VisuGUI_SizeBox( aBox ); aVBLay->addWidget( mySizeBox ); // Deformed Shape @@ -961,7 +958,7 @@ void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, myPrimitiveBox->setResolution( myPrsCopy->GetResolution() ); myPrimitiveBox->setFaceLimit( myPrsCopy->GetFaceLimit() ); - mySizeBox->setType( isResults || isDeformed ? VVTK_SizeBox::Results : VVTK_SizeBox::Geometry ); + mySizeBox->setType( isResults || isDeformed ? VisuGUI_SizeBox::Results : VisuGUI_SizeBox::Geometry ); mySizeBox->setGeomSize( myPrsCopy->GetGeomSize() ); mySizeBox->setMinSize( myPrsCopy->GetMinSize() ); mySizeBox->setMaxSize( myPrsCopy->GetMaxSize() ); @@ -1053,7 +1050,7 @@ void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on ) if( on )//myDefShapeButton->isChecked() ) { myDefShapeBox->show(); - mySizeBox->setType( VVTK_SizeBox::Results ); + mySizeBox->setType( VisuGUI_SizeBox::Results ); } else myDefShapeBox->hide(); diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index 5f3d4ba2..82a0f92c 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -34,8 +34,8 @@ class SalomeApp_DoubleSpinBox; class SalomeApp_Module; class SalomeApp_IntSpinBox; -class VVTK_PrimitiveBox; -class VVTK_SizeBox; +class VisuGUI_PrimitiveBox; +class VisuGUI_SizeBox; class VisuGUI_TextPrefDlg; class VisuGUI_InputPane; @@ -159,8 +159,8 @@ private: QRadioButton* myGeometryButton; QRadioButton* myDefShapeButton; - VVTK_PrimitiveBox* myPrimitiveBox; - VVTK_SizeBox* mySizeBox; + VisuGUI_PrimitiveBox* myPrimitiveBox; + VisuGUI_SizeBox* mySizeBox; QGroupBox* myDefShapeBox; SalomeApp_DoubleSpinBox* myScaleSpinBox; diff --git a/src/VISUGUI/VisuGUI_OffsetDlg.cxx b/src/VISUGUI/VisuGUI_OffsetDlg.cxx index 9c65f507..b3687e45 100644 --- a/src/VISUGUI/VisuGUI_OffsetDlg.cxx +++ b/src/VISUGUI/VisuGUI_OffsetDlg.cxx @@ -40,8 +40,6 @@ #include "SUIT_MessageBox.h" #include "SUIT_ResourceMgr.h" -#include - // VTK Includes #include "vtkRenderer.h" diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index d0b9a6ba..246a0d73 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -31,7 +31,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" -#include #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_ViewManager_i.hh" diff --git a/src/VISUGUI/VisuGUI_PrimitiveBox.cxx b/src/VISUGUI/VisuGUI_PrimitiveBox.cxx new file mode 100644 index 00000000..13ec842c --- /dev/null +++ b/src/VISUGUI/VisuGUI_PrimitiveBox.cxx @@ -0,0 +1,377 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// VISU VISUGUI : GUI of VISU component +// File : VisuGUI_PrimitiveBox.cxx +// Author : Oleg UVAROV +// Module : VISU +// +#include "VisuGUI_PrimitiveBox.h" +#include "VisuGUI_Tools.h" + +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +VisuGUI_PrimitiveBox::VisuGUI_PrimitiveBox( QWidget* parent ) : + QGroupBox( parent ) +{ + SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); + + setTitle( tr( "PRIMITIVE_TITLE" ) ); + //setColumnLayout(0, Qt::Vertical ); + //layout()->setSpacing( 0 ); + //layout()->setMargin( 0 ); + + QGridLayout* aLayout = new QGridLayout( this ); + aLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + aLayout->setSpacing(6); + aLayout->setMargin(11); + + myPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite; + + QString aRootDir = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/"; + myMainTexture = aRootDir + "sprite_texture.bmp"; + myAlphaTexture = aRootDir + "sprite_alpha.bmp"; + + // Primitive Type + QGroupBox* aPrimitiveTypeGroup = new QGroupBox( this ); + aPrimitiveTypeGroup->setMinimumWidth( 450 ); + QHBoxLayout* aPrimLayout = new QHBoxLayout( aPrimitiveTypeGroup ); + aPrimLayout->setMargin( 0 ); + + //QButtonGroup* aPrimitiveTypeGroup = new QButtonGroup( 3, Qt::Horizontal, this, "PrimitiveTypeGroup" ); + //aPrimitiveTypeGroup->setMinimumWidth( 450 ); + //aPrimitiveTypeGroup->setRadioButtonExclusive( true ); + //aPrimitiveTypeGroup->setFrameStyle( QFrame::NoFrame ); + //aPrimitiveTypeGroup->layout()->setMargin( 0 ); + + myPointSpriteButton = new QRadioButton( tr( "POINT_SPRITE" ), aPrimitiveTypeGroup ); + myOpenGLPointButton = new QRadioButton( tr( "OPENGL_POINT" ), aPrimitiveTypeGroup ); + myGeomSphereButton = new QRadioButton( tr( "GEOMETRICAL_SPHERE" ), aPrimitiveTypeGroup ); + + aPrimLayout->addWidget( myPointSpriteButton ); + aPrimLayout->addWidget( myOpenGLPointButton ); + aPrimLayout->addWidget( myGeomSphereButton ); + + aLayout->addWidget( aPrimitiveTypeGroup, 0, 0, 1, 2 ); + + // Clamp ( Point Sprite & OpenGL Point ) + myClampLabel = new QLabel( tr( "CLAMP" ), this ); + myClampSpinBox = new SalomeApp_DoubleSpinBox( this ); + VISU::initSpinBox( myClampSpinBox, 1.0, 512.0, 1.0, "parametric_precision" ); + myClampSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + aLayout->addWidget( myClampLabel, 1, 0 ); + aLayout->addWidget( myClampSpinBox, 1, 1, 1, 2 ); + + // Main Texture ( Point Sprite ) + myMainTextureLabel = new QLabel( tr( "MAIN_TEXTURE" ), this ); + myMainTextureLineEdit = new QLineEdit( this ); + myMainTextureButton = new QPushButton( this ); + myMainTextureButton->setAutoDefault( false ); + myMainTextureButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_LOAD_TEXTURE" ) ) ); + connect( myMainTextureButton, SIGNAL( clicked() ), this, SLOT( onBrowseMainTexture() ) ); + + aLayout->addWidget( myMainTextureLabel, 2, 0 ); + aLayout->addWidget( myMainTextureLineEdit, 2, 1 ); + aLayout->addWidget( myMainTextureButton, 2, 2 ); + + // Alpha Texture ( Point Sprite ) + myAlphaTextureLabel = new QLabel( tr( "ALPHA_TEXTURE" ), this ); + myAlphaTextureLineEdit = new QLineEdit( this ); + myAlphaTextureButton = new QPushButton( this ); + myAlphaTextureButton->setAutoDefault( false ); + myAlphaTextureButton->setIcon( aResourceMgr->loadPixmap( "VISU", tr( "ICON_LOAD_TEXTURE" ) ) ); + connect( myAlphaTextureButton, SIGNAL( clicked() ), this, SLOT( onBrowseAlphaTexture() ) ); + + aLayout->addWidget( myAlphaTextureLabel, 3, 0 ); + aLayout->addWidget( myAlphaTextureLineEdit, 3, 1 ); + aLayout->addWidget( myAlphaTextureButton, 3, 2 ); + + // Alpha Threshold ( Point Sprite ) + myAlphaThresholdLabel = new QLabel( tr( "ALPHA_THRESHOLD" ), this ); + myAlphaThresholdSpinBox = new SalomeApp_DoubleSpinBox( this ); + VISU::initSpinBox( myAlphaThresholdSpinBox, 0.0, 1.0, 0.1, "parametric_precision" ); + myAlphaThresholdSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + aLayout->addWidget( myAlphaThresholdLabel, 4, 0 ); + aLayout->addWidget( myAlphaThresholdSpinBox, 4, 1, 1, 2 ); + + // Resolution ( Geometrical Sphere ) + myResolutionLabel = new QLabel( tr( "RESOLUTION" ), this ); + myResolutionSpinBox = new SalomeApp_IntSpinBox( this ); + VISU::initSpinBox( myResolutionSpinBox, 3, 100, 1 ); + myResolutionSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + connect( myResolutionSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onResolutionChanged( int ) ) ); + + aLayout->addWidget( myResolutionLabel, 5, 0 ); + aLayout->addWidget( myResolutionSpinBox, 5, 1, 1, 2 ); + + // Number of faces ( Geometrical Sphere ) + myFaceNumberLabel = new QLabel( tr( "FACE_NUMBER" ), this ); + myFaceNumberLineEdit = new QLineEdit( this ); + myFaceNumberLineEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + myFaceNumberLineEdit->setEnabled( false ); + //myFaceNumberLineEdit->setReadOnly( true ); + + aLayout->addWidget( myFaceNumberLabel, 6, 0 ); + aLayout->addWidget( myFaceNumberLineEdit, 6, 1, 1, 2 ); + + // Notification ( Geometrical Sphere ) + myFaceLimitLabel = new QLabel( tr( "FACE_LIMIT" ), this ); + myFaceLimitSpinBox = new SalomeApp_IntSpinBox( this ); + VISU::initSpinBox( myFaceLimitSpinBox, 10, 1000000, 10 ); + myFaceLimitSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + aLayout->addWidget( myFaceLimitLabel, 7, 0 ); + aLayout->addWidget( myFaceLimitSpinBox, 7, 1, 1, 2 ); + + connect( myPointSpriteButton, SIGNAL( clicked() ), this, SLOT( onTogglePointSprite() ) ); + connect( myOpenGLPointButton, SIGNAL( clicked() ), this, SLOT( onToggleOpenGLPoint() ) ); + connect( myGeomSphereButton, SIGNAL( clicked() ), this, SLOT( onToggleGeomSphere() ) ); +} + +void VisuGUI_PrimitiveBox::onTogglePointSprite() +{ + myPrimitiveType = VISU_OpenGLPointSpriteMapper::PointSprite; + + myClampLabel->show(); + myClampSpinBox->show(); + + myMainTextureLabel->show(); + myMainTextureLineEdit->show(); + myMainTextureButton->show(); + + myAlphaTextureLabel->show(); + myAlphaTextureLineEdit->show(); + myAlphaTextureButton->show(); + + myAlphaThresholdLabel->show(); + myAlphaThresholdSpinBox->show(); + + myResolutionLabel->hide(); + myResolutionSpinBox->hide(); + + myFaceNumberLabel->hide(); + myFaceNumberLineEdit->hide(); + + myFaceLimitLabel->hide(); + myFaceLimitSpinBox->hide(); +} + +void VisuGUI_PrimitiveBox::onToggleOpenGLPoint() +{ + myPrimitiveType = VISU_OpenGLPointSpriteMapper::OpenGLPoint; + + myClampLabel->show(); + myClampSpinBox->show(); + + myMainTextureLabel->hide(); + myMainTextureLineEdit->hide(); + myMainTextureButton->hide(); + + myAlphaTextureLabel->hide(); + myAlphaTextureLineEdit->hide(); + myAlphaTextureButton->hide(); + + myAlphaThresholdLabel->hide(); + myAlphaThresholdSpinBox->hide(); + + myResolutionLabel->hide(); + myResolutionSpinBox->hide(); + + myFaceNumberLabel->hide(); + myFaceNumberLineEdit->hide(); + + myFaceLimitLabel->hide(); + myFaceLimitSpinBox->hide(); +} + +void VisuGUI_PrimitiveBox::onToggleGeomSphere() +{ + myPrimitiveType = VISU_OpenGLPointSpriteMapper::GeomSphere; + + myClampLabel->hide(); + myClampSpinBox->hide(); + + myMainTextureLabel->hide(); + myMainTextureLineEdit->hide(); + myMainTextureButton->hide(); + + myAlphaTextureLabel->hide(); + myAlphaTextureLineEdit->hide(); + myAlphaTextureButton->hide(); + + myAlphaThresholdLabel->hide(); + myAlphaThresholdSpinBox->hide(); + + myResolutionLabel->show(); + myResolutionSpinBox->show(); + + myFaceNumberLabel->show(); + myFaceNumberLineEdit->show(); + + myFaceLimitLabel->show(); + myFaceLimitSpinBox->show(); +} + +void VisuGUI_PrimitiveBox::onResolutionChanged( int theResolution ) +{ + setFaceNumber( 2 * theResolution * ( theResolution - 2 ) ); +} + +void VisuGUI_PrimitiveBox::setPrimitiveType( int theType ) +{ + myPrimitiveType = theType; + + switch( myPrimitiveType ) + { + case VISU_OpenGLPointSpriteMapper::PointSprite : + myPointSpriteButton->setChecked( true ); + onTogglePointSprite(); + break; + case VISU_OpenGLPointSpriteMapper::OpenGLPoint : + myOpenGLPointButton->setChecked( true ); + onToggleOpenGLPoint(); + break; + case VISU_OpenGLPointSpriteMapper::GeomSphere : + myGeomSphereButton->setChecked( true ); + onToggleGeomSphere(); + break; + default : break; + } +} + +float VisuGUI_PrimitiveBox::getClamp() const +{ + return myClampSpinBox->value(); +} + +void VisuGUI_PrimitiveBox::setClamp( float theClamp ) +{ + myClampSpinBox->setValue( theClamp ); +} + +void VisuGUI_PrimitiveBox::setClampMaximum( float theClampMaximum ) +{ + myClampSpinBox->setMaximum( theClampMaximum ); +} + +void VisuGUI_PrimitiveBox::setMainTexture( const QString& theMainTexture ) +{ + myMainTexture = theMainTexture; + myMainTextureLineEdit->setText( theMainTexture.section( '/', -1 ) ); +} + +void VisuGUI_PrimitiveBox::setAlphaTexture( const QString& theAlphaTexture ) +{ + myAlphaTexture = theAlphaTexture; + myAlphaTextureLineEdit->setText( theAlphaTexture.section( '/', -1 ) ); +} + +float VisuGUI_PrimitiveBox::getAlphaThreshold() const +{ + return myAlphaThresholdSpinBox->value(); +} + +void VisuGUI_PrimitiveBox::setAlphaThreshold( float theAlphaThreshold ) +{ + myAlphaThresholdSpinBox->setValue( theAlphaThreshold ); +} + +int VisuGUI_PrimitiveBox::getResolution() const +{ + return myResolutionSpinBox->value(); +} + +void VisuGUI_PrimitiveBox::setResolution( int theResolution ) +{ + myResolutionSpinBox->setValue( theResolution ); +} + +int VisuGUI_PrimitiveBox::getFaceNumber() const +{ + int aResolution = getResolution(); + return 2 * aResolution * ( aResolution - 2 ); + //return myFaceNumberLineEdit->text().toInt(); +} + +void VisuGUI_PrimitiveBox::setFaceNumber( int theFaceNumber ) +{ + myFaceNumberLineEdit->setText( QString::number( theFaceNumber ) ); +} + +int VisuGUI_PrimitiveBox::getFaceLimit() const +{ + return myFaceLimitSpinBox->value(); +} + +void VisuGUI_PrimitiveBox::setFaceLimit( int theFaceLimit ) +{ + myFaceLimitSpinBox->setValue( theFaceLimit ); +} + +void VisuGUI_PrimitiveBox::onBrowseMainTexture() +{ + QString aRootDir = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/"; + QString aFileName = QFileDialog::getOpenFileName( this, + 0, + aRootDir, + "Bitmap (*.bmp *.jpg *.png)" ); + + if( aFileName.isNull() ) + return; + + myMainTexture = aFileName; + myMainTextureLineEdit->setText( aFileName.section( '/', -1 ) ); +} + +void VisuGUI_PrimitiveBox::onBrowseAlphaTexture() +{ + QString aRootDir = QString( getenv( "VISU_ROOT_DIR") ) + "/share/salome/resources/visu/"; + QString aFileName = QFileDialog::getOpenFileName( this, + 0, + aRootDir, + "Bitmap (*.bmp *.jpg *.png)" ); + + if( aFileName.isNull() ) + return; + + myAlphaTexture = aFileName; + myAlphaTextureLineEdit->setText( aFileName.section( '/', -1 ) ); +} diff --git a/src/VISUGUI/VisuGUI_PrimitiveBox.h b/src/VISUGUI/VisuGUI_PrimitiveBox.h new file mode 100644 index 00000000..1d61abf1 --- /dev/null +++ b/src/VISUGUI/VisuGUI_PrimitiveBox.h @@ -0,0 +1,120 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// VISU VISUGUI : GUI of VISU component +// File : VisuGUI_PrimitiveBox.h +// Author : Oleg UVAROV +// Module : VISU +// +#ifndef VISUGUI_PRIMITIVEBOX_H +#define VISUGUI_PRIMITIVEBOX_H + +#include + +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; + +class SalomeApp_DoubleSpinBox; +class SalomeApp_IntSpinBox; + +class VisuGUI_PrimitiveBox : public QGroupBox +{ + Q_OBJECT + +public: + VisuGUI_PrimitiveBox( QWidget* ); + ~VisuGUI_PrimitiveBox() {} + +public: + int getPrimitiveType() const { return myPrimitiveType; } + void setPrimitiveType( int ); + + float getClamp() const; + void setClamp( float ); + void setClampMaximum( float ); + + QString getMainTexture() const { return myMainTexture; } + void setMainTexture( const QString& ); + + QString getAlphaTexture() const { return myAlphaTexture; } + void setAlphaTexture( const QString& ); + + float getAlphaThreshold() const; + void setAlphaThreshold( float ); + + int getResolution() const; + void setResolution( int ); + + int getFaceNumber() const; + void setFaceNumber( int ); + + int getFaceLimit() const; + void setFaceLimit( int ); + +protected slots: + void onTogglePointSprite(); + void onToggleOpenGLPoint(); + void onToggleGeomSphere(); + + void onBrowseMainTexture(); + void onBrowseAlphaTexture(); + + void onResolutionChanged( int ); + +private: + int myPrimitiveType; + + QRadioButton* myPointSpriteButton; + QRadioButton* myOpenGLPointButton; + QRadioButton* myGeomSphereButton; + + QString myMainTexture; + QString myAlphaTexture; + + QLabel* myClampLabel; + SalomeApp_DoubleSpinBox* myClampSpinBox; + + QLabel* myMainTextureLabel; + QLineEdit* myMainTextureLineEdit; + QPushButton* myMainTextureButton; + + QLabel* myAlphaTextureLabel; + QLineEdit* myAlphaTextureLineEdit; + QPushButton* myAlphaTextureButton; + + QLabel* myAlphaThresholdLabel; + SalomeApp_DoubleSpinBox* myAlphaThresholdSpinBox; + + QLabel* myResolutionLabel; + SalomeApp_IntSpinBox* myResolutionSpinBox; + + QLabel* myFaceNumberLabel; + QLineEdit* myFaceNumberLineEdit; + + QLabel* myFaceLimitLabel; + SalomeApp_IntSpinBox* myFaceLimitSpinBox; +}; + + + +#endif diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx index abc73bf7..047ddfb1 100644 --- a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -31,8 +31,6 @@ #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" -#include - #include "SVTK_ViewWindow.h" #include "SVTK_FontWidget.h" diff --git a/src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx b/src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx index 1d71d17a..c2a56efb 100644 --- a/src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx +++ b/src/VISUGUI/VisuGUI_SelectionPrefDlg.cxx @@ -25,8 +25,7 @@ // #include "VisuGUI_SelectionPrefDlg.h" #include "VisuGUI.h" - -#include +#include "VisuGUI_Tools.h" #include "VISU_PickingSettings.h" diff --git a/src/VISUGUI/VisuGUI_SizeBox.cxx b/src/VISUGUI/VisuGUI_SizeBox.cxx new file mode 100644 index 00000000..94440fa2 --- /dev/null +++ b/src/VISUGUI/VisuGUI_SizeBox.cxx @@ -0,0 +1,382 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// VISU VISUGUI : GUI of VISU component +// File : VisuGUI_SizeBox.cxx +// Author : Oleg UVAROV +// Module : VISU +// +#include "VisuGUI_SizeBox.h" + +#include "VisuGUI_Tools.h" + +#include +#include + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +VisuGUI_SizeBox::VisuGUI_SizeBox( QWidget* parent ) : + QWidget( parent ) +{ + QVBoxLayout* aMainLayout = new QVBoxLayout( this ); + aMainLayout->setSpacing( 0 ); + aMainLayout->setMargin( 0 ); + + // Size + QGroupBox* SizeGroup = new QGroupBox ( tr( "SIZE_TITLE" ), this ); + //SizeGroup->setColumnLayout(0, Qt::Vertical ); + //SizeGroup->layout()->setSpacing( 0 ); + //SizeGroup->layout()->setMargin( 0 ); + + QGridLayout* SizeGroupLayout = new QGridLayout (SizeGroup); + SizeGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter); + SizeGroupLayout->setSpacing(6); + SizeGroupLayout->setMargin(11); + + // Outside Size + myOutsideSizeLabel = new QLabel( tr( "OUTSIDE_SIZE" ), SizeGroup ); + myOutsideSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup ); + VISU::initSpinBox( myOutsideSizeSpinBox, 0, 100, 1 ); + myOutsideSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + SizeGroupLayout->addWidget( myOutsideSizeLabel, 0, 0 ); + SizeGroupLayout->addWidget( myOutsideSizeSpinBox, 0, 1 ); + + // Geometry Size + myGeomSizeLabel = new QLabel( tr( "GEOM_SIZE" ), SizeGroup ); + myGeomSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup ); + VISU::initSpinBox( myGeomSizeSpinBox, 0, 100, 1 ); + myGeomSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + SizeGroupLayout->addWidget( myGeomSizeLabel, 0, 0 ); + SizeGroupLayout->addWidget( myGeomSizeSpinBox, 0, 1 ); + + // Min Size + myMinSizeLabel = new QLabel( tr( "MIN_SIZE" ), SizeGroup ); + myMinSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup ); + VISU::initSpinBox( myMinSizeSpinBox, 0, 100, 1 ); + myMinSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + SizeGroupLayout->addWidget( myMinSizeLabel, 1, 0 ); + SizeGroupLayout->addWidget( myMinSizeSpinBox, 1, 1 ); + + // Max Size + myMaxSizeLabel = new QLabel( tr( "MAX_SIZE" ), SizeGroup ); + myMaxSizeSpinBox = new SalomeApp_IntSpinBox( SizeGroup ); + VISU::initSpinBox( myMaxSizeSpinBox, 0, 100, 1 ); + myMaxSizeSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + SizeGroupLayout->addWidget( myMaxSizeLabel, 1, 2 ); + SizeGroupLayout->addWidget( myMaxSizeSpinBox, 1, 3 ); + + // Magnification + myMagnificationLabel = new QLabel( tr( "MAGNIFICATION" ), SizeGroup ); + myMagnificationSpinBox = new SalomeApp_IntSpinBox( SizeGroup ); + VISU::initSpinBox( myMagnificationSpinBox, 1, 10000, 10 ); + myMagnificationSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + SizeGroupLayout->addWidget( myMagnificationLabel, 2, 0 ); + SizeGroupLayout->addWidget( myMagnificationSpinBox, 2, 1 ); + + // Increment + myIncrementLabel = new QLabel( tr( "INCREMENT" ), SizeGroup ); + myIncrementSpinBox = new SalomeApp_DoubleSpinBox( SizeGroup ); + VISU::initSpinBox( myIncrementSpinBox, 0.01, 10, 0.1, "parametric_precision" ); + myIncrementSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + SizeGroupLayout->addWidget( myIncrementLabel, 2, 2 ); + SizeGroupLayout->addWidget( myIncrementSpinBox, 2, 3 ); + + aMainLayout->addWidget( SizeGroup ); + + // Color + myColorGroup = new QGroupBox ( tr( "COLOR_TITLE" ), this ); + //myColorGroup->setColumnLayout(0, Qt::Vertical ); + //myColorGroup->layout()->setSpacing( 0 ); + //myColorGroup->layout()->setMargin( 0 ); + + QGridLayout* ColorGroupLayout = new QGridLayout ( myColorGroup ); + ColorGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); + ColorGroupLayout->setSpacing(6); + ColorGroupLayout->setMargin(11); + + myUniformCheckBox = new QCheckBox( tr( "UNIFORM_COLOR" ), myColorGroup ); + + myColorLabel = new QLabel( tr( "COLOR" ), myColorGroup ); + myColorButton = new QtxColorButton( myColorGroup ); + + ColorGroupLayout->addWidget( myUniformCheckBox, 0, 0 ); + ColorGroupLayout->addWidget( myColorLabel, 0, 1 ); + ColorGroupLayout->addWidget( myColorButton, 0, 2 ); + + aMainLayout->addWidget( myColorGroup ); + + connect( myUniformCheckBox, SIGNAL( toggled( bool ) ), myColorButton, SLOT( setEnabled( bool ) ) ); + //connect( myColorButton, SIGNAL( clicked() ), this, SLOT( onColorButtonPressed() ) ); + + setType( VisuGUI_SizeBox::Results ); +} + +void VisuGUI_SizeBox::onToggleResults() +{ + myType = VisuGUI_SizeBox::Results; + + myOutsideSizeLabel->hide(); + myOutsideSizeSpinBox->hide(); + + myGeomSizeLabel->hide(); + myGeomSizeSpinBox->hide(); + + myMinSizeLabel->show(); + myMinSizeSpinBox->show(); + + myMaxSizeLabel->show(); + myMaxSizeSpinBox->show(); + + myMagnificationLabel->show(); + myMagnificationSpinBox->show(); + + myIncrementLabel->show(); + myIncrementSpinBox->show(); + + myColorGroup->hide(); + + myUniformCheckBox->hide(); +} + +void VisuGUI_SizeBox::onToggleGeometry() +{ + myType = VisuGUI_SizeBox::Geometry; + + myOutsideSizeLabel->hide(); + myOutsideSizeSpinBox->hide(); + + myGeomSizeLabel->show(); + myGeomSizeSpinBox->show(); + + myMinSizeLabel->hide(); + myMinSizeSpinBox->hide(); + + myMaxSizeLabel->hide(); + myMaxSizeSpinBox->hide(); + + myMagnificationLabel->show(); + myMagnificationSpinBox->show(); + + myIncrementLabel->show(); + myIncrementSpinBox->show(); + + myColorGroup->show(); + + myUniformCheckBox->hide(); +} + +void VisuGUI_SizeBox::onToggleInside() +{ + myType = VisuGUI_SizeBox::Inside; + + myOutsideSizeLabel->hide(); + myOutsideSizeSpinBox->hide(); + + myGeomSizeLabel->hide(); + myGeomSizeSpinBox->hide(); + + myMinSizeLabel->show(); + myMinSizeSpinBox->show(); + + myMaxSizeLabel->show(); + myMaxSizeSpinBox->show(); + + myMagnificationLabel->hide(); + myMagnificationSpinBox->hide(); + + myIncrementLabel->hide(); + myIncrementSpinBox->hide(); + + myColorGroup->hide(); + + myUniformCheckBox->hide(); +} + +void VisuGUI_SizeBox::onToggleOutside() +{ + myType = VisuGUI_SizeBox::Outside; + + myOutsideSizeLabel->show(); + myOutsideSizeSpinBox->show(); + + myGeomSizeLabel->hide(); + myGeomSizeSpinBox->hide(); + + myMinSizeLabel->hide(); + myMinSizeSpinBox->hide(); + + myMaxSizeLabel->hide(); + myMaxSizeSpinBox->hide(); + + myMagnificationLabel->hide(); + myMagnificationSpinBox->hide(); + + myIncrementLabel->hide(); + myIncrementSpinBox->hide(); + + myColorGroup->show(); + + myUniformCheckBox->show(); +} + +void VisuGUI_SizeBox::setType( int theType ) +{ + myType = theType; + + switch( myType ) + { + case VisuGUI_SizeBox::Results : onToggleResults(); break; + case VisuGUI_SizeBox::Geometry : onToggleGeometry(); break; + case VisuGUI_SizeBox::Inside : onToggleInside(); break; + case VisuGUI_SizeBox::Outside : onToggleOutside(); break; + default : break; + } +} + +float VisuGUI_SizeBox::getOutsideSize() const +{ + return myOutsideSizeSpinBox->value() / 100.0; +} + +void VisuGUI_SizeBox::setOutsideSize( float theOutsideSize ) +{ + myOutsideSizeSpinBox->setValue( ( int )( theOutsideSize * 100 ) ); +} + +float VisuGUI_SizeBox::getGeomSize() const +{ + return myGeomSizeSpinBox->value() / 100.0; +} + +void VisuGUI_SizeBox::setGeomSize( float theGeomSize ) +{ + myGeomSizeSpinBox->setValue( ( int )( theGeomSize * 100 ) ); +} + +float VisuGUI_SizeBox::getMinSize() const +{ + return myMinSizeSpinBox->value() / 100.0; +} + +void VisuGUI_SizeBox::setMinSize( float theMinSize ) +{ + myMinSizeSpinBox->setValue( ( int )( theMinSize * 100 ) ); +} + +float VisuGUI_SizeBox::getMaxSize() const +{ + return myMaxSizeSpinBox->value() / 100.0; +} + +void VisuGUI_SizeBox::setMaxSize( float theMaxSize ) +{ + myMaxSizeSpinBox->setValue( ( int )( theMaxSize * 100 ) ); +} + +float VisuGUI_SizeBox::getMagnification() const +{ + return myMagnificationSpinBox->value() / 100.0; +} + +void VisuGUI_SizeBox::setMagnification( float theMagnification ) +{ + myMagnificationSpinBox->setValue( ( int )( theMagnification * 100 ) ); +} + +float VisuGUI_SizeBox::getIncrement() const +{ + return myIncrementSpinBox->value(); +} + +void VisuGUI_SizeBox::setIncrement( float theIncrement ) +{ + myIncrementSpinBox->setValue( theIncrement ); +} + +bool VisuGUI_SizeBox::getUniform() const +{ + return myUniformCheckBox->isChecked(); +} + +void VisuGUI_SizeBox::setUniform( bool theUniform ) +{ + myUniformCheckBox->setChecked( theUniform ); + myColorButton->setEnabled( theUniform ); +} + +QColor VisuGUI_SizeBox::getColor() const +{ + return myColorButton->color();//palette().color( myColorButton->backgroundRole() ); + //return myColorButton->paletteBackgroundColor(); +} + +void VisuGUI_SizeBox::setColor( const QColor& theColor ) +{ + if ( theColor.isValid() ) + { + //QPalette aPalette( myColorButton->palette() ); + //aPalette.setColor( myColorButton->backgroundRole(), theColor ); + myColorButton->setColor( theColor ); + } + //myColorButton->setPaletteBackgroundColor( theColor ); +} + +void VisuGUI_SizeBox::enableSizeControls( bool enabled ) +{ + myMagnificationSpinBox->setEnabled( enabled ); + myMaxSizeSpinBox->setEnabled( enabled ); + myMinSizeSpinBox->setEnabled( enabled ); + myIncrementSpinBox->setEnabled( enabled ); + myGeomSizeSpinBox->setEnabled( enabled ); +} + +/*void VisuGUI_SizeBox::onColorButtonPressed() +{ + QPalette aPalette( myColorButton->palette() ); + QColor aColor = QColorDialog:: + getColor( aPalette.color(myColorButton->backgroundRole() ), this ); + + if( aColor.isValid() ) + { + aPalette.setColor( myColorButton->backgroundRole(), aColor ); + myColorButton->setPalette( aPalette ); + } +}*/ diff --git a/src/VISUGUI/VisuGUI_SizeBox.h b/src/VISUGUI/VisuGUI_SizeBox.h new file mode 100644 index 00000000..da1a89d9 --- /dev/null +++ b/src/VISUGUI/VisuGUI_SizeBox.h @@ -0,0 +1,121 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// VISU VISUGUI : GUI of VISU component +// File : VisuGUI_SizeBox.h +// Author : Oleg UVAROV +// Module : VISU +// +#ifndef VISUGUI_SIZEBOX_H +#define VISUGUI_SIZEBOX_H + +#include + +class QLabel; +class QLineEdit; +class QPushButton; +class QCheckBox; +class QGroupBox; + +class SalomeApp_DoubleSpinBox; +class SalomeApp_IntSpinBox; +class QtxColorButton; + +class VisuGUI_SizeBox : public QWidget +{ + Q_OBJECT + +public: + enum { Results = 0, Geometry, Inside, Outside }; + +public: + VisuGUI_SizeBox( QWidget* ); + ~VisuGUI_SizeBox() {} + +public: + int getType() const { return myType; } + void setType( int ); + + float getOutsideSize() const; + void setOutsideSize( float ); + + float getGeomSize() const; + void setGeomSize( float ); + + float getMinSize() const; + void setMinSize( float ); + + float getMaxSize() const; + void setMaxSize( float ); + + float getMagnification() const; + void setMagnification( float ); + + float getIncrement() const; + void setIncrement( float ); + + bool getUniform() const; + void setUniform( bool ); + + QColor getColor() const; + void setColor( const QColor& ); + + void enableSizeControls( bool enabled ); + +protected slots: + void onToggleResults(); + void onToggleGeometry(); + void onToggleInside(); + void onToggleOutside(); + + //void onColorButtonPressed(); + +private: + int myType; + + QLabel* myOutsideSizeLabel; + SalomeApp_IntSpinBox* myOutsideSizeSpinBox; + + QLabel* myGeomSizeLabel; + SalomeApp_IntSpinBox* myGeomSizeSpinBox; + + QLabel* myMinSizeLabel; + SalomeApp_IntSpinBox* myMinSizeSpinBox; + + QLabel* myMaxSizeLabel; + SalomeApp_IntSpinBox* myMaxSizeSpinBox; + + QLabel* myMagnificationLabel; + SalomeApp_IntSpinBox* myMagnificationSpinBox; + + QLabel* myIncrementLabel; + SalomeApp_DoubleSpinBox* myIncrementSpinBox; + + QCheckBox* myUniformCheckBox; + + QGroupBox* myColorGroup; + QLabel* myColorLabel; + QtxColorButton* myColorButton; +}; + + + +#endif diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index ac2eedc0..19ce68a8 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -25,8 +25,7 @@ // Module : VISU // #include "VisuGUI_Slider.h" - -#include +#include "VisuGUI_Tools.h" #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index e828a891..b64658dc 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -29,8 +29,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" -#include - #include "VISU_Mesh_i.hh" #include "VISU_Gen_i.hh" #include "VISU_StreamLines_i.hh" diff --git a/src/VISUGUI/VisuGUI_Sweep.cxx b/src/VISUGUI/VisuGUI_Sweep.cxx index bcbbf9bf..f707b0f4 100644 --- a/src/VISUGUI/VisuGUI_Sweep.cxx +++ b/src/VISUGUI/VisuGUI_Sweep.cxx @@ -25,8 +25,7 @@ // Module : VISU // #include "VisuGUI_Sweep.h" - -#include +#include "VisuGUI_Tools.h" #include "SUIT_ResourceMgr.h" diff --git a/src/VISUGUI/VisuGUI_Table3dDlg.cxx b/src/VISUGUI/VisuGUI_Table3dDlg.cxx index f5e2f2b6..9e2311cb 100644 --- a/src/VISUGUI/VisuGUI_Table3dDlg.cxx +++ b/src/VISUGUI/VisuGUI_Table3dDlg.cxx @@ -30,8 +30,6 @@ #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" -#include - #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_ViewManager_i.hh" #include "VISU_Prs3dUtils.hh" diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index a7bdbcfb..d8ea1bcd 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -40,8 +40,6 @@ #include "VisuGUI_DeformedShapeAndScalarMapDlg.h" #include "VisuGUI_GaussPointsDlg.h" -#include - #include "VISU_TimeAnimation.h" #include "VISU_ScalarMap_i.hh" diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 40215a7a..963e1efa 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -47,6 +47,8 @@ #include "SalomeApp_Module.h" #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" +#include "SalomeApp_IntSpinBox.h" +#include "SalomeApp_DoubleSpinBox.h" #include "LightApp_DataObject.h" #include "LightApp_SelectionMgr.h" @@ -70,6 +72,7 @@ #include "SUIT_MessageBox.h" #include "SUIT_Desktop.h" #include "SUIT_ViewWindow.h" +#include "SUIT_ResourceMgr.h" #include "CAM_DataModel.h" @@ -79,6 +82,7 @@ #include #include #include +#include using namespace std; @@ -1342,4 +1346,39 @@ namespace VISU theSObject = aFolder; return true; } + + //------------------------------------------------------------ + void initSpinBox( SalomeApp_IntSpinBox* sb, + const int bottom, + const int top, + const int step ) + { + sb->setAcceptNames( false ); + sb->setRange( bottom, top ); + sb->setSingleStep( step ); + } + + //------------------------------------------------------------ + void initSpinBox( SalomeApp_DoubleSpinBox* sb, + const double& bottom, + const double& top, + const double& step, + const char* quantity ) + { + // Obtain precision from preferences + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + int precision = resMgr->integerValue( "VISU", quantity, 3 ); + + sb->setPrecision ( precision ); + sb->setDecimals ( qAbs(precision) ); + sb->setRange ( bottom, top ); + sb->setSingleStep ( step ); + sb->setDefaultValue( bottom ); + sb->setAcceptNames ( false ); + + // Add a hint for the user saying how to tune precision + QString userPropName = QObject::tr( QString( "VISU_PREF_%1" ).arg( quantity ).toLatin1().constData() ); + sb->setProperty( "validity_tune_hint", + QVariant( QObject::tr( "VISU_PRECISION_HINT" ).arg( userPropName ) ) ); + } } diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index c953076c..7ead3511 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -51,6 +51,8 @@ class SPlot2d_Curve; class Plot2d_ViewFrame; class CAM_Module; class LightApp_SelectionMgr; +class SalomeApp_DoubleSpinBox; +class SalomeApp_IntSpinBox; class SalomeApp_Module; class SalomeApp_Study; class VisuGUI; @@ -243,6 +245,9 @@ namespace VISU #define CLIP_PLANES_FOLDER "Clipping Planes" bool getClippingPlanesFolder(_PTR(Study) theStudy, _PTR(SObject)& theSObject); + + void initSpinBox( SalomeApp_IntSpinBox*, const int, const int, const int ); + void initSpinBox( SalomeApp_DoubleSpinBox*, const double&, const double&, const double&, const char* ); } #endif diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index a4310d8e..df00b409 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -31,8 +31,6 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" -#include - #include "VISU_ColoredPrs3dFactory.hh" #include "VISU_Vectors_i.hh" #include "LightApp_Application.h" diff --git a/src/VISU_I/Makefile.am b/src/VISU_I/Makefile.am index 9d6c9de5..7052ee53 100644 --- a/src/VISU_I/Makefile.am +++ b/src/VISU_I/Makefile.am @@ -67,8 +67,8 @@ salomeinclude_HEADERS = \ VISU_Deformation_i.hh \ VISU_OptionalDeformation_i.hh \ SALOME_GenericObjPointer.hh \ - VISU_ClippingPlaneMgr.hxx - + VISU_ClippingPlaneMgr.hxx \ + VISU_TableDlg.h libVISUEngineImpl_la_SOURCES = \ VISUConfig.cc \ @@ -109,9 +109,13 @@ libVISUEngineImpl_la_SOURCES = \ VISU_Deformation_i.cc \ VISU_OptionalDeformation_i.cc \ SALOME_GenericObjPointer.cc \ - VISU_ClippingPlaneMgr.cxx + VISU_ClippingPlaneMgr.cxx \ + VISU_TableDlg.cxx + +MOC_FILES = \ + VISU_TimeAnimation_moc.cxx \ + VISU_TableDlg_moc.cxx -MOC_FILES = VISU_TimeAnimation_moc.cxx nodist_libVISUEngineImpl_la_SOURCES= $(MOC_FILES) # additionnal information to compil and link file @@ -131,7 +135,6 @@ libVISUEngineImpl_la_CPPFLAGS= \ -I$(srcdir)/../CONVERTOR \ -I$(srcdir)/../PIPELINE \ -I$(srcdir)/../OBJECT \ - -I$(srcdir)/../GUITOOLS \ -I$(top_builddir)/idl libVISUEngineImpl_la_LDFLAGS= \ @@ -150,7 +153,6 @@ libVISUEngineImpl_la_LIBADD= \ ../CONVERTOR/libVisuConvertor.la \ ../PIPELINE/libVisuPipeLine.la \ ../OBJECT/libVisuObject.la \ - ../GUITOOLS/libVISUGUITOOLS.la \ -lSalomeIDLKernel \ -lSalomeHDFPersist \ -lSalomeGenericObj \ diff --git a/src/VISU_I/VISU_TableDlg.cxx b/src/VISU_I/VISU_TableDlg.cxx new file mode 100644 index 00000000..be56e272 --- /dev/null +++ b/src/VISU_I/VISU_TableDlg.cxx @@ -0,0 +1,1161 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VISU_TableDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +// + +#include "VISU_TableDlg.h" + +#include + +#include "SUIT_Tools.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ResourceMgr.h" +#include "SUIT_Session.h" + +#include "LightApp_Application.h" + +#include "CAM_Module.h" + +#include "SALOMEDSClient_Study.hxx" +#include "SALOMEDSClient_GenericAttribute.hxx" +#include "SALOMEDSClient_AttributeTableOfInteger.hxx" +#include "SALOMEDSClient_AttributeTableOfReal.hxx" +#include "SALOMEDSClient_StudyBuilder.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utilities.h" + +const int MARGIN_SIZE = 11; +const int SPACING_SIZE = 6; +const int MIN_TABLE_WIDTH = 200; +const int MIN_TABLE_HEIGHT = 200; + +NumDelegateItem::NumDelegateItem( QObject* parent, NumValidator mode ) + : QItemDelegate( parent ), + myMode( mode ) +{ +} + +NumDelegateItem::~NumDelegateItem() +{ +} + +QWidget* NumDelegateItem::createEditor( QWidget* parent, + const QStyleOptionViewItem& option, + const QModelIndex& index ) const +{ + QLineEdit* editor = new QLineEdit( parent ); + switch ( myMode ) + { + case NV_Int: + editor->setValidator( new QIntValidator( editor ) ); + break; + case NV_Real: + editor->setValidator( new QDoubleValidator( editor ) ); + break; + default: + break; + } + return editor; +} + +void NumDelegateItem::setEditorData( QWidget* editor, + const QModelIndex& index ) const +{ + QLineEdit* aLE = qobject_cast( editor ); + if ( !aLE ) + return; + + switch ( myMode ) + { + case NV_Int: + { + int value = index.model()->data( index, Qt::DisplayRole ).toInt(); + aLE->setText( QString("%1").arg( value ) ); + break; + } + case NV_Real: + { + double value = index.model()->data(index, Qt::DisplayRole).toDouble(); + aLE->setText( QString("%1").arg( value ) ); + break; + } + default: + aLE->setText( index.model()->data( index, Qt::DisplayRole ).toString() ); + break; + } +} + +class VISU_TableDlg::WidgetCointainer : public QWidget +{ +public: + WidgetCointainer( QWidget* parent, Qt::Orientation o, int lm, int tm, int rm, int bm, int s ) + : QWidget( parent ) + { + QLayout* l = o == Qt::Horizontal ? (QLayout*)( new QHBoxLayout( this ) ) : ( QLayout* )( new QVBoxLayout( this ) ); + l->setContentsMargins( lm, tm, rm, bm ); + l->setSpacing( s ); + setLayout( l ); + } + void addWidget( QWidget* w ) + { + if ( w ) { + QHBoxLayout* hl = qobject_cast( layout() ); + QVBoxLayout* wl = qobject_cast( layout() ); + if ( hl ) hl->addWidget( w ); + else if ( wl ) wl->addWidget( w ); + } + } + void addSpacing( int s ) + { + if ( s > 0 ) { + QHBoxLayout* hl = qobject_cast( layout() ); + QVBoxLayout* wl = qobject_cast( layout() ); + if ( hl ) hl->addSpacing( s ); + else if ( wl ) wl->addSpacing( s ); + } + } + void addStretch( int s ) + { + if ( s >= 0 ) { + QHBoxLayout* hl = qobject_cast( layout() ); + QVBoxLayout* wl = qobject_cast( layout() ); + if ( hl ) hl->addStretch( s ); + else if ( wl ) wl->addStretch( s ); + } + } +}; + +/*class VISU_Table : public QTableWidget { +public: + VISU_Table( Orientation orient, QWidget* parent = 0 ) + : QTableWidget( parent ), myValidator( 0 ), myOrientation( orient ) {} + VISU_Table( Orientation orient, int numRows, int numCols, QWidget* parent = 0 ) + : QTableWidget( numRows, numCols, parent ), myValidator( 0 ), myOrientation( orient ) {} + + void setValidator( QValidator* v = 0 ) { myValidator = v; } + bool isEditing() const { return QTable::isEditing(); } + +protected: + QWidget* createEditor ( int row, int col, bool initFromCell ) const + { + bool testUnits = ( myOrientation == Qt::Horizontal && col == 0 ) || ( myOrientation == Qt::Vertical && row == 0 ); + QWidget* wg = QTable::createEditor( row, col, initFromCell ); + if ( wg && wg->inherits("QLineEdit") && myValidator && !testUnits ) + (( QLineEdit*)wg)->setValidator( myValidator ); + return wg; + } + +protected: + QValidator* myValidator; + Orientation myOrientation; + };*/ + +QString VISU_TableDlg::tableTitle( int type ) +{ + QString tlt; + switch ( type ) { + case ttInt: tlt = tr( "TABLE_OF_INTEGER_TLT" ); break; + case ttReal: tlt = tr( "TABLE_OF_REAL_TLT" ); break; + default: tlt = tr( "TABLE_UNKNOWN_TLT" ); break; + } + return tlt; +} +/*! + Constructor +*/ +VISU_TableDlg::VISU_TableDlg( QWidget* parent, + _PTR(Study) study, + VISU::Table_i* table, + bool allowEdition, + int which, + Qt::Orientation orient, + bool showColumnTitles ) + : QDialog( parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint ), + myStudy( study ), myTable( table ), myEditCheck( 0 ), myUpdateCheck( 0 ) +{ + allowEdition = true; ////////////////////////////////// + setWindowTitle( tr( "VIEW_TABLE_TLT" ) ); + setSizeGripEnabled( true ); + + bool bHasIntTable = false; + bool bHasRealTable = false; + if ( myStudy && myTable ) { + _PTR(SObject) aSObject = myStudy->FindObjectID( myTable->GetObjectEntry() ); + if ( aSObject ) { + _PTR(GenericAttribute) anAttr; + bHasIntTable = aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ); + bHasRealTable = aSObject->FindAttribute( anAttr, "AttributeTableOfReal" ); + } + } + + if ( allowEdition ) { + myEditCheck = new QCheckBox( tr( "ALLOW_EDIT_CHECK" ), this ); + myUpdateCheck = new QCheckBox( tr( "DO_UPDATE_CHECK" ), this ); + connect( myEditCheck, SIGNAL( toggled( bool ) ), myUpdateCheck, SLOT( setEnabled( bool ) ) ); + myUpdateCheck->setEnabled( false ); + myUpdateCheck->hide(); // the feature has been temporarily disabled + } + + QWidget* top = 0; + + if ( which == ttInt || which == ttAll || which == ttAuto && bHasIntTable ) { + myTableMap[ ttInt ] = new TableWidget( this, orient ); + myTableMap[ ttInt ]->initialize( myStudy, myTable, ttInt ); + myTableMap[ ttInt ]->setEditEnabled( false ); + myTableMap[ ttInt ]->showColumnTitles( showColumnTitles ); + if ( myEditCheck ) + connect( myEditCheck, SIGNAL( toggled( bool ) ), myTableMap[ ttInt ], SLOT( setEditEnabled( bool ) ) ); + } + if ( which == ttReal || which == ttAll || which == ttAuto && bHasRealTable ) { + myTableMap[ ttReal ] = new TableWidget( this, orient ); + myTableMap[ ttReal ]->initialize( myStudy, myTable, ttReal ); + myTableMap[ ttReal ]->setEditEnabled( false ); + myTableMap[ ttReal ]->showColumnTitles( showColumnTitles ); + if ( myEditCheck ) + connect( myEditCheck, SIGNAL( toggled( bool ) ), myTableMap[ ttReal ], SLOT( setEditEnabled( bool ) ) ); + } + + if ( myTableMap.count() > 1 ) { + QTabWidget* tw = new QTabWidget( this ); + for ( int i = ttInt; i < ttAll; i++ ) { + if ( myTableMap.contains( i ) ) { + tw->addTab( myTableMap[ i ], tableTitle( i ) ); + myTableMap[ i ]->layout()->setMargin( MARGIN_SIZE ); + } + } + top = tw; + } + else if ( myTableMap.count() == 1 ) { + top = myTableMap[myTableMap.keys().first()]; + } + else { + QLabel* dumbLabel = new QLabel( tr( "ERR_TABLE_NOT_AVAILABLE" ), this ); + dumbLabel->setAlignment( Qt::AlignCenter ); + top = dumbLabel; + } + + myOKBtn = new QPushButton( tr( "BUT_OK" ), this ); + myHelpBtn = new QPushButton( tr( "BUT_HELP" ), this ); + + QHBoxLayout* btnLayout = new QHBoxLayout; + btnLayout->setMargin( 0 ); + btnLayout->setSpacing( SPACING_SIZE ); + + btnLayout->addWidget( myOKBtn ); + btnLayout->addStretch( 20 ); + btnLayout->addWidget( myHelpBtn ); + connect( myOKBtn, SIGNAL( clicked() ), this, SLOT( close() ) ); + connect( myHelpBtn, SIGNAL( clicked() ), this, SLOT( help() ) ); + + QVBoxLayout* mainLayout = new QVBoxLayout( this ); + mainLayout->setMargin( MARGIN_SIZE ); + mainLayout->setSpacing( SPACING_SIZE ); + + if ( myEditCheck ) { + QHBoxLayout* checkLayout = new QHBoxLayout; + checkLayout->setMargin( 0 ); + checkLayout->setSpacing( SPACING_SIZE ); + checkLayout->addWidget( myEditCheck ); + checkLayout->addWidget( myUpdateCheck ); + mainLayout->addLayout( checkLayout ); + } + mainLayout->addWidget( top ); + mainLayout->addLayout( btnLayout ); + + resize( 500, 400 ); + SUIT_Tools::centerWidget( this, parent ); +} + +/*! + Destructor +*/ +VISU_TableDlg::~VISU_TableDlg() +{ +} + +/*! + button slot, saves table(s) + Called only in create/edit mode ( parameter for constructor is true ) +*/ +/* +void VISU_TableDlg::onOK() +{ + myOKBtn->setFocus(); // accept possible changes + bool done = true; + + if ( myObject ) { + _PTR(Study) study = myObject->GetStudy(); + _PTR(AttributeTableOfInteger) tblIntAttr; + _PTR(AttributeTableOfReal) tblRealAttr; + + if ( study ) { + _PTR(StudyBuilder) builder = study->NewBuilder(); + builder->NewCommand(); // start transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!!! + try { + if ( myTableMap.contains( ttInt ) ) { + builder->RemoveAttribute( myObject, "AttributeTableOfInteger" ); + tblIntAttr = builder->FindOrCreateAttribute( myObject, "AttributeTableOfInteger" ); + + int i; + int nbRows = myTableMap[ ttInt ]->getNumRows(); + int nbCols = myTableMap[ ttInt ]->getNumCols(); + QString tlt = myTableMap[ ttInt ]->getTableTitle(); + QStringList rowTitles, colTitles, units; + myTableMap[ ttInt ]->getRowTitles( rowTitles ); + myTableMap[ ttInt ]->getColTitles( colTitles ); + myTableMap[ ttInt ]->getUnits( units ); + + if ( nbRows > 0) { + // data + int nRow = 0; + tblIntAttr->SetNbColumns( nbCols ); + for ( i = 0; i < nbRows; i++ ) { + QStringList data; + myTableMap[ ttInt ]->getRowData( i, data ); + bool bEmptyRow = true; + for ( int j = 0; j < data.count(); j++ ) { + if ( !data[ j ].isNull() ) { + tblIntAttr->PutValue( data[ j ].toInt(), nRow+1, j+1 ); + bEmptyRow = false; + } + } + if ( !bEmptyRow ) { // Skip rows with no data !!! + // set row title + tblIntAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : (const char*)rowTitles[ i ].toLatin1() ); + // set row unit + tblIntAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : (const char*)units[ i ].toLatin1() ); + nRow++; + } + } + if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!! + // column titles + for ( i = 0; i < colTitles.count(); i++ ) + tblIntAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : (const char*)colTitles[ i ].toLatin1() ); + } + } + // title + tblIntAttr->SetTitle( (const char*)myTableMap[ ttInt ]->getTableTitle().toLatin1() ); + } + if ( myTableMap.contains( ttReal ) ) { + builder->RemoveAttribute( myObject, "AttributeTableOfReal" ); + tblRealAttr = builder->FindOrCreateAttribute( myObject, "AttributeTableOfReal" ); + + int i; + int nbRows = myTableMap[ ttReal ]->getNumRows(); + int nbCols = myTableMap[ ttReal ]->getNumCols(); + QString tlt = myTableMap[ ttReal ]->getTableTitle(); + QStringList rowTitles, colTitles, units; + myTableMap[ ttReal ]->getRowTitles( rowTitles ); + myTableMap[ ttReal ]->getColTitles( colTitles ); + myTableMap[ ttReal ]->getUnits( units ); + + if ( nbRows > 0) { + // data + int nRow = 0; + tblRealAttr->SetNbColumns( nbCols ); + for ( i = 0; i < nbRows; i++ ) { + QStringList data; + myTableMap[ ttReal ]->getRowData( i, data ); + bool bEmptyRow = true; + for ( int j = 0; j < data.count(); j++ ) { + if ( !data[ j ].isNull() ) { + tblRealAttr->PutValue( data[ j ].toDouble(), nRow+1, j+1 ); + bEmptyRow = false; + } + } + if ( !bEmptyRow ) { // Skip rows with no data !!! + // set row title + tblRealAttr->SetRowTitle( nRow+1, rowTitles[ i ].isNull() ? "" : (const char*)rowTitles[ i ].toLatin1() ); + // set row unit + tblRealAttr->SetRowUnit( nRow+1, units[ i ].isNull() ? "" : (const char*)units[ i ].toLatin1() ); + nRow++; + } + } + if ( nRow > 0 ) { // Set columns only if table is not empty, otherwise exception is raised !!! + // column titles + for ( i = 0; i < colTitles.count(); i++ ) + tblRealAttr->SetColumnTitle( i+1, colTitles[ i ].isNull() ? "" : (const char*)colTitles[ i ].toLatin1() ); + } + } + // title + tblRealAttr->SetTitle( (const char*)myTableMap[ ttReal ]->getTableTitle().toLatin1() ); + } + if ( myTableMap.contains( ttInt ) || myTableMap.contains( ttReal ) ) + builder->CommitCommand(); // commit transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! + else + builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! + } + catch( ... ) { + MESSAGE("VISU_TableDlg::onOK : Exception has been caught !!!"); + builder->AbortCommand(); // abort transaction !!!!!!!!!!!!!!!!!!!!!!!!!!! + done = false; + SUIT_MessageBox::critical ( this, tr("ERR_ERROR"), tr("ERR_APP_EXCEPTION") ); + } + } + } + if ( done ) + accept(); +} +*/ + +/*! + button slot, shows corresponding help page +*/ +void VISU_TableDlg::help() +{ + QString aHelpFileName = "table_presentations_page.html"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName); + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning( this, + QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) ); + } +} + +/*! + Provides help on F1 button click +*/ +void VISU_TableDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Qt::Key_F1 ) { + e->accept(); + help(); + } +} + +/*! + Constructor +*/ +VISU_TableDlg::TableWidget::TableWidget( QWidget* parent, + Qt::Orientation orientation ) + : QWidget( parent ), myOrientation( orientation ) +{ + myTitleEdit = new QLineEdit( this ); + + myTable = new QTableWidget( 5, 5, this ); + myTable->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + myTable->setMinimumSize( MIN_TABLE_WIDTH, MIN_TABLE_HEIGHT ); + myTable->setSelectionMode( QAbstractItemView::SingleSelection ); + myTable->setShowGrid( true ); + myTable->horizontalHeader()->setMovable( false ); + myTable->verticalHeader()->setMovable( false ); + myTable->setDragEnabled( false ); + + myAdjustBtn = new QPushButton( VISU_TableDlg::tr( "ADJUST_CELLS_BTN" ), this ); + myAddRowBtn = new QPushButton( VISU_TableDlg::tr( "ADD_ROW_BTN" ), this ); + myDelRowBtn = new QPushButton( VISU_TableDlg::tr( "REMOVE_ROW_BTN" ), this ); + myAddColBtn = new QPushButton( VISU_TableDlg::tr( "ADD_COLUMN_BTN" ), this ); + myDelColBtn = new QPushButton( VISU_TableDlg::tr( "REMOVE_COLUMN_BTN" ), this ); + mySelectAllBtn = new QPushButton( VISU_TableDlg::tr( "SELECT_ALL_BTN" ), this ); + myClearBtn = new QPushButton( VISU_TableDlg::tr( "CLEAR_BTN"), this ); + + // the features has been temporarily disabled + myAddRowBtn->hide(); + myDelRowBtn->hide(); + myAddColBtn->hide(); + myDelColBtn->hide(); + mySelectAllBtn->hide(); + myClearBtn->hide(); + + QVBoxLayout* btnLayout = new QVBoxLayout; + btnLayout->setMargin( 0 ); + btnLayout->setSpacing( SPACING_SIZE ); + btnLayout->addWidget( myAdjustBtn ); + btnLayout->addStretch( 20 ); + btnLayout->addWidget( myAddRowBtn ); + btnLayout->addWidget( myDelRowBtn ); + btnLayout->addWidget( myAddColBtn ); + btnLayout->addWidget( myDelColBtn ); + btnLayout->addStretch( 20 ); + btnLayout->addWidget( mySelectAllBtn ); + btnLayout->addWidget( myClearBtn ); + + QGridLayout* mainLayout = new QGridLayout( this ); + mainLayout->setMargin( 0 ); + mainLayout->setSpacing( SPACING_SIZE ); + mainLayout->addWidget( myTitleEdit, 0, 0, 1, 2 ); + mainLayout->addWidget( myTable, 1, 0 ); + mainLayout->addLayout( btnLayout, 1, 1 ); + + connect( myTable, SIGNAL( itemSelectionChanged() ), + this, SLOT( updateButtonsState() ) ); + connect( myTable, SIGNAL( currentItemChanged( QTableWidgetItem*, QTableWidgetItem* ) ), + this, SLOT( updateButtonsState() ) ); + connect( myAddRowBtn, SIGNAL( clicked() ), this, SLOT( addRow() ) ); + connect( myAddColBtn, SIGNAL( clicked() ), this, SLOT( addCol() ) ); + connect( myDelRowBtn, SIGNAL( clicked() ), this, SLOT( delRow() ) ); + connect( myDelColBtn, SIGNAL( clicked() ), this, SLOT( delCol() ) ); + connect( myAdjustBtn, SIGNAL( clicked() ), this, SLOT( adjustTable() ) ); + connect( mySelectAllBtn, SIGNAL( clicked() ), this, SLOT( selectAll() ) ); + connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( clearTable() ) ); + myTable->horizontalHeader()->installEventFilter( this ); + myTable->verticalHeader()->installEventFilter( this ); + myTable->installEventFilter( this ); + + updateButtonsState(); +} + +/*! + Destructor +*/ +VISU_TableDlg::TableWidget::~TableWidget() +{ +} + +/*! + Initialize widget +*/ +void VISU_TableDlg::TableWidget::initialize( _PTR(Study) study, VISU::Table_i* table, int type ) +{ + myStudy = study; + myTableObj = table; + myType = type; + + setUnitsTitle( VISU_TableDlg::tr( "UNITS_TLT" ) ); + setEditEnabled( false ); + showColumnTitles( false ); + + _PTR(SObject) aSObject = myStudy->FindObjectID( myTableObj->GetObjectEntry() ); + if ( aSObject ) { + int i, j; + switch ( myType ) { + case ttInt: + myTable->setItemDelegate( new NumDelegateItem( this, NumDelegateItem::NV_Int ) ); + if ( aSObject->FindAttribute( myAttr, "AttributeTableOfInteger" ) ) { + _PTR(AttributeTableOfInteger) intAttr = myAttr; + try { + // title + setTableTitle( intAttr->GetTitle().c_str() ); + // nb of rows & cols + int nbRows = intAttr->GetNbRows() ; + int nbCols = intAttr->GetNbColumns(); + setNumRows( nbRows ); + setNumCols( nbCols ); + // rows titles + QStringList strlist; + std::vector titles = intAttr->GetRowTitles(); + for ( i = 0; i < nbRows; i++ ) { + if ( titles.size() > 0 ) + strlist.append( titles[i].c_str() ); + else + strlist.append( "" ); + } + setRowTitles( strlist ); + // columns titles + strlist.clear(); + titles = intAttr->GetColumnTitles(); + for ( i = 0; i < nbCols; i++ ) { + if ( titles.size() > 0 ) + strlist.append( titles[i].c_str() ); + else + strlist.append( "" ); + } + setColTitles( strlist ); + // units + strlist.clear(); + titles = intAttr->GetRowUnits(); + if ( titles.size() > 0 ) { + for ( i = 0; i < nbRows; i++ ) + strlist.append( titles[i].c_str() ); + setUnits( strlist ); + } + // data + for ( i = 1; i <= nbRows; i++ ) { + strlist.clear(); + for ( j = 1; j <= nbCols; j++ ) { + if ( intAttr->HasValue( i, j ) ) + strlist.append( QString::number( intAttr->GetValue( i, j ) ) ); + else + strlist.append( QString::null ); + } + setRowData( i-1, strlist ); + } + adjustTable(); + } + catch( ... ) { + MESSAGE("VISU_TableDlg::TableWidget::initialize : Exception has been caught !!!"); + } + } + break; + case ttReal: + myTable->setItemDelegate( new NumDelegateItem( this, NumDelegateItem::NV_Real ) ); + if ( aSObject->FindAttribute( myAttr, "AttributeTableOfReal" ) ) { + _PTR(AttributeTableOfReal) realAttr = myAttr; + try { + // title + setTableTitle( realAttr->GetTitle().c_str() ); + // nb of rows & cols + int nbRows = realAttr->GetNbRows() ; + int nbCols = realAttr->GetNbColumns(); + setNumRows( nbRows ); + setNumCols( nbCols ); + // rows titles + QStringList strlist; + std::vector titles = realAttr->GetRowTitles(); + for ( i = 0; i < nbRows; i++ ) { + if ( titles.size() > 0 ) + strlist.append( titles[i].c_str() ); + else + strlist.append( "" ); + } + setRowTitles( strlist ); + // columns titles + strlist.clear(); + titles = realAttr->GetColumnTitles(); + for ( i = 0; i < nbCols; i++ ) { + if ( titles.size() > 0 ) + strlist.append( titles[i].c_str() ); + else + strlist.append( "" ); + } + setColTitles( strlist ); + // units + strlist.clear(); + titles = realAttr->GetRowUnits(); + if ( titles.size() > 0 ) { + for ( i = 0; i < nbRows; i++ ) + strlist.append( titles[i].c_str() ); + setUnits( strlist ); + } + // data + for ( i = 1; i <= nbRows; i++ ) { + strlist.clear(); + for ( j = 1; j <= nbCols; j++ ) { + if ( realAttr->HasValue( i, j ) ) + strlist.append( QString::number( realAttr->GetValue( i, j ) ) ); + else + strlist.append( QString::null ); + } + setRowData( i-1, strlist ); + } + adjustTable(); + } + catch( ... ) { + MESSAGE("VISU_TableDlg::TableWidget::initialize : Exception has been caught !!!"); + } + } + break; + default: + break; + } + } + updateButtonsState(); +} + +/*! + Enable / disable editing +*/ +void VISU_TableDlg::TableWidget::setEditEnabled( bool enable ) +{ + // the feature has been temporarily disabled + enable = false; + + myTitleEdit->setReadOnly( !enable ); + myTable->setEditTriggers( enable ? + QAbstractItemView::DoubleClicked | + QAbstractItemView::SelectedClicked | + QAbstractItemView::EditKeyPressed : + QAbstractItemView::NoEditTriggers ); + myAddRowBtn->setVisible( enable ); + myDelRowBtn->setVisible( enable ); + myAddColBtn->setVisible( enable ); + myDelColBtn->setVisible( enable ); + mySelectAllBtn->setVisible( enable ); + myClearBtn->setVisible( enable ); +} + +/*! + Show / hide column titles +*/ +void VISU_TableDlg::TableWidget::showColumnTitles( bool showTitles ) +{ + if ( myOrientation == Qt::Horizontal ) + myTable->horizontalHeader()->setVisible( showTitles ); + else + myTable->verticalHeader()->setVisible( showTitles ); +} + +/*! + Sets table title +*/ +void VISU_TableDlg::TableWidget::setTableTitle( const QString& title ) +{ + myTitleEdit->setText( title ); +} + +/*! + Gets table title +*/ +QString VISU_TableDlg::TableWidget::getTableTitle() +{ + return myTitleEdit->text(); +} + +/*! + Sets total number of rows +*/ +void VISU_TableDlg::TableWidget::setNumRows( const int num ) +{ + myOrientation == Qt::Horizontal ? myTable->setRowCount( num ) : myTable->setColumnCount( num ); +} + +/*! + Gets total number of rows +*/ +int VISU_TableDlg::TableWidget::getNumRows() +{ + return myOrientation == Qt::Horizontal ? myTable->rowCount() : myTable->columnCount(); +} + +/*! + Sets total number of columns +*/ +void VISU_TableDlg::TableWidget::setNumCols( const int num ) +{ + // !!! first column contains units !!! + myOrientation == Qt::Horizontal ? myTable->setColumnCount( num+1 ) : myTable->setRowCount( num+1 ); +// myOrientation == Qt::Horizontal ? myTable->setColumnReadOnly( 0, true ) : myTable->setRowReadOnly( 0, true ); +} + +/*! + Gets total number of columns +*/ +int VISU_TableDlg::TableWidget::getNumCols() +{ + // !!! first column contains units !!! + return myOrientation == Qt::Horizontal ? myTable->columnCount()-1 : myTable->rowCount()-1; +} +/*! + Sets rows titles +*/ +void VISU_TableDlg::TableWidget::setRowTitles( QStringList& tlts ) +{ + QStringList aLabels; + for ( int i = 0; i < tlts.count(); i++ ) + tlts[i].isNull() ? aLabels.append("") : aLabels.append( tlts[i] ); + + myOrientation == Qt::Horizontal ? + myTable->setVerticalHeaderLabels( aLabels ) : + myTable->setHorizontalHeaderLabels( aLabels ); + + // myTable->verticalHeader()->setLabel( i, tlts[i] ) : + //myTable->horizontalHeader()->setLabel( i, tlts[i] ); + //} +} +/*! + Gets rows titles +*/ +void VISU_TableDlg::TableWidget::getRowTitles( QStringList& tlts ) +{ + tlts.clear(); + if ( myOrientation == Qt::Horizontal ) { + for ( int i = 0; i < myTable->rowCount(); i++ ) { + tlts.append( myTable->verticalHeaderItem(i) ? myTable->verticalHeaderItem(i)->text() : "" ); + } + } + else { + for ( int i = 0; i < myTable->columnCount(); i++ ) { + tlts.append( myTable->horizontalHeaderItem(i) ? myTable->horizontalHeaderItem(i)->text() : "" ); + } + } +} +/*! + Sets columns titles +*/ +void VISU_TableDlg::TableWidget::setColTitles( QStringList& tlts ) +{ + QStringList aLabels; + + // !!! first column contains units !!! + aLabels.append(""); // it'll be initialized below - in setUnitsTitle() method + + for ( int i = 0; i < tlts.count(); i++ ) + tlts[i].isNull() ? aLabels.append("") : aLabels.append( tlts[i] ); + + myOrientation == Qt::Horizontal ? + myTable->setHorizontalHeaderLabels( aLabels ) : + myTable->setVerticalHeaderLabels( aLabels ); + + setUnitsTitle( VISU_TableDlg::tr( "UNITS_TLT" ) ); +} +/*! + Sets columns titles +*/ +void VISU_TableDlg::TableWidget::getColTitles( QStringList& tlts ) +{ + // !!! first column contains units !!! + tlts.clear(); + if ( myOrientation == Qt::Horizontal ) { + for ( int i = 1; i < myTable->columnCount(); i++ ) { + tlts.append( myTable->horizontalHeaderItem(i) ? myTable->horizontalHeaderItem(i)->text() : "" ); + } + } + else { + for ( int i = 1; i < myTable->rowCount(); i++ ) { + tlts.append( myTable->verticalHeaderItem(i) ? myTable->verticalHeaderItem(i)->text() : "" ); + } + } +} +/*! + Sets units title +*/ +void VISU_TableDlg::TableWidget::setUnitsTitle( const QString& tlt ) { + // !!! first column contains units !!! + myTable->model()->setHeaderData( 0, myOrientation, QVariant(tlt.isNull() ? "" : tlt), Qt::DisplayRole ); +} +/*! + Sets units +*/ +void VISU_TableDlg::TableWidget::setUnits( QStringList& units ) +{ + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + QModelIndex anIndex; + for ( int i = 0; i < units.count(); i++ ) + { + myOrientation == Qt::Horizontal ? + anIndex = aModel->index( i, 0 ) : + anIndex = aModel->index( 0, i ); + + aModel->setData( anIndex, QVariant( units[i].isNull() ? "" : units[i] ) ); + } + } +} +/*! + Gets units +*/ +void VISU_TableDlg::TableWidget::getUnits( QStringList& units ) +{ + units.clear(); + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + if ( myOrientation == Qt::Horizontal ) + { + for ( int i = 0; i < myTable->rowCount(); i++ ) + units.append( aModel->index( i, 0 ).data().toString() ); + } + else { + for ( int i = 0; i < myTable->columnCount(); i++ ) + units.append( aModel->index( 0, i ).data().toString() ); + } + } +} +/*! + Sets row data +*/ +void VISU_TableDlg::TableWidget::setRowData( int row, QStringList& data ) +{ + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + QModelIndex anIndex; + if ( row >= 0 && row < getNumRows() ) { + for ( int i = 0; i < data.count(); i++ ) + { + myOrientation == Qt::Horizontal ? anIndex = aModel->index( row, i+1 ) : + anIndex = aModel->index( i+1, row ); + aModel->setData( anIndex, QVariant( data[i] ) ); + + } + } + } +} +/*! + Gets row data +*/ +void VISU_TableDlg::TableWidget::getRowData( int row, QStringList& data ) +{ + data.clear(); + QAbstractTableModel* aModel = qobject_cast( myTable->model() ); + if ( aModel ) + { + if ( row >= 0 && row < getNumRows() ) + { + if ( myOrientation == Qt::Horizontal ) + { + for ( int i = 1; i < myTable->columnCount(); i++ ) + data.append( aModel->index( row, i ).data().toString() ); + } + else { + for ( int i = 1; i < myTable->rowCount(); i++ ) + data.append( aModel->index( i, row ).data().toString() ); + } + } + } +} +/*! + Adjusts table cell to see contents, button slot +*/ +void VISU_TableDlg::TableWidget::adjustTable() +{ + myTable->resizeRowsToContents(); + myTable->resizeColumnsToContents(); +} +/*! + Called when selection changed in table +*/ +void VISU_TableDlg::TableWidget::updateButtonsState() +{ + if ( myTable->editTriggers() == QAbstractItemView::NoEditTriggers ) + return; + bool bDR = false; // + bool bDC = false; // + bool bSA = false; // button slot +*/ +void VISU_TableDlg::TableWidget::selectAll() +{ + /*myTable->clearSelection(); + QTableSelection ts; + ts.init( 0, 0 ); ts.expandTo( myTable->numRows()-1, myTable->numCols()-1 ); + myTable->addSelection( ts );*/ + myTable->selectAll(); + updateButtonsState(); +} +/*! + button slot +*/ +void VISU_TableDlg::TableWidget::clearTable() +{ + /*int nbSel = myTable->numSelections(); + for ( int i = 0; i < nbSel; i++ ) { + QTableSelection ts = myTable->selection( i ); + for ( int j = ts.topRow(); j < ts.bottomRow()+1; j++) { + if ( myOrientation == Qt::Vertical && j == 0 ) { +// continue; // UNITS + } + for ( int k = ts.leftCol(); k < ts.rightCol()+1; k++) { + if ( myOrientation == Qt::Horizontal && k == 0 ) { +// continue; // UNITS + } + myTable->clearCell( j, k ); + } + } + } + if ( nbSel == 0 ) + myTable->clearCell( myTable->currentRow(), myTable->currentColumn() ); + myTable->clearSelection();*/ + myTable->clearContents(); + updateButtonsState(); +} +/*! + Event filter - handles titles editing +*/ +bool VISU_TableDlg::TableWidget::eventFilter( QObject* o, QEvent* e ) +{ + if ( e->type() == QEvent::MouseButtonDblClick) { + //TODO + /*QMouseEvent* me = ( QMouseEvent* )e; + if ( me->button() == Qt::LeftButton && (myTable->editTriggers() != QAbstractItemView::NoEditTriggers ) ) { + if ( o == myTable->horizontalHeader() ) { + for ( int i = 0; i < myTable->horizontalHeader()->count(); i++ ) { + QRect rect = myTable->horizontalHeader()->sectionRect( i ); + rect.addCoords( 1, 1, -1, -1 ); + if ( rect.contains( myTable->horizontalHeader()->mapFromGlobal( me->globalPos() ) ) ) { + if ( myOrientation == Qt::Vertical || i != 0 ) { + bool bOk; + QString tlt = QInputDialog::getText( tr( "SET_TITLE_TLT" ), + tr( "TITLE_LBL" ), + QLineEdit::Normal, + myTable->horizontalHeader()->label( i ), + &bOk, + this ); + if ( bOk && !tlt.isNull() ) + myTable->horizontalHeader()->setLabel( i, tlt ); + break; + } + } + } + } + if ( o == myTable->verticalHeader() ) { + for ( int i = 0; i < myTable->verticalHeader()->count(); i++ ) { + QRect rect = myTable->verticalHeader()->sectionRect( i ); + rect.addCoords( 1, 1, -1, -1 ); + if ( rect.contains( myTable->verticalHeader()->mapFromGlobal( me->globalPos() ) ) ) { + if ( myOrientation == Qt::Horizontal || i != 0 ) { + bool bOk; + QString tlt = QInputDialog::getText( tr( "SET_TITLE_TLT" ), + tr( "TITLE_LBL" ), + QLineEdit::Normal, + myTable->verticalHeader()->label( i ), + &bOk, + this ); + if ( bOk && !tlt.isNull() ) + myTable->verticalHeader()->setLabel( i, tlt ); + break; + } + } + } + } + }*/ + } + else if ( e->type() == QEvent::KeyRelease && o == myTable ) { + QKeyEvent* ke = (QKeyEvent*)e; + if ( ke->key() == Qt::Key_Delete && (myTable->editTriggers() != QAbstractItemView::NoEditTriggers) ) { + clearTable(); + } + else if ( ke->key() == Qt::Key_Backspace && (myTable->editTriggers() != QAbstractItemView::NoEditTriggers) ) { + clearTable(); + int i = myTable->currentRow(); + int j = myTable->currentColumn() - 1; + if ( j < 0 ) { j = myTable->columnCount()-1; i--; } + if ( i >= 0 && j >= 0 ) + myTable->setCurrentCell( i, j ); + } + } + return QWidget::eventFilter( o, e ); +} diff --git a/src/VISU_I/VISU_TableDlg.h b/src/VISU_I/VISU_TableDlg.h new file mode 100644 index 00000000..626c6f21 --- /dev/null +++ b/src/VISU_I/VISU_TableDlg.h @@ -0,0 +1,176 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : VISU_TableDlg.h +// Author : Vadim SANDLER +// Module : VISU +// +#ifndef VISU_TABLEDLG_H +#define VISU_TABLEDLG_H + +#include "VISU_I.hxx" + +#include + +#include +#include +#include + +class QLineEdit; +class QPushButton; +class QCheckBox; +class QTableWidget; + +namespace VISU +{ + class Table_i; +} + +class VISU_I_EXPORT VISU_TableDlg : public QDialog +{ + Q_OBJECT + + class TableWidget; + class WidgetCointainer; + + enum { tcTitle, tcTable, tcControls, tcButtons }; + +public: + + enum { ttNone, ttInt, ttReal, ttAll, ttAuto }; + enum { teNone = 0x00, + teAddRemove = 0x01, + teEditData = 0x02, + teRowColumn = 0x04, + teAll = teAddRemove | teEditData | teRowColumn + }; + + VISU_TableDlg( QWidget* parent, + _PTR(Study) study, + VISU::Table_i* table, + bool allowEdition = false, + int which = ttAuto, + Qt::Orientation orient = Qt::Horizontal, + bool showColumnTitles = true ); + ~VISU_TableDlg(); + +protected: + void keyPressEvent( QKeyEvent* e ); + +private slots: + void help(); + +private: + QString tableTitle( int type ); + +private: + typedef QMap TableMap; + typedef QMap ContMap; + + TableMap myTableMap; + ContMap myContMap; + QCheckBox* myEditCheck; + QCheckBox* myUpdateCheck; + QPushButton* myOKBtn; + QPushButton* myHelpBtn; + + _PTR(Study) myStudy; + VISU::Table_i* myTable; +}; + +class VISU_I_EXPORT VISU_TableDlg::TableWidget : public QWidget +{ + Q_OBJECT + +public: + TableWidget( QWidget* parent = 0, Qt::Orientation orientation = Qt::Horizontal ); + ~TableWidget(); + + void initialize( _PTR(Study) study, VISU::Table_i* table, int type ); + + void setTableTitle( const QString& title ); + QString getTableTitle(); + void setNumRows( const int num ); + int getNumRows(); + void setNumCols( const int num ); + int getNumCols(); + void setRowTitles( QStringList& tlts ); + void getRowTitles( QStringList& tlts ); + void setColTitles( QStringList& tlts ); + void getColTitles( QStringList& tlts ); + void setUnitsTitle( const QString& tlt ); + void setUnits( QStringList& units ); + void getUnits( QStringList& units ); + void setRowData( int row, QStringList& data ); + void getRowData( int row, QStringList& data ); + + bool eventFilter( QObject* o, QEvent* e); + +public slots: + void setEditEnabled( bool enable ); + void showColumnTitles( bool showTitles ); + + void updateButtonsState(); + void addRow(); + void addCol(); + void delRow(); + void delCol(); + void adjustTable(); + void selectAll(); + void clearTable(); + +private: + _PTR(Study) myStudy; + VISU::Table_i* myTableObj; + _PTR(GenericAttribute) myAttr; + int myType; + + QLineEdit* myTitleEdit; + QTableWidget* myTable; + QPushButton* myAddRowBtn; + QPushButton* myAddColBtn; + QPushButton* myDelRowBtn; + QPushButton* myDelColBtn; + QPushButton* myAdjustBtn; + QPushButton* mySelectAllBtn; + QPushButton* myClearBtn; + Qt::Orientation myOrientation; +}; + +class VISU_I_EXPORT NumDelegateItem: public QItemDelegate +{ +public: + enum NumValidator{ NV_Int, NV_Real }; + + NumDelegateItem( QObject* parent, NumValidator mode = NV_Int ); + virtual ~NumDelegateItem(); + + virtual QWidget* createEditor( QWidget* parent, + const QStyleOptionViewItem& option, + const QModelIndex& index ) const; + virtual void setEditorData( QWidget* editor, + const QModelIndex& index ) const; +private: + int myMode; +}; + +#endif // VISU_TABLEDLG_H + diff --git a/src/VISU_I/VISU_View_i.cc b/src/VISU_I/VISU_View_i.cc index 89ebe9d2..0d1d6be2 100644 --- a/src/VISU_I/VISU_View_i.cc +++ b/src/VISU_I/VISU_View_i.cc @@ -32,8 +32,7 @@ #include "VISU_PointMap3d_i.hh" #include "VISU_ScalarMap_i.hh" #include "VISU_ViewManager_i.hh" - -#include "VisuGUI_TableDlg.h" +#include "VISU_TableDlg.h" #include "VISU_Actor.h" #include "VISU_ScalarMapAct.h" @@ -1471,7 +1470,7 @@ namespace VISU { SalomeApp_Application* myApplication; VISU::Table_i* myTable; - typedef VisuGUI_TableDlg* TResult; + typedef VISU_TableDlg* TResult; TResult myResult; TCreateTableViewEvent (SalomeApp_Application* theApplication, @@ -1489,15 +1488,13 @@ namespace VISU { if (SUIT_Study* aSStudy = myApplication->activeStudy()) { if (SalomeApp_Study* aStudy = dynamic_cast(aSStudy)) { if (_PTR(Study) aCStudy = aStudy->studyDS()) { - _PTR(SObject) aSObject = aCStudy->FindObjectID(myTable->GetObjectEntry()); - if (aSObject) { - myResult = new VisuGUI_TableDlg (myApplication->desktop(), - aSObject, - false, - VisuGUI_TableDlg::ttAuto, - Qt::Vertical); - myResult->show(); - } + myResult = new VISU_TableDlg (myApplication->desktop(), + aCStudy, + myTable, + false, + VISU_TableDlg::ttAuto, + Qt::Vertical); + myResult->show(); } } } @@ -1528,8 +1525,8 @@ namespace VISU { void TableView_i::SetTitle (const char* theTitle) { - ProcessVoidEvent(new TVoidMemFun1ArgEvent - (myView, &VisuGUI_TableDlg::setWindowTitle, QString(theTitle))); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myView, &VISU_TableDlg::setWindowTitle, QString(theTitle))); } char* TableView_i::GetTitle() diff --git a/src/VISU_I/VISU_View_i.hh b/src/VISU_I/VISU_View_i.hh index 6e644af5..86e4f977 100644 --- a/src/VISU_I/VISU_View_i.hh +++ b/src/VISU_I/VISU_View_i.hh @@ -32,7 +32,7 @@ class QWidget; -class VisuGUI_TableDlg; +class VISU_TableDlg; class SalomeApp_Application; @@ -212,7 +212,7 @@ namespace VISU virtual void Close(); protected: - VisuGUI_TableDlg* myView; + VISU_TableDlg* myView; public: virtual Storable* Create (VISU::Table_ptr theTable); };