From 87a9f0ca8722973d427657d7ef658d75c368be42 Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 5 Aug 2016 16:35:18 +0300 Subject: [PATCH] 0004007: External 20828 Plot3d setting --- src/SVTK/SVTK_CubeAxesDlg.cxx | 69 ++++++++++++++++++++++++++----- src/SVTK/SVTK_FontWidget.cxx | 28 +++++++++---- src/SVTK/SVTK_FontWidget.h | 6 ++- src/SVTK/resources/SVTK_msg_en.ts | 26 ++++++++++++ 4 files changed, 109 insertions(+), 20 deletions(-) diff --git a/src/SVTK/SVTK_CubeAxesDlg.cxx b/src/SVTK/SVTK_CubeAxesDlg.cxx index bf0eaf83f..967ecec3d 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.cxx +++ b/src/SVTK/SVTK_CubeAxesDlg.cxx @@ -47,6 +47,8 @@ #include #include +#define DEFAULT_FONT_SIZE 16 + /*! \class SVTK_CubeAxesDlg::AxisWidget \brief Axis tab widget of the "Graduated axis" dialog box @@ -61,7 +63,7 @@ public: void UseName( const bool ); void SetName( const QString& ); - void SetNameFont( const QColor&, const int, const bool, const bool, const bool ); + void SetNameFont( const QColor&, const int, const int, const bool, const bool, const bool ); bool ReadData( vtkAxisActor2D* ); bool Apply( vtkAxisActor2D* ); @@ -75,6 +77,7 @@ private: QGroupBox* myLabelsGrp; QtxIntSpinBox* myLabelNumber; QtxIntSpinBox* myLabelOffset; + QLineEdit* myLabelFormat; SVTK_FontWidget* myLabelsFont; // tick marks @@ -100,6 +103,7 @@ SVTK_CubeAxesDlg::AxisWidget::AxisWidget (QWidget* theParent) QVBoxLayout* aVBox = new QVBoxLayout; QHBoxLayout* aHBox = new QHBoxLayout; + aHBox->setMargin(0); aHBox->setSpacing(5); QLabel* aLabel = new QLabel(SVTK_CubeAxesDlg::tr("NAME")); aHBox->addWidget(aLabel); @@ -109,6 +113,7 @@ SVTK_CubeAxesDlg::AxisWidget::AxisWidget (QWidget* theParent) aVBox->addLayout(aHBox); aHBox = new QHBoxLayout; + aHBox->setMargin(0); aHBox->setSpacing(5); aLabel = new QLabel(SVTK_CubeAxesDlg::tr("FONT")); aHBox->addWidget(aLabel); @@ -127,6 +132,7 @@ SVTK_CubeAxesDlg::AxisWidget::AxisWidget (QWidget* theParent) aVBox = new QVBoxLayout; aHBox = new QHBoxLayout; + aHBox->setMargin(0); aHBox->setSpacing(5); aLabel = new QLabel(SVTK_CubeAxesDlg::tr("NUMBER")); aHBox->addWidget(aLabel); @@ -136,6 +142,7 @@ SVTK_CubeAxesDlg::AxisWidget::AxisWidget (QWidget* theParent) aVBox->addLayout(aHBox); aHBox = new QHBoxLayout; + aHBox->setMargin(0); aHBox->setSpacing(5); aLabel = new QLabel(SVTK_CubeAxesDlg::tr("OFFSET")); aHBox->addWidget(aLabel); @@ -145,6 +152,19 @@ SVTK_CubeAxesDlg::AxisWidget::AxisWidget (QWidget* theParent) aVBox->addLayout(aHBox); aHBox = new QHBoxLayout; + aHBox->setMargin(0); + aHBox->setSpacing(5); + aLabel = new QLabel(SVTK_CubeAxesDlg::tr("FORMAT")); + aHBox->addWidget(aLabel); + myLabelFormat = new QLineEdit(myLabelsGrp); + aHBox->addWidget(myLabelFormat); + aLabels.append(aLabel); + aVBox->addLayout(aHBox); + + myLabelFormat->setToolTip( SVTK_CubeAxesDlg::tr("FORMAT_TOOLTIP") ); + + aHBox = new QHBoxLayout; + aHBox->setMargin(0); aHBox->setSpacing(5); aLabel = new QLabel(SVTK_CubeAxesDlg::tr("FONT")); aHBox->addWidget(aLabel); @@ -163,6 +183,7 @@ SVTK_CubeAxesDlg::AxisWidget::AxisWidget (QWidget* theParent) aVBox = new QVBoxLayout; aHBox = new QHBoxLayout; + aHBox->setMargin(0); aHBox->setSpacing(5); aLabel = new QLabel(SVTK_CubeAxesDlg::tr("LENGTH")); aHBox->addWidget(aLabel); @@ -214,12 +235,13 @@ void SVTK_CubeAxesDlg::AxisWidget::SetName(const QString& theName) } void SVTK_CubeAxesDlg::AxisWidget::SetNameFont(const QColor& theColor, - const int theFont, - const bool theIsBold, - const bool theIsItalic, - const bool theIsShadow) + const int theFont, + const int theSize, + const bool theIsBold, + const bool theIsItalic, + const bool theIsShadow) { - myNameFont->SetData(theColor, theFont, theIsBold, theIsItalic, theIsShadow); + myNameFont->SetData(theColor, theFont, theSize, theIsBold, theIsItalic, theIsShadow); } bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) @@ -227,6 +249,14 @@ bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) if (theActor == 0) return false; + // Font sizes of title and labels are calculated on the base of FontFactor and LabelFactor + // (vtkAxisActor2D completely ignores FontSize of the text property). + double aFontFactor = theActor->GetFontFactor(); + double aLabelFactor = theActor->GetLabelFactor(); + + int aTitleFontSize = (int)( DEFAULT_FONT_SIZE * aFontFactor ); + int aLabelsFontSize = (int)( aTitleFontSize * aLabelFactor ); + // Name bool useName = theActor->GetTitleVisibility(); @@ -234,6 +264,7 @@ bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) QColor aTitleColor(255, 255, 255); int aTitleFontFamily = VTK_ARIAL; + //int aTitleFontSize = 12; bool isTitleBold = false; bool isTitleItalic = false; bool isTitleShadow = false; @@ -245,6 +276,7 @@ bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) aTitleProp->GetColor(c); aTitleColor.setRgb((int)(c[ 0 ] * 255), (int)(c[ 1 ] * 255), (int)(c[ 2 ] * 255)); aTitleFontFamily = aTitleProp->GetFontFamily(); + //aTitleFontSize = aTitleProp->GetFontSize(); isTitleBold = aTitleProp->GetBold() ? true : false; isTitleItalic = aTitleProp->GetItalic() ? true : false; isTitleShadow = aTitleProp->GetShadow() ? true : false; @@ -252,16 +284,18 @@ bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) myNameGrp->setChecked(useName); myAxisName->setText(aTitle); - myNameFont->SetData(aTitleColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow); + myNameFont->SetData(aTitleColor, aTitleFontFamily, aTitleFontSize, isTitleBold, isTitleItalic, isTitleShadow); // Labels bool useLabels = theActor->GetLabelVisibility(); int nbLabels = theActor->GetNumberOfLabels(); int anOffset = theActor->GetTickOffset(); + char* aFormat = theActor->GetLabelFormat(); QColor aLabelsColor(255, 255, 255); int aLabelsFontFamily = VTK_ARIAL; + //int aLabelsFontSize = 12; bool isLabelsBold = false; bool isLabelsItalic = false; bool isLabelsShadow = false; @@ -273,6 +307,7 @@ bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) aLabelsProp->GetColor(c); aLabelsColor.setRgb((int)(c[ 0 ] * 255), (int)(c[ 1 ] * 255), (int)(c[ 2 ] * 255)); aLabelsFontFamily = aLabelsProp->GetFontFamily(); + //aLabelsFontSize = aLabelsProp->GetFontSize(); isLabelsBold = aLabelsProp->GetBold() ? true : false; isLabelsItalic = aLabelsProp->GetItalic() ? true : false; isLabelsShadow = aLabelsProp->GetShadow() ? true : false; @@ -281,7 +316,8 @@ bool SVTK_CubeAxesDlg::AxisWidget::ReadData(vtkAxisActor2D* theActor) myLabelsGrp->setChecked(useLabels); myLabelNumber->setValue(nbLabels); myLabelOffset->setValue(anOffset); - myLabelsFont->SetData(aLabelsColor, aLabelsFontFamily, isLabelsBold, isLabelsItalic, isLabelsShadow); + myLabelFormat->setText(aFormat); + myLabelsFont->SetData(aLabelsColor, aLabelsFontFamily, aLabelsFontSize, isLabelsBold, isLabelsItalic, isLabelsShadow); // Tick marks bool useTickMarks = theActor->GetTickVisibility(); @@ -305,11 +341,12 @@ bool SVTK_CubeAxesDlg::AxisWidget::Apply(vtkAxisActor2D* theActor) QColor aTitleColor(255, 255, 255); int aTitleFontFamily = VTK_ARIAL; + int aTitleFontSize = 12; bool isTitleBold = false; bool isTitleItalic = false; bool isTitleShadow = false; - myNameFont->GetData(aTitleColor, aTitleFontFamily, isTitleBold, isTitleItalic, isTitleShadow); + myNameFont->GetData(aTitleColor, aTitleFontFamily, aTitleFontSize, isTitleBold, isTitleItalic, isTitleShadow); vtkTextProperty* aTitleProp = theActor->GetTitleTextProperty(); if (aTitleProp) { @@ -317,14 +354,19 @@ bool SVTK_CubeAxesDlg::AxisWidget::Apply(vtkAxisActor2D* theActor) aTitleColor.green() / 255., aTitleColor.blue() / 255.); aTitleProp->SetFontFamily(aTitleFontFamily); + //aTitleProp->SetFontSize(aTitleFontSize); aTitleProp->SetBold(isTitleBold ? 1 : 0); aTitleProp->SetItalic(isTitleItalic ? 1 : 0); aTitleProp->SetShadow(isTitleShadow ? 1 : 0); + aTitleProp->Modified(); theActor->SetTitleTextProperty(aTitleProp); } + double aFontFactor = (double)aTitleFontSize / (double)DEFAULT_FONT_SIZE; + theActor->SetFontFactor( aFontFactor ); + // Labels theActor->SetLabelVisibility(myLabelsGrp->isChecked() ? 1 : 0); @@ -335,13 +377,17 @@ bool SVTK_CubeAxesDlg::AxisWidget::Apply(vtkAxisActor2D* theActor) int anOffset = myLabelOffset->value(); theActor->SetTickOffset(anOffset); + QString aFormat = myLabelFormat->text(); + theActor->SetLabelFormat( aFormat.toLatin1().constData() ); + QColor aLabelsColor(255, 255, 255); int aLabelsFontFamily = VTK_ARIAL; + int aLabelsFontSize = 12; bool isLabelsBold = false; bool isLabelsItalic = false; bool isLabelsShadow = false; - myLabelsFont->GetData(aLabelsColor, aLabelsFontFamily, isLabelsBold, isLabelsItalic, isLabelsShadow); + myLabelsFont->GetData(aLabelsColor, aLabelsFontFamily, aLabelsFontSize, isLabelsBold, isLabelsItalic, isLabelsShadow); vtkTextProperty* aLabelsProp = theActor->GetLabelTextProperty(); if (aLabelsProp) { @@ -349,6 +395,7 @@ bool SVTK_CubeAxesDlg::AxisWidget::Apply(vtkAxisActor2D* theActor) aLabelsColor.green() / 255., aLabelsColor.blue() / 255.); aLabelsProp->SetFontFamily(aLabelsFontFamily); + //aLabelsProp->SetFontSize(aLabelsFontSize); aLabelsProp->SetBold(isLabelsBold ? 1 : 0); aLabelsProp->SetItalic(isLabelsItalic ? 1 : 0); @@ -358,6 +405,8 @@ bool SVTK_CubeAxesDlg::AxisWidget::Apply(vtkAxisActor2D* theActor) theActor->SetLabelTextProperty(aLabelsProp); } + double aLabelFactor = (double)aLabelsFontSize / (double)aTitleFontSize; + theActor->SetLabelFactor( aLabelFactor ); // Tick marks theActor->SetTickVisibility(myTicksGrp->isChecked()); diff --git a/src/SVTK/SVTK_FontWidget.cxx b/src/SVTK/SVTK_FontWidget.cxx index b32f7ab0c..20c5dd0c3 100644 --- a/src/SVTK/SVTK_FontWidget.cxx +++ b/src/SVTK/SVTK_FontWidget.cxx @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -54,14 +55,19 @@ SVTK_FontWidget::SVTK_FontWidget( QWidget* theParent ) myFamily->insertItem( myFamily->count(), tr( "COURIER" ) ); myFamily->insertItem( myFamily->count(), tr( "TIMES" ) ); + mySize = new QSpinBox( this ); + mySize->setRange( 8, 24 ); + myBold = new QCheckBox( tr( "BOLD" ), this ); myItalic = new QCheckBox( tr( "ITALIC" ), this ); myShadow = new QCheckBox( tr( "SHADOW" ), this ); QHBoxLayout* aHBLayout = new QHBoxLayout; + aHBLayout->setMargin( 0 ); aHBLayout->setSpacing( 5 ); aHBLayout->addWidget(myColorBtn); aHBLayout->addWidget(myFamily); + aHBLayout->addWidget(mySize); aHBLayout->addWidget(myBold); aHBLayout->addWidget(myItalic); aHBLayout->addWidget(myShadow); @@ -97,10 +103,11 @@ void SVTK_FontWidget::onColor() } void SVTK_FontWidget::SetData( const QColor& theColor, - const int theFamily, - const bool theBold, - const bool theItalic, - const bool theShadow ) + const int theFamily, + const int theSize, + const bool theBold, + const bool theItalic, + const bool theShadow ) { SetColor( theColor ); @@ -111,16 +118,19 @@ void SVTK_FontWidget::SetData( const QColor& theColor, else myFamily->setCurrentIndex( 2 ); + mySize->setValue( theSize ); + myBold->setChecked( theBold ); myItalic->setChecked( theItalic ); myShadow->setChecked( theShadow ); } void SVTK_FontWidget::GetData( QColor& theColor, - int& theFamily, - bool& theBold, - bool& theItalic, - bool& theShadow ) const + int& theFamily, + int& theSize, + bool& theBold, + bool& theItalic, + bool& theShadow ) const { theColor = GetColor(); @@ -132,6 +142,8 @@ void SVTK_FontWidget::GetData( QColor& theColor, else theFamily = VTK_TIMES; + theSize = mySize->value(); + theBold = myBold->isChecked(); theItalic = myItalic->isChecked(); theShadow = myShadow->isChecked(); diff --git a/src/SVTK/SVTK_FontWidget.h b/src/SVTK/SVTK_FontWidget.h index 3c10e1a2c..9356268ef 100644 --- a/src/SVTK/SVTK_FontWidget.h +++ b/src/SVTK/SVTK_FontWidget.h @@ -33,6 +33,7 @@ class QToolButton; class QComboBox; +class QSpinBox; class QCheckBox; class QColor; @@ -52,9 +53,9 @@ public: void SetColor( const QColor& ); QColor GetColor() const; - void SetData( const QColor&, const int, const bool, const bool, const bool ); + void SetData( const QColor&, const int, const int, const bool, const bool, const bool ); - void GetData( QColor&, int&, bool&, bool&, bool& ) const; + void GetData( QColor&, int&, int&, bool&, bool&, bool& ) const; private slots: void onColor(); @@ -62,6 +63,7 @@ private slots: private: QToolButton* myColorBtn; QComboBox* myFamily; + QSpinBox* mySize; QCheckBox* myBold; QCheckBox* myItalic; QCheckBox* myShadow; diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index 024d0bc45..26972f242 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -228,6 +228,32 @@ OFFSET Offset + + FORMAT + Format + + + FORMAT_TOOLTIP + Format: %[width][.precision]specifier + +width +Minimum number of characters to be printed. If the value to be printed is shorter than this number, +the result is padded with blank spaces. The value is not truncated even if the result is larger. + +precision +For integer specifier (d): precision specifies the minimum number of digits to be written. +If the value to be written is shorter than this number, the result is padded with leading zeros. +The value is not truncated even if the result is longer. +A precision of 0 means that no character is written for the value 0. +For f and e specifiers: this is the number of digits to be printed after the decimal point (by default, 6). +For g specifier: this is the maximum number of significant digits to be printed. + +specifier +d: Decimal integer (392) +f: Decimal floating point (392.65) +e: Scientific notation (3.9265e+2) +g: Use the shortest representation: %e or %f (392.65) + AXIS_NAME Axis name -- 2.39.2