From: mzn Date: Tue, 26 Jul 2005 10:29:05 +0000 (+0000) Subject: Preferences for VISU module. X-Git-Tag: V3_0_1~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6b23788a4546d5a40a32ed51f4604c7c445fe198;p=modules%2Fvisu.git Preferences for VISU module. --- diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 1be18722..1f32ea26 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -39,6 +39,105 @@ msgstr "Failed to activate MED engine!" msgid "ERR_CANT_BUILD_PRESENTATION" msgstr "The object can't be built" +msgid "VISU_SCALAR_BAR" +msgstr "Scalar Bar" + +msgid "VISU_FONT" +msgstr "Font" + +msgid "VISU_FONT_ARIAL" +msgstr "Arial" + +msgid "VISU_FONT_COURIER" +msgstr "Courier" + +msgid "VISU_FONT_TIMES" +msgstr "Times" + +msgid "VISU_TITLE" +msgstr "Title" + +msgid "VISU_LABELS" +msgstr "Labels" + +msgid "VISU_COLORS_AND_LABELS" +msgstr "Colors && Labels" + +msgid "VISU_NB_COLORS" +msgstr "Nb. of colors" + +msgid "VISU_NB_LABELS" +msgstr "Nb. of labels" + +msgid "VISU_ORIENTATION" +msgstr "Orientation" + +msgid "VISU_VERTICAL" +msgstr "Vertical" + +msgid "VISU_HORIZONTAL" +msgstr "Horizontal" + +msgid "VISU_ORIGIN_AND_SIZE" +msgstr "Origin && Size" + +msgid "VISU_X" +msgstr "X:" + +msgid "VISU_Y" +msgstr "Y:" + +msgid "VISU_WIDTH" +msgstr "Width:" + +msgid "VISU_HEIGHT" +msgstr "Height:" + +msgid "VISU_SCALAR_RANGE" +msgstr "Scalar range" + +msgid "VISU_SCALAR_MODE" +msgstr "Scalar mode" + +msgid "VISU_MODULUS" +msgstr "Modulus" + +msgid "VISU_COMPONENT" +msgstr "Component" + +msgid "VISU_LOGARITHMIC_SCALING" +msgstr "Logarithmic scaling" + +msgid "VISU_RANGE_TO_USE" +msgstr "Range to use" + +msgid "VISU_FIELD_RANGE" +msgstr "Field range" + +msgid "VISU_IMPOSED_RANGE" +msgstr "Imposed range" + +msgid "VISU_MINMAX_IMPOSED_RANGE" +msgstr "Min and max for imposed range" + +msgid "VISU_MIN" +msgstr "Min:" + +msgid "VISU_MAX" +msgstr "Max:" + +msgid "VISU_SWEEPING_PREF" +msgstr "Sweeping preferences" + +msgid "VISU_TIME_STEP" +msgstr "Time step(second)" + +msgid "VISU_NB_CYCLES" +msgstr "Number of cycles" + +msgid "VISU_NB_STEPS" +msgstr "Number of steps" + #: VisuGUI.cxx msgid "VisuGUI::MEN_IMPORT_FROM_FILE" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index a99dee77..08615023 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -73,6 +73,7 @@ #include "SalomeApp_Study.h" #include "SalomeApp_SelectionMgr.h" #include "SalomeApp_Selection.h" +#include "SalomeApp_Preferences.h" #include "VISUConfig.hh" #include "VISU_Gen_i.hh" @@ -174,7 +175,7 @@ OnImportFromFile() application()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); VISU::Result_var aResult; - bool anIsBuild = aResourceMgr->booleanValue("Visu:BuildResult",false); + bool anIsBuild = aResourceMgr->booleanValue("VISU", "full_med_loading", false); if(VisuGUI_FileDlg::IsBuild){ aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath()); if(!CORBA::is_nil(aResult.in())) @@ -188,9 +189,9 @@ OnImportFromFile() aRes->BuildAll(); } }else{ - aResourceMgr->setValue("Visu:BuildResult",false); + aResourceMgr->setValue("VISU", "full_med_loading", false); aResult = GetVisuGen(this)->ImportFile(aFileInfo.filePath()); - aResourceMgr->setValue("Visu:BuildResult",anIsBuild); + aResourceMgr->setValue("VISU", "full_med_loading", anIsBuild); } if(CORBA::is_nil(aResult.in())) { @@ -1526,11 +1527,11 @@ OnSweep() // Get sweep parameters SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); - double aTempoDbl = aResourceMgr->doubleValue("Visu:SweepTempo", 0.1); + double aTempoDbl = aResourceMgr->doubleValue("VISU", "sweeping_time_step", 0.1); int aTemp = int(1.E6 * aTempoDbl); - int aCycles = aResourceMgr->integerValue("Visu:SweepCycles", 1); - int aSteps = aResourceMgr->integerValue("Visu:SweepSteps", 40); + int aCycles = aResourceMgr->integerValue("VISU", "sweeping_number_cycles", 1); + int aSteps = aResourceMgr->integerValue("VISU", "sweeping_time_step", 40); // Sweep QApplication::setOverrideCursor(Qt::waitCursor); @@ -2663,3 +2664,141 @@ extern "C" { return new VisuGUI(); } } + +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" ); + + QStringList fam; + fam.append( tr( "VISU_FONT_ARIAL" ) ); + fam.append( tr( "VISU_FONT_COURIER" ) ); + fam.append( tr( "VISU_FONT_TIMES" ) ); + int wflag = ( QtxListResourceEdit::FontItem::All & ( ~( QtxListResourceEdit::FontItem::Size | QtxListResourceEdit::FontItem::UserSize ) ) ); + + setPreferenceProperty( tfont, "families", fam ); + setPreferenceProperty( tfont, "system", false ); + setPreferenceProperty( tfont, "widget_flags", wflag ); + setPreferenceProperty( lfont, "families", fam ); + setPreferenceProperty( lfont, "system", false ); + setPreferenceProperty( lfont, "widget_flags", wflag ); + + 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" ); + setPreferenceProperty( numcol, "min", 2 ); + setPreferenceProperty( numcol, "max", 64 ); + + int numlab = addPreference( tr( "VISU_NB_LABELS" ), colorsLabelsGr, SalomeApp_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" ); + QStringList orients; + orients.append( tr( "VISU_VERTICAL" ) ); + orients.append( tr( "VISU_HORIZONTAL" ) ); + QValueList indices; + indices.append( 0 ); + indices.append( 1 ); + setPreferenceProperty( orient, "strings", orients ); + 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" ); + setPreferenceProperty( xv, "step", 0.1 ); + setPreferenceProperty( yv, "step", 0.1 ); + setPreferenceProperty( wv, "step", 0.1 ); + setPreferenceProperty( hv, "step", 0.1 ); + setPreferenceProperty( xv, "min", 0.0 ); + setPreferenceProperty( yv, "min", 0.0 ); + setPreferenceProperty( wv, "min", 0.0 ); + setPreferenceProperty( hv, "min", 0.0 ); + setPreferenceProperty( xv, "max", 1.0 ); + setPreferenceProperty( yv, "max", 1.0 ); + setPreferenceProperty( wv, "max", 1.0 ); + 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" ); + setPreferenceProperty( xh, "step", 0.1 ); + setPreferenceProperty( yh, "step", 0.1 ); + setPreferenceProperty( wh, "step", 0.1 ); + setPreferenceProperty( hh, "step", 0.1 ); + setPreferenceProperty( xh, "min", 0.0 ); + setPreferenceProperty( yh, "min", 0.0 ); + setPreferenceProperty( wh, "min", 0.0 ); + setPreferenceProperty( hh, "min", 0.0 ); + setPreferenceProperty( xh, "max", 1.0 ); + setPreferenceProperty( yh, "max", 1.0 ); + setPreferenceProperty( wh, "max", 1.0 ); + setPreferenceProperty( hh, "max", 1.0 ); + + int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) ); + + 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" ); + QStringList modes; + modes.append( tr( "VISU_MODULUS" ) ); + modes.append( tr( "VISU_COMPONENT" ) + tr("1") ); + modes.append( tr( "VISU_COMPONENT" ) + tr("2") ); + modes.append( tr( "VISU_COMPONENT" ) + tr("3") ); + indices.clear(); + indices.append( 0 ); + indices.append( 1 ); + indices.append( 2 ); + indices.append( 3 ); + setPreferenceProperty( mode, "strings", modes ); + setPreferenceProperty( mode, "indexes", indices ); + + addPreference( tr( "VISU_LOGARITHMIC_SCALING" ), rangeGr, SalomeApp_Preferences::Bool, "VISU", "scalar_bar_logarithmic" ); + + int rangetype = addPreference( tr( "VISU_RANGE_TO_USE" ), rangeGr, SalomeApp_Preferences::Selector, "VISU", "scalar_range_type" ); + QStringList types; + types.append( tr( "VISU_FIELD_RANGE" ) ); + types.append( tr( "VISU_IMPOSED_RANGE" ) ); + indices.clear(); + indices.append( 0 ); + indices.append( 1 ); + setPreferenceProperty( rangetype, "strings", types ); + setPreferenceProperty( rangetype, "indexes", indices ); + + 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" ); + 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" ); + setPreferenceProperty( timestep, "min", 0.1 ); + setPreferenceProperty( timestep, "step", 0.1 ); + setPreferenceProperty( timestep, "max", 1000 ); + setPreferenceProperty( nbcycles, "max", 100 ); + 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" ); +} + +void VisuGUI::preferencesChanged( const QString&, const QString& ) +{ +} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index d43f4360..3735c340 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -50,6 +50,9 @@ public: virtual void contextMenuPopup( const QString& theClient, QPopupMenu* theMenu, QString& theTitle ); + virtual void createPreferences(); + virtual void preferencesChanged( const QString&, const QString& ); + public slots: virtual bool deactivateModule( SUIT_Study* ); virtual bool activateModule( SUIT_Study* ); diff --git a/src/VISUGUI/VisuGUI_ClippingDlg.cxx b/src/VISUGUI/VisuGUI_ClippingDlg.cxx index 02cdbb9a..f5891a70 100644 --- a/src/VISUGUI/VisuGUI_ClippingDlg.cxx +++ b/src/VISUGUI/VisuGUI_ClippingDlg.cxx @@ -161,18 +161,23 @@ protected: vtkProperty* aProp = vtkProperty::New(); float anRGB[3]; - anRGB[0] = VISU::GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = VISU::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = VISU::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + QColor aFillColor = aResourceMgr->colorValue("SMESH", "fill_color", QColor(0, 170, 255)); + anRGB[0] = aFillColor.red()/255.; + anRGB[1] = aFillColor.green()/255.; + anRGB[2] = aFillColor.blue()/255.; aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aProp->SetOpacity(0.75); myActor->SetProperty(aProp); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = VISU::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = VISU::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = VISU::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + QColor aBackFaceColor = aResourceMgr->colorValue("SMESH", "backface_color", QColor(0, 0, 255));//@ + anRGB[0] = aBackFaceColor.red()/255.; + anRGB[1] = aBackFaceColor.green()/255.; + anRGB[2] = aBackFaceColor.blue()/255.; aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aBackProp->SetOpacity(0.75); myActor->SetBackfaceProperty(aBackProp); diff --git a/src/VISUGUI/VisuGUI_FileDlg.cxx b/src/VISUGUI/VisuGUI_FileDlg.cxx index 30ccc07e..1e788c46 100644 --- a/src/VISUGUI/VisuGUI_FileDlg.cxx +++ b/src/VISUGUI/VisuGUI_FileDlg.cxx @@ -39,8 +39,8 @@ VisuGUI_FileDlg::VisuGUI_FileDlg (QWidget* parent, QPushButton* pb = new QPushButton(this); pb->setMaximumWidth(0); addWidgets( label, myCBuildAll, pb ); - QString aIsBuild = VISU::GetResourceMgr()->stringValue("Visu:BuildResult"); - if (aIsBuild.isEmpty()? 0 : aIsBuild.toInt()) myCBuildAll->setChecked(true); + bool toBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false); + if (toBuildAll) myCBuildAll->setChecked(true); } /*! diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 5ad002e1..6a24502f 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -250,7 +250,7 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref): * Initializes dialog box values from resources */ void VisuGUI_ScalarBarPane::initFromResources() { - int sbCol=64,sbLab=5,orient=1; + int sbCol=64,sbLab=5,orient=0; float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8; float sbVmin=0., sbVmax=0.; bool sbRange=false; @@ -258,36 +258,40 @@ void VisuGUI_ScalarBarPane::initFromResources() { SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - orient = aResourceMgr->integerValue("Visu:SBOrientation",orient); - if(orient != 1){ - orient=0; + int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0); + myModeCombo->setCurrentItem(aScalarMode); + + orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient); + if(orient != 0){ + orient=1; sbX1=0.2; sbY1=0.01; sbW=0.6; sbH=0.12; } - - sbX1 = aResourceMgr->doubleValue("Visu:SBXorigin",sbX1); - sbY1 = aResourceMgr->doubleValue("Visu:SBYorigin",sbY1); - - sbW = aResourceMgr->doubleValue("Visu:SBWidth",sbW); - sbH = aResourceMgr->doubleValue("Visu:SBHeight",sbH); - - sbCol = aResourceMgr->integerValue("Visu:SBNumberOfColors",sbCol); - sbLab = aResourceMgr->integerValue("Visu:SBNumberOfLabels",sbLab); - sbRange = aResourceMgr->booleanValue("Visu:SBImposeRange",sbRange); - sbVmin = aResourceMgr->doubleValue("Visu:SBMinimumValue",sbVmin); - sbVmax = aResourceMgr->doubleValue("Visu:SBMaximumValue",sbVmax); - - QString aScaling = aResourceMgr->stringValue("Visu:SBMaximumValue","LINEAR"); - if(aScaling.compare("LOGARITHMIC") == 0) - setLogarithmic(true); - else - setLogarithmic(false); - + + QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" ); + + sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1); + sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1); + + sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW); + sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH); + + sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol); + sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab); + + int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); + if (rangeType == 1) sbRange = true; + sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin); + sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax); + + bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false); + setLogarithmic(isLog); + if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { - if(orient == 1) { + if(orient == 0) { sbX1=0.01; sbY1=0.1; sbW=0.1; @@ -310,85 +314,63 @@ void VisuGUI_ScalarBarPane::initFromResources() { } setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange ); - setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 1); + setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0); setScalarBarData( sbCol, sbLab ); // "Title" - aString = aResourceMgr->stringValue("Visu:IsBoldTitle","true"); - bool isBold = (aString.compare("true") == 0); - aString = aResourceMgr->stringValue("Visu:IsItalicTitle","true"); - bool isItalic = (aString.compare("true") == 0); - aString = aResourceMgr->stringValue("Visu:IsShadowTitle","true"); - bool isShadow = (aString.compare("true") == 0); - - int aFontType = aResourceMgr->integerValue("Visu:TitFontType",0); + bool isBold = false, isItalic = false, isShadow = false; int aFontFamily = VTK_ARIAL; - switch (aFontType) { - case 0: - aFontFamily = VTK_ARIAL; break; - case 1: - aFontFamily = VTK_COURIER; break; - case 2: - aFontFamily = VTK_TIMES; break; - } - - float R = aResourceMgr->doubleValue("Visu:TitleColorR",1.0); - if (R > 1) R = 1; - if (R < 0) R = 0; - - float G = aResourceMgr->doubleValue("Visu:TitleColorG",1.0); - if (G > 1) G = 1; - if (G < 0) G = 0; - float B = aResourceMgr->doubleValue("Visu:TitleColorB",1.0); - if (B > 1) B = 1; - if (B < 0) B = 0; - - myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), - aFontFamily, - isBold, isItalic, isShadow); + if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) ) + { + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" ); + + if ( f.family() == "Arial" ) + aFontFamily = VTK_ARIAL; + else if ( f.family() == "Courier" ) + aFontFamily = VTK_COURIER; + else if ( f.family() == "Times" ) + aFontFamily = VTK_TIMES; + + isBold = f.bold(); + isItalic = f.italic(); + isShadow = f.underline(); + } + + QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); + + myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow); // "Labels" - aString = aResourceMgr->stringValue("Visu:IsBoldLabel","true"); - isBold = (aString.compare("true") == 0); - aString = aResourceMgr->stringValue("Visu:IsItalicLabel","true"); - isItalic = (aString.compare("true") == 0); - aString = aResourceMgr->stringValue("Visu:IsShadowLabel","true"); - isShadow = (aString.compare("true") == 0); - - aFontType = aResourceMgr->integerValue("Visu:LblFontType",0); + isBold = isItalic = isShadow = false; aFontFamily = VTK_ARIAL; - switch (aFontType) { - case 0: - aFontFamily = VTK_ARIAL; break; - case 1: - aFontFamily = VTK_COURIER; break; - case 2: - aFontFamily = VTK_TIMES; break; - } - - R = aResourceMgr->doubleValue("Visu:LabelColorR",1.0); - if (R > 1) R = 1; - if (R < 0) R = 0; - - G = aResourceMgr->doubleValue("Visu:LabelColorG",1.0); - if (G > 1) G = 1; - if (G < 0) G = 0; - B = aResourceMgr->doubleValue("Visu:LabelColorB",1.0); - if (B > 1) B = 1; - if (B < 0) B = 0; - - myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), - aFontFamily, - isBold, isItalic, isShadow); + if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) ) + { + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" ); + + if ( f.family() == "Arial" ) + aFontFamily = VTK_ARIAL; + else if ( f.family() == "Courier" ) + aFontFamily = VTK_COURIER; + else if ( f.family() == "Times" ) + aFontFamily = VTK_TIMES; + + isBold = f.bold(); + isItalic = f.italic(); + isShadow = f.underline(); + } + + aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); + + myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow); } /** * Stores dialog values to resources */ void VisuGUI_ScalarBarPane::storeToResources() { - int orient = (RBvert->isChecked())? 1 : 0; + int orient = (RBvert->isChecked())? 0 : 1; float sbX1 = XSpin->value(); float sbY1 = YSpin->value(); float sbW = WidthSpin->value(); @@ -397,7 +379,7 @@ void VisuGUI_ScalarBarPane::storeToResources() { int sbLab = LabelSpin->value(); if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { - if(orient == 1) { + if(orient == 0) { sbX1=0.01; sbY1=0.1; sbW=0.17; @@ -421,24 +403,29 @@ void VisuGUI_ScalarBarPane::storeToResources() { SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - aResourceMgr->setValue("Visu:SBOrientation",orient); - aResourceMgr->setValue("Visu:SBXorigin",sbX1); - aResourceMgr->setValue("Visu:SBYorigin",sbY1); - aResourceMgr->setValue("Visu:SBWidth",sbW); - aResourceMgr->setValue("Visu:SBHeight",sbH); - aResourceMgr->setValue("Visu:SBNumberOfColors",sbCol); - aResourceMgr->setValue("Visu:SBNumberOfLabels",sbLab); + aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient); + + QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" ); + + aResourceMgr->setValue("VISU", propertyName + "x", sbX1); + aResourceMgr->setValue("VISU", propertyName + "y", sbY1); + aResourceMgr->setValue("VISU", propertyName + "width", sbW); + aResourceMgr->setValue("VISU", propertyName + "height", sbH); + + aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol); + aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab); + if(sbRange) - aResourceMgr->setValue("Visu:SBImposeRange", "true"); - else - aResourceMgr->setValue("Visu:SBImposeRange", "false"); - aResourceMgr->setValue("Visu:SBMinimumValue",sbVmin); - aResourceMgr->setValue("Visu:SBMaximumValue",sbVmax); - if(isLogarithmic()) - aResourceMgr->setValue("Visu:SBScaling", "LOGARITHMIC"); + { + aResourceMgr->setValue("VISU", "scalar_range_type", 1); + aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin); + aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax); + } else - aResourceMgr->setValue("Visu:SBScaling", "LINEAR"); - + aResourceMgr->setValue("VISU", "scalar_range_type", 0); + + aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic()); + //// if (myIsStoreTextProp) { @@ -452,36 +439,30 @@ void VisuGUI_ScalarBarPane::storeToResources() { myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow); - if (isTitleBold) - aResourceMgr->setValue("Visu:IsBoldTitle","true"); - else - aResourceMgr->setValue("Visu:IsBoldTitle","false"); - - if (isTitleItalic) - aResourceMgr->setValue("Visu:IsItalicTitle","true"); - else - aResourceMgr->setValue("Visu:IsItalicTitle","false"); - - if (isTitleShadow) - aResourceMgr->setValue("Visu:IsShadowTitle","true"); - else - aResourceMgr->setValue("Visu:IsShadowTitle","false"); - + QFont aTitleFont; + + aTitleFont.setBold(isTitleBold); + aTitleFont.setItalic(isTitleItalic); + aTitleFont.setUnderline(isTitleShadow); + + QString titleFontFamily; switch (aTitleFontFamily) { case VTK_ARIAL: - aResourceMgr->setValue("Visu:TitFontType",0); + titleFontFamily = "Arial"; break; case VTK_COURIER: - aResourceMgr->setValue("Visu:TitFontType",1); + titleFontFamily = "Courier"; break; case VTK_TIMES: - aResourceMgr->setValue("Visu:TitFontType",2); + titleFontFamily = "Times"; break; } - aResourceMgr->setValue("Visu:TitleColorR", aTitleColor.red()/255.); - aResourceMgr->setValue("Visu:TitleColorG", aTitleColor.green()/255.); - aResourceMgr->setValue("Visu:TitleColorB", aTitleColor.blue()/255.); - + aTitleFont.setFamily(titleFontFamily); + + aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont); + + aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor); + // "Label" QColor aLabelColor (255, 255, 255); int aLabelFontFamily = VTK_ARIAL; @@ -489,38 +470,34 @@ void VisuGUI_ScalarBarPane::storeToResources() { bool isLabelItalic = false; bool isLabelShadow = false; - myTextDlg->myTitleFont->GetData(aLabelColor, aLabelFontFamily, + myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily, isLabelBold, isLabelItalic, isLabelShadow); - if (isLabelBold) - aResourceMgr->setValue("Visu:IsBoldLabel","true"); - else - aResourceMgr->setValue("Visu:IsBoldLabel","false"); - - if (isLabelItalic) - aResourceMgr->setValue("Visu:IsItalicLabel","true"); - else - aResourceMgr->setValue("Visu:IsItalicLabel","false"); - if (isLabelShadow) - aResourceMgr->setValue("Visu:IsShadowLabel","true"); - else - aResourceMgr->setValue("Visu:IsShadowLabel","false"); + QFont aLabelFont; + + aLabelFont.setBold(isLabelBold); + aLabelFont.setItalic(isLabelItalic); + aLabelFont.setUnderline(isLabelShadow); + QString labelFontFamily; switch (aLabelFontFamily) { case VTK_ARIAL: - aResourceMgr->setValue("Visu:LblFontType",0); + labelFontFamily = "Arial"; break; case VTK_COURIER: - aResourceMgr->setValue("Visu:LblFontType",1); + labelFontFamily = "Courier"; break; case VTK_TIMES: - aResourceMgr->setValue("Visu:LblFontType",2); + labelFontFamily = "Times"; break; } - aResourceMgr->setValue("Visu:LabelColorR", aLabelColor.red()/255.); - aResourceMgr->setValue("Visu:LabelColorG", aLabelColor.green()/255.); - aResourceMgr->setValue("Visu:LabelColorB", aLabelColor.blue()/255.); + + aLabelFont.setFamily(labelFontFamily); + + aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont); + + aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor); } } diff --git a/src/VISU_I/VISU_Result_i.cc b/src/VISU_I/VISU_Result_i.cc index 29fbda35..742539ff 100644 --- a/src/VISU_I/VISU_Result_i.cc +++ b/src/VISU_I/VISU_Result_i.cc @@ -433,8 +433,7 @@ Build(SALOMEDS::SObject_ptr theSObject) } } } - QString aIsBuild = VISU::GetResourceMgr()->stringValue("Visu:BuildResult"); - bool isBuildAll = aIsBuild.isEmpty()? 0 : aIsBuild.toInt(); + bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false); if(isBuildAll) BuildAll(); }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<SetValue(aComment.latin1()); } - QString aIsBuild = VISU::GetResourceMgr()->stringValue("Visu:BuildResult"); - if(aIsBuild.isEmpty()? 0 : aIsBuild.toInt()) - BuildAll(); + bool isBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false); + if(isBuildAll) BuildAll(); return this; }catch(std::exception& exc){ INFOS("Follow exception was occured :\n"<integerValue("VISU", "scalar_bar_mode", 0); + SetScalarMode(aScalarMode); + // Orientation - QString aOrient = VISU::GetResourceMgr()->stringValue("Visu:SBOrientation"); - if ( !aOrient.isEmpty() ) - myOrientation = (VISU::ScalarMap::Orientation) aOrient.toInt(); + int orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", 0); + if (orient == 1) + myOrientation = VISU::ScalarMap::HORIZONTAL; else myOrientation = VISU::ScalarMap::VERTICAL; // Scalar Bar origin - QString aXorigin = VISU::GetResourceMgr()->stringValue("Visu:SBXorigin"); - if ( !aXorigin.isEmpty() ) - myPosition[0] = aXorigin.toFloat(); - else { - if(myOrientation == VISU::ScalarMap::VERTICAL) { - myPosition[0] = 0.03; - } else { - myPosition[0] = 0.2; - } - } - - QString aYorigin = VISU::GetResourceMgr()->stringValue("Visu:SBYorigin"); - if ( !aYorigin.isEmpty() ) - myPosition[1] = aYorigin.toFloat(); - else { - if(myOrientation == VISU::ScalarMap::VERTICAL) { - myPosition[1] = 0.1; - } else { - myPosition[1] = 0.012; - } - } - + QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" ); + + float aXorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.01 : 0.2; + aXorigin = aResourceMgr->doubleValue("VISU", propertyName + "x", aXorigin); + myPosition[0] = aXorigin; + + float aYorigin = (myOrientation == VISU::ScalarMap::VERTICAL) ? 0.1 : 0.012; + aYorigin = aResourceMgr->doubleValue("VISU", propertyName + "y", aYorigin); + myPosition[1] = aYorigin; + // Scalar Bar size - QString aWidth = VISU::GetResourceMgr()->stringValue("Visu:SBWidth"); - if ( !aWidth.isEmpty() ) - myWidth = aWidth.toFloat(); - else { - myWidth =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.17:0.6; - } - QString aHeight = VISU::GetResourceMgr()->stringValue("Visu:SBHeight"); - if ( !aHeight.isEmpty() ) - myHeight = aHeight.toFloat(); - else { - myHeight =(myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12; - } + myWidth = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.1 : 0.6; + myWidth = aResourceMgr->doubleValue("VISU", propertyName + "width", myWidth); + + myHeight = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12; + myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight); // Nb of Colors - QString aColors = VISU::GetResourceMgr()->stringValue("Visu:SBNumberOfColors"); - int aNumberOfColors = (aColors.isEmpty())? 64 : aColors.toInt(); - if (aNumberOfColors > 64) - aNumberOfColors = 64; + int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 ); SetNbColors(aNumberOfColors); // Nb of Labels - QString aLabels = VISU::GetResourceMgr()->stringValue("Visu:SBNumberOfLabels"); - myNumberOfLabels = (aLabels.isEmpty())? 5 : aLabels.toInt(); - if (myNumberOfLabels > 65) - myNumberOfLabels = 65; - + myNumberOfLabels = aResourceMgr->integerValue( "VISU", "scalar_bar_num_labels", 5 ); + // Scalar Range - QString aFixRange = VISU::GetResourceMgr()->stringValue("Visu:SBImposeRange"); - myIsFixedRange = (aFixRange.compare("true") == 0); - - if(myIsFixedRange){ - QString aRangeMin = VISU::GetResourceMgr()->stringValue("Visu:SBMinimumValue"); - float aMin = (aRangeMin.isEmpty())? 0 : aRangeMin.toFloat(); - QString aRangeMax = VISU::GetResourceMgr()->stringValue("Visu:SBMaximumValue"); - float aMax = (aRangeMax.isEmpty())? 0 : aRangeMax.toFloat(); - SetRange(aMin,aMax); - } - - QString aScaling = VISU::GetResourceMgr()->stringValue("Visu:SBScaling"); - if(aScaling.compare("LOGARITHMIC") == 0) + int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); + myIsFixedRange = (rangeType == 1) ? true : false; + + if (myIsFixedRange) + { + float aMin = aResourceMgr->doubleValue("VISU", "scalar_range_min", 0); + float aMax = aResourceMgr->doubleValue("VISU", "scalar_range_max", 0); + SetRange(aMin,aMax); + } + + bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false); + + if( isLog ) SetScaling(VISU::LOGARITHMIC); else SetScaling(VISU::LINEAR); // Fonts properties definition - QString aIsBoldTitle = VISU::GetResourceMgr()->stringValue("Visu:IsBoldTitle"); - myIsBoldTitle = (aIsBoldTitle.isEmpty())? true : (aIsBoldTitle.compare("true") == 0); - - QString aIsItalicTitle = VISU::GetResourceMgr()->stringValue("Visu:IsItalicTitle"); - myIsItalicTitle = (aIsItalicTitle.isEmpty())? true : (aIsItalicTitle.compare("true") == 0); - - QString aIsShadowTitle = VISU::GetResourceMgr()->stringValue("Visu:IsShadowTitle"); - myIsShadowTitle = (aIsShadowTitle.isEmpty())? true : (aIsShadowTitle.compare("true") == 0); - - QString aTitFontType = VISU::GetResourceMgr()->stringValue("Visu:TitFontType"); - if (!aTitFontType.isEmpty()) { - switch (aTitFontType.toInt()) { - case 0: myTitFontType = VTK_ARIAL; break; - case 1: myTitFontType = VTK_COURIER; break; - case 2: myTitFontType = VTK_TIMES; break; + myIsBoldTitle = myIsItalicTitle = myIsShadowTitle = true; + myTitFontType = VTK_ARIAL; + + if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) ) + { + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" ); + + if ( f.family() == "Arial" ) + myTitFontType = VTK_ARIAL; + else if ( f.family() == "Courier" ) + myTitFontType = VTK_COURIER; + else if ( f.family() == "Times" ) + myTitFontType = VTK_TIMES; + + myIsBoldTitle = f.bold(); + myIsItalicTitle = f.italic(); + myIsShadowTitle = f.underline(); } - } else { - myTitFontType = VTK_ARIAL; - } - QString aRTitColor = VISU::GetResourceMgr()->stringValue("Visu:TitleColorR"); - myTitleColor[0] = (aRTitColor.isEmpty())? 1 : aRTitColor.toFloat(); - if (myTitleColor[0] > 1) myTitleColor[0] = 1; - if (myTitleColor[0] < 0) myTitleColor[0] = 0; - - QString aGTitColor = VISU::GetResourceMgr()->stringValue("Visu:TitleColorG"); - myTitleColor[1] = (aGTitColor.isEmpty())? 1 : aGTitColor.toFloat(); - if (myTitleColor[1] > 1) myTitleColor[1] = 1; - if (myTitleColor[1] < 0) myTitleColor[1] = 0; - - QString aBTitColor = VISU::GetResourceMgr()->stringValue("Visu:TitleColorB"); - myTitleColor[2] = (aBTitColor.isEmpty())? 1 : aBTitColor.toFloat(); - if (myTitleColor[2] > 1) myTitleColor[2] = 1; - if (myTitleColor[2] < 0) myTitleColor[2] = 0; - + + QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); + + myTitleColor[0] = aTextColor.red() / 255; + myTitleColor[1] = aTextColor.green() / 255; + myTitleColor[2] = aTextColor.blue() / 255; + /// - QString aIsBoldLabel = VISU::GetResourceMgr()->stringValue("Visu:IsBoldLabel"); - myIsBoldLabel = (aIsBoldLabel.isEmpty())? true : (aIsBoldLabel.compare("true") == 0); - - QString aIsItalicLabel = VISU::GetResourceMgr()->stringValue("Visu:IsItalicLabel"); - myIsItalicLabel = (aIsItalicLabel.isEmpty())? true : (aIsItalicLabel.compare("true") == 0); - - QString aIsShadowLabel = VISU::GetResourceMgr()->stringValue("Visu:IsShadowLabel"); - myIsShadowLabel = (aIsShadowLabel.isEmpty())? true : (aIsShadowLabel.compare("true") == 0); - - QString aLblFontType = VISU::GetResourceMgr()->stringValue("Visu:LblFontType"); - if (!aLblFontType.isEmpty()) { - switch (aLblFontType.toInt()) { - case 0: myLblFontType = VTK_ARIAL; break; - case 1: myLblFontType = VTK_COURIER; break; - case 2: myLblFontType = VTK_TIMES; break; + myIsBoldLabel = myIsItalicLabel = myIsShadowLabel = true; + myLblFontType = VTK_ARIAL; + + if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) ) + { + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" ); + + if ( f.family() == "Arial" ) + myLblFontType = VTK_ARIAL; + else if ( f.family() == "Courier" ) + myLblFontType = VTK_COURIER; + else if ( f.family() == "Times" ) + myLblFontType = VTK_TIMES; + + myIsBoldLabel = f.bold(); + myIsItalicLabel = f.italic(); + myIsShadowLabel = f.underline(); } - } else { - myLblFontType = VTK_ARIAL; - } - QString aRLblColor = VISU::GetResourceMgr()->stringValue("Visu:LabelColorR"); - myLabelColor[0] = (aRLblColor.isEmpty())? 1 : aRLblColor.toFloat(); - if (myLabelColor[0] > 1) myLabelColor[0] = 1; - if (myLabelColor[0] < 0) myLabelColor[0] = 0; - - QString aGLblColor = VISU::GetResourceMgr()->stringValue("Visu:LabelColorG"); - myLabelColor[1] = (aGLblColor.isEmpty())? 1 : aGLblColor.toFloat(); - if (myLabelColor[1] > 1) myLabelColor[1] = 1; - if (myLabelColor[1] < 0) myLabelColor[1] = 0; - - QString aBLblColor = VISU::GetResourceMgr()->stringValue("Visu:LabelColorB"); - myLabelColor[2] = (aBLblColor.isEmpty())? 1 : aBLblColor.toFloat(); - if (myLabelColor[2] > 1) myLabelColor[2] = 1; - if (myLabelColor[2] < 0) myLabelColor[2] = 0; + + QColor aLabelColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); + + myLabelColor[0] = aLabelColor.red() / 255; + myLabelColor[1] = aLabelColor.green() / 255; + myLabelColor[2] = aLabelColor.blue() / 255; myMeshName = theMeshName; diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 0e34ef3f..6710fff5 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -281,8 +281,9 @@ void VISU_TimeAnimation::generatePresentations(CORBA::Long theFieldNum) { i++; } aData.myNbFrames = i; - QString aFixRange = VISU::GetResourceMgr()->stringValue("Visu:SBImposeRange"); - if (aFixRange.compare("true") != 0) { + + int rangeType = VISU::GetResourceMgr()->integerValue("VISU" , "scalar_range_type", 0); + if ( rangeType != 1 ) { for (i = 0; i < aData.myNbFrames; i++) { aData.myPrs[i]->SetRange(aMin, aMax); aData.myPrs[i]->SetOffset(aData.myOffset);