1 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : VisuGUI_ValuesLabelingDlg.cxx
21 // Author : Litonin SERGEY
24 #include "VisuGUI_ValuesLabelingDlg.h"
28 #include <QHBoxLayout>
30 #include <QPushButton>
31 #include <QtxColorButton.h>
32 #include <QtxFontEdit.h>
33 #include <QVBoxLayout>
36 \class VisuGUI_ValuesLabelingDlg
37 \brief This class is intended for changing parameters of labeling values
38 of 3D colored presentations
43 \param theModule module
45 VisuGUI_ValuesLabelingDlg::VisuGUI_ValuesLabelingDlg( SalomeApp_Module* theModule )
46 : VisuGUI_Prs3dDlg( theModule )
48 setWindowTitle( tr( "PARAMETERS_OF_VALUES_LABELING" ) );
52 QGroupBox* aFGrp = new QGroupBox( tr( "LABELS" ), this );
54 QLabel* aFont = new QLabel( tr( "FONT" ) );
55 QLabel* aColor = new QLabel( tr( "COLOR" ) );
56 myFont = new QtxFontEdit( aFGrp );
57 myColor = new QtxColorButton( aFGrp );
58 myColor->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
60 QGridLayout* aFLay = new QGridLayout( aFGrp );
61 aFLay->setSpacing( 5 );
62 aFLay->setMargin( 5 );
64 aFLay->addWidget( aFont, 0, 0 );
65 aFLay->addWidget( myFont, 0, 1 );
66 aFLay->addWidget( aColor, 1, 0 );
67 aFLay->addWidget( myColor, 1, 1 );
71 QGroupBox* aBtnGrp = new QGroupBox( this );
72 QGridLayout* aBtnLay = new QGridLayout( aBtnGrp );
73 aBtnLay->setAlignment( Qt::AlignTop );
74 aBtnLay->setSpacing( 5 );
75 aBtnLay->setMargin( 5 );
77 QPushButton* anOK = new QPushButton( tr("BUT_OK"), aBtnGrp );
78 anOK->setAutoDefault( true );
79 anOK->setDefault( true );
80 aBtnLay->addWidget( anOK, 0, 0 );
81 aBtnLay->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
83 QPushButton* aCancel = new QPushButton( tr("BUT_CANCEL") , aBtnGrp );
84 aCancel->setAutoDefault( true );
85 aBtnLay->addWidget( aCancel, 0, 2 );
87 QPushButton* aHelp = new QPushButton( tr("BUT_HELP") , aBtnGrp );
88 aHelp->setAutoDefault( true );
89 aBtnLay->addWidget( aHelp, 0, 3 );
91 myFont->setMode( QtxFontEdit::Custom );
92 myFont->setFeatures( QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic |
93 QtxFontEdit::Shadow | QtxFontEdit::UserSize | QtxFontEdit::Size );
95 fam.append( tr( "VISU_FONT_ARIAL" ) );
96 fam.append( tr( "VISU_FONT_COURIER" ) );
97 fam.append( tr( "VISU_FONT_TIMES" ) );
98 myFont->setFonts( fam );
102 QVBoxLayout* aMainLay = new QVBoxLayout( this );
103 aMainLay->setSpacing( 5 );
104 aMainLay->setMargin( 5 );
105 aMainLay->addWidget( aFGrp );
106 aMainLay->addWidget( aBtnGrp );
108 // Connect signals and slots
109 connect( anOK,SIGNAL( clicked() ), SLOT( accept() ) );
110 connect( aCancel, SIGNAL( clicked() ), SLOT( reject() ) );
111 connect( aHelp, SIGNAL( clicked() ), SLOT( onHelp() ) );
113 setFixedSize( minimumSizeHint() );
119 VisuGUI_ValuesLabelingDlg::~VisuGUI_ValuesLabelingDlg()
124 \brief Initializes dialog fields using specified presentation
125 \param thePrs presentation
126 \param theInit not used
127 \sa storeToPrsObject()
129 void VisuGUI_ValuesLabelingDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool )
134 int aFType = thePrs->GetValLblFontType();
136 double aSize = thePrs->GetValLblFontSize();
138 bool isBold = thePrs->IsBoldValLbl();
139 bool isItalic = thePrs->IsItalicValLbl();
140 bool isShadow = thePrs->IsShadowValLbl();
142 vtkFloatingPointType aGRB[ 3 ];
143 thePrs->GetValLblFontColor( aGRB[ 0 ], aGRB[ 1 ], aGRB[ 2 ] );
149 if ( aFType == VTK_ARIAL )
151 else if ( aFType == VTK_COURIER )
153 else if ( aFType == VTK_TIMES )
156 aFont.setFamily( aFamily );
157 aFont.setPointSize( aSize );
158 aFont.setBold( isBold );
159 aFont.setItalic( isItalic );
160 aFont.setOverline( isShadow );
162 myFont->setCurrentFont( aFont );
165 QColor aColor( aGRB[ 0 ] * 255, aGRB[ 1 ] * 255, aGRB[ 2 ] * 255 );
166 myColor->setColor( aColor );
170 \brief Updates presentation in accordance with dialog input data
171 \param thePrs to be updated
172 \sa initFromPrsObject()
174 int VisuGUI_ValuesLabelingDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs )
179 QFont aFont = myFont->currentFont();
182 if ( aFont.family() == "Arial" )
183 thePrs->SetValLblFontType( VTK_ARIAL );
184 else if ( aFont.family() == "Courier" )
185 thePrs->SetValLblFontType( VTK_COURIER );
186 else if ( aFont.family() == "Times" )
187 thePrs->SetValLblFontType( VTK_TIMES );
190 int aSize = aFont.pointSize();
192 thePrs->SetValLblFontSize( aSize );
194 // bold, italic, shadow
195 thePrs->SetBoldValLbl( aFont.bold() );
196 thePrs->SetItalicValLbl( aFont.italic() );
197 thePrs->SetShadowValLbl( aFont.overline() );
200 QColor aColor = myColor->color();
201 thePrs->SetValLblFontColor(
202 aColor.red() / 255., aColor.green() / 255., aColor.blue() / 255. );
208 \brief Gets help file name
210 QString VisuGUI_ValuesLabelingDlg::GetContextHelpFilePath()
212 return "viewing_3d_presentations_page.html#labeling_parameters_anchor";