From: apo Date: Tue, 8 Nov 2005 12:26:43 +0000 (+0000) Subject: Adjust to LightApp architecture X-Git-Tag: TG-D5-38-2003_D2005-20-12~119 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=766931725fd65993937039d5bfeb6d347a6163ab;p=modules%2Fvisu.git Adjust to LightApp architecture --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index def9b9fc..f41c3be9 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -70,9 +70,9 @@ #include "SalomeApp_Application.h" #include "SalomeApp_DataModel.h" #include "SalomeApp_Study.h" -#include "SalomeApp_SelectionMgr.h" -#include "SalomeApp_Selection.h" -#include "SalomeApp_Preferences.h" +#include "LightApp_SelectionMgr.h" +#include "LightApp_Selection.h" +#include "LightApp_Preferences.h" #include "QtxAction.h" @@ -100,6 +100,7 @@ #include "VisuGUI_ClippingDlg.h" #include "VisuGUI_Plot3DDlg.h" #include "VisuGUI_OffsetDlg.h" +#include "VisuGUI_Displayer.h" #include "VISU_ScalarMap_i.hh" #include "VisuGUI_ScalarBarDlg.h" @@ -146,7 +147,8 @@ static int MYDEBUG = 0; ////////////////////////////////////////////////// VisuGUI::VisuGUI(): - SalomeApp_Module( "VISU" ) + SalomeApp_Module( "VISU" ), + myDisplayer( 0 ) { } @@ -297,7 +299,7 @@ OnExportTableToFile() _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -401,7 +403,7 @@ OnImportMedField() return; SALOMEDS::Study_var aStudy = GetDSStudy(aCStudy); - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -521,7 +523,7 @@ OnCreateManyMesh() GetViewWindow( this, /*create=*/true ); // Get selected SObject - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); SALOME_ListIteratorOfListIO anIter (aListIO); @@ -608,7 +610,7 @@ OnDisplayPrs() QApplication::setOverrideCursor(Qt::waitCursor); SALOME_ListIO aList; - SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this); + LightApp_SelectionMgr* mgr = GetSelectionMgr(this); mgr->selectedObjects(aList); Handle(SALOME_InteractiveObject) anIO; @@ -679,7 +681,7 @@ OnErasePrs() vw->unHighlightAll(); SALOME_ListIO aList; - SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this); + LightApp_SelectionMgr* mgr = GetSelectionMgr(this); mgr->selectedObjects(aList); Handle(SALOME_InteractiveObject) anIO; @@ -1118,8 +1120,8 @@ OnDeleteObjects() return; SALOME_ListIO aList; - SalomeApp_SelectionMgr* mgr = GetSelectionMgr(this); - mgr->selectedObjects(aList); + LightApp_SelectionMgr* mgr = GetSelectionMgr(this); + mgr->selectedObjects(aList,QString::null,false); int i = 0, nbSelected = aList.Extent(); if (nbSelected < 1) return; @@ -1311,7 +1313,7 @@ void VisuGUI:: OnCurveProperties() { - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); if (aListIO.Extent() != 1) return; @@ -1409,7 +1411,7 @@ OnSaveViewParams() if (aViewMgr->getType() != SVTK_Viewer::Type()) return; - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); if (aListIO.Extent() > 1) @@ -1432,7 +1434,7 @@ OnRestoreViewParams() if (aViewMgr->getType() != SVTK_Viewer::Type()) return; - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); if (aListIO.Extent() != 1) @@ -1594,7 +1596,7 @@ OnTimeAnimation() // new VisuGUI_TimeAnimationDlg(GetDesktop(this), aCStudy); new VisuGUI_TimeAnimationDlg (this, aCStudy); - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -1626,7 +1628,7 @@ void VisuGUI:: OnShowAnimation() { - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -1769,7 +1771,7 @@ void VisuGUI:: OnMergeScalarBars() { - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -1832,7 +1834,7 @@ void VisuGUI:: OnFreeScalarBars() { - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -1876,7 +1878,7 @@ OnTranslatePrs() _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this)); - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -2542,7 +2544,7 @@ void VisuGUI::contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, Q OB_Browser* ob = getApp()->objectBrowser(); bool isOBClient = (ob && theClient == ob->popupClientType()); - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -2699,7 +2701,7 @@ deactivateModule( SUIT_Study* theStudy ) return true; } -SalomeApp_Selection* +LightApp_Selection* VisuGUI:: createSelection() const { @@ -2726,10 +2728,10 @@ void VisuGUI::createPreferences() int sbarTab = addPreference( tr( "VISU_SCALAR_BAR" ) ); int fontGr = addPreference( tr( "VISU_FONT" ), sbarTab ); - int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_title_font" ); - addPreference( tr( "VISU_TITLE" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_title_color" ); - int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Font, "VISU", "scalar_bar_label_font" ); - addPreference( tr( "VISU_LABELS" ), fontGr, SalomeApp_Preferences::Color, "VISU", "scalar_bar_label_color" ); + int tfont = addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_title_font" ); + addPreference( tr( "VISU_TITLE" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_title_color" ); + int lfont = addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Font, "VISU", "scalar_bar_label_font" ); + addPreference( tr( "VISU_LABELS" ), fontGr, LightApp_Preferences::Color, "VISU", "scalar_bar_label_color" ); QStringList fam; fam.append( tr( "VISU_FONT_ARIAL" ) ); @@ -2746,16 +2748,16 @@ void VisuGUI::createPreferences() int colorsLabelsGr = addPreference( tr( "VISU_COLORS_AND_LABELS" ), sbarTab ); - int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" ); + int numcol = addPreference( tr( "VISU_NB_COLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_colors" ); setPreferenceProperty( numcol, "min", 2 ); setPreferenceProperty( numcol, "max", 256 ); - int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" ); + int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "VISU", "scalar_bar_num_labels" ); setPreferenceProperty( numlab, "min", 2 ); setPreferenceProperty( numlab, "max", 65 ); int orientGr = addPreference( tr( "VISU_ORIENTATION" ), sbarTab ); - int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_orientation" ); + int orient = addPreference( tr( "VISU_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_orientation" ); QStringList orients; orients.append( tr( "VISU_VERTICAL" ) ); orients.append( tr( "VISU_HORIZONTAL" ) ); @@ -2766,10 +2768,10 @@ void VisuGUI::createPreferences() setPreferenceProperty( orient, "indexes", indices ); int posVSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_VERTICAL" ), sbarTab ); - int xv = addPreference( tr( "VISU_X" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" ); - int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" ); - int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" ); - int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" ); + int xv = addPreference( tr( "VISU_X" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_x" ); + int yv = addPreference( tr( "VISU_Y" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_y" ); + int wv = addPreference( tr( "VISU_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_width" ); + int hv = addPreference( tr( "VISU_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_vertical_height" ); setPreferenceProperty( xv, "step", 0.1 ); setPreferenceProperty( yv, "step", 0.1 ); setPreferenceProperty( wv, "step", 0.1 ); @@ -2784,10 +2786,10 @@ void VisuGUI::createPreferences() setPreferenceProperty( hv, "max", 1.0 ); int posHSizeGr = addPreference( tr( "VISU_ORIGIN_AND_SIZE" ) + " " + tr( "VISU_HORIZONTAL" ), sbarTab ); - int xh = addPreference( tr( "VISU_X" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" ); - int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" ); - int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" ); - int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" ); + int xh = addPreference( tr( "VISU_X" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_x" ); + int yh = addPreference( tr( "VISU_Y" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_y" ); + int wh = addPreference( tr( "VISU_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_width" ); + int hh = addPreference( tr( "VISU_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "VISU", "scalar_bar_horizontal_height" ); setPreferenceProperty( xh, "step", 0.1 ); setPreferenceProperty( yh, "step", 0.1 ); setPreferenceProperty( wh, "step", 0.1 ); @@ -2806,7 +2808,7 @@ void VisuGUI::createPreferences() int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab ); setPreferenceProperty( rangeGr, "columns", 1 ); - int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_bar_mode" ); + int mode = addPreference( tr( "VISU_SCALAR_MODE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_bar_mode" ); QStringList modes; modes.append( tr( "VISU_MODULUS" ) ); modes.append( tr( "VISU_COMPONENT" ) + tr("1") ); @@ -2820,9 +2822,9 @@ void VisuGUI::createPreferences() setPreferenceProperty( mode, "strings", modes ); setPreferenceProperty( mode, "indexes", indices ); - addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" ); + addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, LightApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" ); - int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" ); + int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, LightApp_Preferences::Selector, "VISU", "scalar_range_type" ); QStringList types; types.append( tr( "VISU_FIELD_RANGE" ) ); types.append( tr( "VISU_IMPOSED_RANGE" ) ); @@ -2834,17 +2836,17 @@ void VisuGUI::createPreferences() int imposedGr = addPreference( tr( "VISU_MINMAX_IMPOSED_RANGE" ), srangeTab ); - int min = addPreference( tr( "VISU_MIN" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_min" ); - int max = addPreference( tr( "VISU_MAX" ), imposedGr, SalomeApp_Preferences::DblSpin, "VISU", "scalar_range_max" ); + int min = addPreference( tr( "VISU_MIN" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_min" ); + int max = addPreference( tr( "VISU_MAX" ), imposedGr, LightApp_Preferences::DblSpin, "VISU", "scalar_range_max" ); setPreferenceProperty( min, "step", 0.1 ); setPreferenceProperty( max, "step", 0.1 ); int sweepGr = addPreference( tr( "VISU_SWEEPING_PREF" ), srangeTab ); setPreferenceProperty( sweepGr, "columns", 1 ); - int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, SalomeApp_Preferences::DblSpin, "VISU", "sweeping_time_step" ); - int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" ); - int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, SalomeApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" ); + int timestep = addPreference( tr( "VISU_TIME_STEP" ), sweepGr, LightApp_Preferences::DblSpin, "VISU", "sweeping_time_step" ); + int nbcycles = addPreference( tr( "VISU_NB_CYCLES" ), sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_cycles" ); + int nbsteps = addPreference( tr( "VISU_NB_STEPS" ), sweepGr, LightApp_Preferences::IntSpin, "VISU", "sweeping_number_steps" ); setPreferenceProperty( timestep, "min", 0.1 ); setPreferenceProperty( timestep, "step", 0.1 ); setPreferenceProperty( timestep, "max", 1000 ); @@ -2852,7 +2854,7 @@ void VisuGUI::createPreferences() setPreferenceProperty( nbsteps, "max", 200 ); int importGr = addPreference( tr( "MED files import" ), srangeTab ); - addPreference( tr( "Full MED loading" ), importGr, SalomeApp_Preferences::Bool, "VISU", "full_med_loading" ); + addPreference( tr( "Full MED loading" ), importGr, LightApp_Preferences::Bool, "VISU", "full_med_loading" ); } void VisuGUI::preferencesChanged( const QString&, const QString& ) @@ -2867,7 +2869,10 @@ VisuGUI return getApp()->getViewManager(theType,theIsCreate); } -SalomeApp_Displayer* VisuGUI::displayer() +LightApp_Displayer* VisuGUI::displayer() { - return 0; + if( !myDisplayer ) + myDisplayer = new VisuGUI_Displayer( dynamic_cast( getApp()->activeStudy() ) ); + + return myDisplayer; } diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index aa8e4316..30c24e82 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -42,7 +42,7 @@ public: VisuGUI(); virtual ~VisuGUI(); - virtual SalomeApp_Displayer* displayer(); + virtual LightApp_Displayer* displayer(); virtual void initialize( CAM_Application* ); virtual void windows( QMap& ) const; virtual void viewManagers( QStringList& ) const; @@ -105,6 +105,9 @@ protected slots: void OnMakePoints(); void OnMakeShrink(); + void OnSetShadingOn(); + void OnSetShadingOff(); + void OnChangeColor(); void OnChangeWireframeColor(); void OnChangeOpacity(); @@ -138,7 +141,7 @@ protected slots: void OnArrangeActors(); protected: - virtual SalomeApp_Selection* createSelection() const; + virtual LightApp_Selection* createSelection() const; private: void createActions(); @@ -147,7 +150,7 @@ private: void createPopupMenus(); private: - SalomeApp_Displayer* myDisplayer; + LightApp_Displayer* myDisplayer; }; #endif diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index f9b591aa..549aeda6 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -28,6 +28,8 @@ #include "VisuGUI_Module.h" +#include "QtxPopupMgr.h" + #include "SUIT_Study.h" #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" @@ -37,8 +39,8 @@ #include "CAM_Module.h" #include "SalomeApp_Application.h" -#include "SalomeApp_SelectionMgr.h" -#include "SalomeApp_VTKSelector.h" +#include "LightApp_SelectionMgr.h" +#include "LightApp_VTKSelector.h" #include "SalomeApp_Preferences.h" #include "VVTK_ViewManager.h" @@ -100,7 +102,7 @@ namespace VISU class Viewer { VVTK_ViewManager* myViewManager; - SalomeApp_VTKSelector* mySelector; + LightApp_VTKSelector* mySelector; public: Viewer(VisuGUI_Module* theModule, TViewerMap& theViewerMap) @@ -108,7 +110,7 @@ namespace VISU SalomeApp_Application* anApp = theModule->getApp(); myViewManager = new VVTK_ViewManager( anApp->activeStudy(), anApp->desktop() ); VVTK_Viewer* aViewer = (VVTK_Viewer*)myViewManager->getViewModel(); - mySelector = new SalomeApp_VTKSelector( aViewer, anApp->selectionMgr() ); + mySelector = new LightApp_VTKSelector( aViewer, anApp->selectionMgr() ); anApp->addViewManager( myViewManager ); theViewerMap.insert(TViewerMap::value_type(myViewManager,PViewer(this))); @@ -828,7 +830,7 @@ VisuGUI_Module QApplication::setOverrideCursor(Qt::waitCursor); - if(SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){ + if(LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){ SALOME_ListIO aList; aSelectionMgr->selectedObjects(aList); for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){ @@ -896,7 +898,7 @@ void VisuGUI_Module ::OnDisplayOnlyPrs() { - if(SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){ + if(LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this)){ SALOME_ListIO aList; aSelectionMgr->selectedObjects(aList); for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){ @@ -926,7 +928,7 @@ VisuGUI_Module QApplication::setOverrideCursor(Qt::waitCursor); SALOME_ListIO aList; - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); aSelectionMgr->selectedObjects(aList); for(SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next()){ @@ -1127,7 +1129,7 @@ OnSaveViewParams() if (CheckLock(aCStudy)) return; - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -1190,7 +1192,7 @@ void VisuGUI_Module:: OnRestoreViewParams() { - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 88bb6480..ef22f154 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -28,7 +28,11 @@ #include "VisuGUI_PopupTools.h" #include "VisuGUI_ViewTools.h" #include "VisuGUI_Tools.h" +#include "SalomeApp_Study.h" +#include "LightApp_Study.h" +#include "VISU_Actor.h" +#include "VISU_ScalarMapAct.h" #include "VISU_Result_i.hh" #include "SalomeApp_Study.h" @@ -40,7 +44,7 @@ using namespace VISU; QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const { - QtxValue val( SalomeApp_Selection::param( ind, p ) ); + QtxValue val( LightApp_Selection::param( ind, p ) ); if ( !val.isValid() ) { if ( p == "type" ) val = QtxValue( type( ind ) ); else if ( p == "nbComponents" ) val = QtxValue( nbComponents( ind ) ); @@ -53,6 +57,8 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const else if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) ); else if ( p == "isShrunk" ) val = QtxValue( isShrunk( ind ) ); else if ( p == "hasActor" ) val = QtxValue( hasActor( ind ) ); + else if ( p == "isShading" ) val = QtxValue( isShading( ind ) ); + else if ( p == "isScalarMapAct" ) val = QtxValue( isScalarMapAct( ind ) ); } return val; @@ -68,7 +74,10 @@ QString VisuGUI_Selection::type( const int ind ) const { QString aResStr; VISU::Storable::TRestoringMap aMap; - CORBA::Object_var anObject = GetSelectedObj( study(), entry( ind ), &aMap ); + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + CORBA::Object_var anObject = GetSelectedObj( aStudy, entry( ind ), &aMap ); VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject ); if ( !CORBA::is_nil( aVisuObj ) ){ @@ -121,7 +130,10 @@ QString VisuGUI_Selection::nbComponents( const int ind ) const { QString aResStr; VISU::Storable::TRestoringMap aMap; - GetSelectedObj( study(), entry( ind ), &aMap ); + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + GetSelectedObj( aStudy, entry( ind ), &aMap ); bool isExist; const QString& aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist); if ( isExist ) @@ -133,7 +145,7 @@ QString VisuGUI_Selection::medEntity( const int ind ) const { bool isExist; VISU::Storable::TRestoringMap aMap; - GetSelectedObj( study(), entry( ind ), &aMap ); + GetSelectedObj( GetStudy(), entry( ind ), &aMap ); const QString& aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist); if ( isExist ) { using namespace VISU; @@ -156,7 +168,7 @@ QString VisuGUI_Selection::medEntity( const int ind ) const QString VisuGUI_Selection::medSource( const int ind ) const { - _PTR(Study) aStudyDS = study()->studyDS(); + _PTR(Study) aStudyDS = GetStudy()->studyDS(); if(_PTR(SObject) aSObject = aStudyDS->FindObjectID(entry(ind))){ VISU::Result_var aRes; if(VISU::Result_i* aResult = CheckResult(myModule,aSObject,aRes)){ @@ -183,7 +195,10 @@ QString VisuGUI_Selection::nbTimeStamps( const int ind ) const { QString aResStr; VISU::Storable::TRestoringMap aMap; - GetSelectedObj( study(), entry( ind ), &aMap ); + SalomeApp_Study* aStudy = GetStudy(); + if ( !aStudy ) + return aResStr; + GetSelectedObj( aStudy, entry( ind ), &aMap ); bool isExist; const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist); if ( isExist ) @@ -211,10 +226,20 @@ QString VisuGUI_Selection::representation( const int ind ) const return aResStr; } +SalomeApp_Study* VisuGUI_Selection::GetStudy() const + +{ + LightApp_Study* aLightStudy = const_cast( study() ); + return dynamic_cast( aLightStudy ); +} + int VisuGUI_Selection::nbChild( const int ind, const bool named ) const { int cnt = 0; - _PTR(Study) aStudy = GetCStudy( study() ); + SalomeApp_Study* aSStudy = GetStudy(); + if ( !aSStudy ) + return cnt; + _PTR(Study) aStudy = GetCStudy( aSStudy ); if ( aStudy ){ _PTR(SObject) SO = aStudy->FindObjectID( entry( ind ).latin1() ); if ( SO ){ @@ -301,3 +326,29 @@ QString VisuGUI_Selection::hasActor( const int ind ) const { return representation( ind ).isEmpty() ? "0" : "1"; } + +QString VisuGUI_Selection::isShading( const int ind ) const +{ + QString aResStr; + + if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ) + if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) + if ( VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor) ) + aResStr = anActor->IsShading() ? "1" : "0"; + + return aResStr; +} + +QString VisuGUI_Selection::isScalarMapAct( const int ind ) const +{ + QString aResStr; + + if ( SVTK_ViewWindow* aView = GetViewWindow( myModule ) ) + if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) ) + { + VISU_ScalarMapAct* anActor = dynamic_cast(anVISUActor); + aResStr = anActor ? "1" : "0"; + } + + return aResStr; +} diff --git a/src/VISUGUI/VisuGUI_PopupTools.h b/src/VISUGUI/VisuGUI_PopupTools.h index 42b6a839..1a7ae957 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.h +++ b/src/VISUGUI/VisuGUI_PopupTools.h @@ -28,15 +28,16 @@ #ifndef VisuGUI_PopupTools_HeaderFile #define VisuGUI_PopupTools_HeaderFile -#include +#include ////////////////////////////////////////////////// // Class: VisuGUI_Selection ////////////////////////////////////////////////// class SalomeApp_Module; +class SalomeApp_Study; -class VisuGUI_Selection : public SalomeApp_Selection +class VisuGUI_Selection : public LightApp_Selection { public: VisuGUI_Selection( SalomeApp_Module* theModule ) : myModule( theModule ) {}; @@ -56,9 +57,12 @@ private: QString isVisible( const int ) const; QString isShrunk( const int ) const; QString hasActor( const int ) const; + QString isShading( const int ) const; + QString isScalarMapAct( const int ) const; private: int nbChild( const int, const bool ) const; + SalomeApp_Study* GetStudy() const; private: SalomeApp_Module* myModule; diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 0948023b..4ffcf68d 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -38,8 +38,8 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" -#include "SalomeApp_SelectionMgr.h" -#include "SalomeApp_VTKSelector.h" +#include "LightApp_SelectionMgr.h" +#include "LightApp_VTKSelector.h" #include "SUIT_MessageBox.h" #include "SUIT_ViewWindow.h" @@ -512,7 +512,7 @@ typedef vtkIdType (vtkDataSet::* TDataSetMethod)(); bool onIdEdit (const QString& theText, TDataSetMethod theMethod, bool theIsCell, - SalomeApp_SelectionMgr* theSelectionMgr, + LightApp_SelectionMgr* theSelectionMgr, QLabel* theMeshName, QString theValue, QLabel* theFieldName) diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 71b4bcef..5484e621 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -36,11 +36,12 @@ #include "VISU_ViewManager_i.hh" #include "VISU_Actor.h" +#include "VISU_ScalarMapAct.h" #include "SalomeApp_Module.h" #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_SelectionMgr.h" #include "SALOME_ListIO.hxx" #include "SALOME_ListIteratorOfListIO.hxx" @@ -70,7 +71,7 @@ namespace VISU return theModule->application()->desktop(); } - SalomeApp_SelectionMgr* + LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule) { return theModule->getApp()->selectionMgr(); @@ -192,7 +193,7 @@ namespace VISU Handle(SALOME_InteractiveObject)* theIO, VISU::Storable::TRestoringMap* theMap) { - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); SALOME_ListIteratorOfListIO anIter(aListIO); @@ -226,7 +227,7 @@ namespace VISU } void - Add(SalomeApp_SelectionMgr* theSelectionMgr, + Add(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO) { SALOME_ListIO aListIO; @@ -236,7 +237,7 @@ namespace VISU } void - Remove(SalomeApp_SelectionMgr* theSelectionMgr, + Remove(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO) { if (theIO.IsNull()) return; @@ -261,7 +262,7 @@ namespace VISU bool IsRemovableSelected (const SalomeApp_Module* theModule) { - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); SALOME_ListIO aListIO; aSelectionMgr->selectedObjects(aListIO); @@ -392,12 +393,11 @@ namespace VISU _PTR(SObject) theSObject) { SalomeApp_Study* study = GetAppStudy( theModule ); - study->deleteReferencesTo( theSObject ); _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject); for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) { _PTR(SObject) aChildSObject = aChildIter->Value(); - study->deleteReferencesTo( aChildSObject ); + CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject); ErasePrs(theModule, aChildObj); } @@ -430,7 +430,7 @@ namespace VISU return; SALOMEDS::SObject_var aSObject = thePrs->GetSObject(); CORBA::String_var anEntry = aSObject->GetID(); - SalomeApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule); Remove(aSelectionMgr,theIO); TViewWindows aViewWindows = GetViews(theModule); for(int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++){ @@ -500,6 +500,36 @@ namespace VISU } } } + + void + SetShading ( const SalomeApp_Module* theModule, + bool theOn ) + { + SUIT_ViewWindow* aView = GetActiveView(theModule, SVTK_Viewer::Type()); + if (!aView) return; + SVTK_ViewWindow* vw = dynamic_cast( aView ); + if( !vw ) + return; + + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO); + if (CORBA::is_nil(anObject)) return; + + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (CORBA::is_nil(aVisuObj)) return; + + PortableServer::ServantBase_var aServant = VISU::GetServant(anObject); + if (!aServant.in()) return; + + VISU::Prs3d_i* aPrs3d = dynamic_cast(aServant.in()); + if (aPrs3d) { + if (VISU_Actor* anActor = GetActor(aPrs3d, vw)) { + if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast(anActor) ) + aScalarMapActor->SetShading( theOn ); + } + vw->Repaint(); + } + } //************************************************************ // SObject type @@ -604,6 +634,23 @@ namespace VISU } SVTK_ViewWindow* + GetViewWindow( const SalomeApp_Module* theModule, const bool theCreate ) + { + if (SalomeApp_Application* anApp = theModule->getApp()) + { + SVTK_ViewWindow* wnd = dynamic_cast(anApp->desktop()->activeWindow()); + if( wnd ) + return wnd; + else + { + SUIT_ViewManager* aViewManager = anApp->getViewManager( SVTK_Viewer::Type(), theCreate ); + return dynamic_cast( aViewManager->getActiveView() ); + } + } + return NULL; + } + + /*SVTK_ViewWindow* GetViewWindow(const SalomeApp_Module* theModule, const bool theCreate ) { if(SalomeApp_Application* anApp = theModule->getApp()){ @@ -614,7 +661,7 @@ namespace VISU } } return NULL; - } + }*/ SVTK_ViewWindow* @@ -649,7 +696,7 @@ namespace VISU }catch(std::exception& exc){ SUIT_MessageBox::warn1(GetDesktop(theModule), QObject::tr("WRN_VISU"), - QObject::tr("ERR_CANT_CREATE_ACTOR"), + QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()), QObject::tr("BUT_OK")); } QApplication::restoreOverrideCursor(); @@ -680,9 +727,16 @@ namespace VISU if(aPrs == NULL) continue; if (thePrs == aPrs) { aResActor = anVISUActor; - thePrs->UpdateActor(aResActor); - aResActor->VisibilityOn(); - + try { + thePrs->UpdateActor(aResActor); + aResActor->VisibilityOn(); + } catch (std::runtime_error& ex) { + aResActor->VisibilityOff(); + INFOS(ex.what()); + SUIT_MessageBox::warn1(GetDesktop(theModule), QObject::tr("WRN_VISU"), + QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(ex.what()), + QObject::tr("BUT_OK")); + } } else if (theDispOnly) { anVISUActor->VisibilityOff(); } else { @@ -695,7 +749,7 @@ namespace VISU if (aResActor) return aResActor; - anVISUActor = PublishInView( theModule, thePrs ); + //anVISUActor = PublishInView( theModule, thePrs ); return anVISUActor; } @@ -755,6 +809,7 @@ namespace VISU VISU::Prs3d_i* thePrs) { QApplication::setOverrideCursor(Qt::waitCursor); + bool isPublished = false; SALOMEDS::SObject_var aSObject = thePrs->GetSObject(); CORBA::String_var anEntry = aSObject->GetID(); @@ -766,6 +821,7 @@ namespace VISU for (int i = 0, iEnd = aViewWindows.size(); i < iEnd; i++) { SVTK_ViewWindow* aView = aViewWindows[i]; if (VISU_Actor* anActor = FindActor(aView, anEntry.in())) { + isPublished = true; thePrs->UpdateActor(anActor); } } @@ -773,7 +829,7 @@ namespace VISU INFOS(ex.what()); QApplication::restoreOverrideCursor(); SUIT_MessageBox::warn1 (GetDesktop(theModule), QObject::tr("WRN_VISU"), - QObject::tr("ERR_CANT_BUILD_PRESENTATION") + " " + QObject::tr(ex.what()), + QObject::tr("ERR_CANT_BUILD_PRESENTATION") + ": " + QObject::tr(ex.what()), QObject::tr("BUT_OK")); TViewWindows aViewWindows = GetViews(theModule); @@ -787,6 +843,9 @@ namespace VISU return; } QApplication::restoreOverrideCursor(); + + if (!isPublished) + PublishInView(theModule, thePrs); } static bool ComputeVisiblePropBounds(SVTK_ViewWindow* theViewWindow, @@ -894,7 +953,7 @@ namespace VISU int theDisplaying) { if ( theDisplaying == VISU::eErase ) { - if ( plotCurve ) + if ( plotCurve && aPlot ) aPlot->eraseCurve( plotCurve, false ); } else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { @@ -917,12 +976,14 @@ namespace VISU plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); } plotCurve->setAutoAssign( theCurve->IsAuto() ); - aPlot->displayCurve( plotCurve, false ); + if( aPlot ) + aPlot->displayCurve( plotCurve, false ); } else { Plot2d_Curve* crv = theCurve->CreatePresentation(); if ( crv ) { - aPlot->displayCurve( crv, false ); + if( aPlot ) + aPlot->displayCurve( crv, false ); theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); SALOMEDS::Color newColor; @@ -1164,7 +1225,7 @@ namespace VISU INFOS(exc.what()); SUIT_MessageBox::warn1 (GetDesktop(theModule), QObject::tr("WRN_VISU"), - QObject::tr("ERR_CANT_CREATE_ACTOR") + " " + QObject::tr(exc.what()), + QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()), QObject::tr("BUT_OK")); } } diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 3d6fd0e5..3f36c793 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -45,8 +45,10 @@ class SUIT_ViewWindow; class VISU_Actor; class SVTK_ViewWindow; class SPlot2d_Viewer; +class SPlot2d_Curve; +class Plot2d_ViewFrame; class CAM_Module; -class SalomeApp_SelectionMgr; +class LightApp_SelectionMgr; class SalomeApp_Study; namespace VISU { @@ -75,7 +77,7 @@ namespace VISU { QString getValue(_PTR(SObject) theSObject, QString theKey); // Selection - SalomeApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule); + LightApp_SelectionMgr* GetSelectionMgr(const SalomeApp_Module* theModule); CORBA::Object_var GetSelectedObj(const SalomeApp_Study* theStudy, const QString& theEntry, VISU::Storable::TRestoringMap* theMap = NULL); @@ -86,9 +88,9 @@ namespace VISU { Handle(SALOME_InteractiveObject)* theIO = NULL, VISU::Storable::TRestoringMap* theMap = NULL); - void Add(SalomeApp_SelectionMgr* theSelectionMgr, + void Add(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO); - void Remove(SalomeApp_SelectionMgr* theSelectionMgr, + void Remove(LightApp_SelectionMgr* theSelectionMgr, const Handle(SALOME_InteractiveObject)& theIO); bool IsRemovableSelected(const SalomeApp_Module* theModule); @@ -110,6 +112,8 @@ namespace VISU { void ChangeRepresentation (const SalomeApp_Module* theModule, VISU::PresentationType theType); + void SetShading ( const SalomeApp_Module* theModule, bool theOn = true ); + // SObject type bool CheckTimeStamp(const SalomeApp_Module* theModule, _PTR(SObject)& theSObject, @@ -176,6 +180,12 @@ namespace VISU { void CreatePlot( SalomeApp_Module* theModule, _PTR(SObject) theSobj ); + void UpdateCurve( VISU::Curve_i*, + Plot2d_ViewFrame* frame, + SPlot2d_Curve*, + int theDisplaying ); + //parameter frame may be 0, in this case there is only update without display/erase + // Others void CreateMesh (const SalomeApp_Module* theModule, const Handle(SALOME_InteractiveObject)& theIO); diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index df191e3e..b9705365 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -45,7 +45,7 @@ #include "SalomeApp_Study.h" #include "SalomeApp_Application.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_SelectionMgr.h" #include "SALOME_Event.hxx" #include "SALOME_ListIO.hxx" @@ -502,7 +502,7 @@ namespace VISU { SALOMEDS::SObject_var aSObject = myPrs->GetSObject(); CORBA::String_var anEntry = aSObject->GetID(); - SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); + LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); SALOME_ListIO aListIO, aNewListIO; aSelectionMgr->selectedObjects(aListIO); @@ -580,7 +580,7 @@ namespace VISU { SALOMEDS::SObject_var aSObject = thePrs->GetSObject(); CORBA::String_var anEntry = aSObject->GetID(); - SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); + LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); SALOME_ListIO aListIO, aNewListIO; aSelectionMgr->selectedObjects(aListIO); @@ -656,7 +656,7 @@ namespace VISU { SALOMEDS::SObject_var aSObject = thePrs->GetSObject(); CORBA::String_var anEntry = aSObject->GetID(); - SalomeApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); + LightApp_SelectionMgr* aSelectionMgr = anApp->selectionMgr(); SALOME_ListIO aListIO, aNewListIO; aSelectionMgr->selectedObjects(aListIO);