1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "ViewerTools_CubeAxesDlgBase.h"
25 #include "ViewerTools_FontWidgetBase.h"
27 #include "QtxAction.h"
28 #include "QtxIntSpinBox.h"
30 #include <QHBoxLayout>
31 #include <QVBoxLayout>
32 #include <QPushButton>
40 * Class : ViewerTools_AxisWidgetBase
41 * Description : Axis tab widget of the "Graduated axis" dialog box
47 ViewerTools_AxisWidgetBase::ViewerTools_AxisWidgetBase (QWidget* theParent)
55 ViewerTools_AxisWidgetBase::~ViewerTools_AxisWidgetBase()
62 void ViewerTools_AxisWidgetBase::initialize()
64 QList< QLabel* > aLabels;
68 myNameGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("AXIS_NAME"), this);
69 myNameGrp->setCheckable( true );
71 QVBoxLayout* aVBox = new QVBoxLayout;
73 QHBoxLayout* aHBox = new QHBoxLayout;
75 QLabel* aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("NAME"));
76 aHBox->addWidget(aLabel);
77 myAxisName = new QLineEdit;
78 aHBox->addWidget(myAxisName);
79 aLabels.append(aLabel);
80 aVBox->addLayout(aHBox);
82 aHBox = new QHBoxLayout;
84 aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("FONT"));
85 aHBox->addWidget(aLabel);
86 myNameFont = createFontWidget(myNameGrp);
87 aHBox->addWidget(myNameFont);
88 aLabels.append(aLabel);
89 aVBox->addLayout(aHBox);
91 myNameGrp->setLayout(aVBox);
95 myLabelsGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("LABELS"), this);
96 myLabelsGrp->setCheckable( true );
98 aVBox = new QVBoxLayout;
100 aHBox = new QHBoxLayout;
101 aHBox->setSpacing(5);
102 aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("NUMBER"));
103 aHBox->addWidget(aLabel);
104 myLabelNumber = new QtxIntSpinBox(2,25,1,myLabelsGrp);
105 aHBox->addWidget(myLabelNumber);
106 aLabels.append(aLabel);
107 aVBox->addLayout(aHBox);
109 aHBox = new QHBoxLayout;
110 aHBox->setSpacing(5);
111 aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("OFFSET"));
112 aHBox->addWidget(aLabel);
113 myLabelOffset = new QtxIntSpinBox(0,100,1,myLabelsGrp);
114 aHBox->addWidget(myLabelOffset);
115 aLabels.append(aLabel);
116 aVBox->addLayout(aHBox);
118 aHBox = new QHBoxLayout;
119 aHBox->setSpacing(5);
120 aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("FONT"));
121 aHBox->addWidget(aLabel);
122 myLabelsFont = createFontWidget(myLabelsGrp);
123 aHBox->addWidget(myLabelsFont);
124 aLabels.append(aLabel);
125 aVBox->addLayout(aHBox);
127 myLabelsGrp->setLayout(aVBox);
131 myTicksGrp = new QGroupBox(ViewerTools_CubeAxesDlgBase::tr("TICK_MARKS"), this);
132 myTicksGrp->setCheckable( true );
134 aVBox = new QVBoxLayout;
136 aHBox = new QHBoxLayout;
137 aHBox->setSpacing(5);
138 aLabel = new QLabel(ViewerTools_CubeAxesDlgBase::tr("LENGTH"));
139 aHBox->addWidget(aLabel);
140 myTickLength = new QtxIntSpinBox(0,100,1,myTicksGrp);
141 aHBox->addWidget(myTickLength);
142 aLabels.append(aLabel);
143 aVBox->addLayout(aHBox);
145 myTicksGrp->setLayout(aVBox);
149 QVBoxLayout* aLay = new QVBoxLayout(this);
152 aLay->addWidget(myNameGrp);
153 aLay->addWidget(myLabelsGrp);
154 aLay->addWidget(myTicksGrp);
157 myNameGrp->setChecked( true );
158 myLabelsGrp->setChecked( true );
159 myTicksGrp->setChecked( true );
161 // Adjust label widths
162 QList< QLabel* >::iterator anIter;
164 for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++)
165 aMaxWidth = qMax(aMaxWidth, (*anIter)->sizeHint().width());
166 for (anIter = aLabels.begin(); anIter != aLabels.end(); anIter++)
167 (*anIter)->setFixedWidth(aMaxWidth);
170 void ViewerTools_AxisWidgetBase::UseName(const bool toUse)
172 myNameGrp->setChecked(toUse);
175 void ViewerTools_AxisWidgetBase::SetName(const QString& theName)
177 myAxisName->setText(theName);
180 void ViewerTools_AxisWidgetBase::SetNameFont(const QColor& theColor,
182 const bool theIsBold,
183 const bool theIsItalic,
184 const bool theIsShadow)
186 myNameFont->SetData(theColor, theFont, theIsBold, theIsItalic, theIsShadow);
190 Class : ViewerTools_CubeAxesDlgBase
191 Description : Dialog for specifying cube axes properties
197 ViewerTools_CubeAxesDlgBase::ViewerTools_CubeAxesDlgBase(QtxAction* theAction,
199 const char* theName):
200 ViewerTools_DialogBase(theAction,
204 setWindowTitle(tr("CAPTION"));
210 void ViewerTools_CubeAxesDlgBase::initialize()
212 QVBoxLayout* aLay = new QVBoxLayout(this);
215 aLay->addWidget(createMainFrame(this));
216 aLay->addWidget(createButtonFrame(this));
220 Create frame containing dialog's input fields
222 QWidget* ViewerTools_CubeAxesDlgBase::createMainFrame(QWidget* theParent)
224 QFrame* aFrame = new QFrame(theParent);
226 myTabWg = new QTabWidget(aFrame);
228 myAxes[ 0 ] = createAxisWidget(myTabWg);
229 myAxes[ 1 ] = createAxisWidget(myTabWg);
230 myAxes[ 2 ] = createAxisWidget(myTabWg);
232 myTabWg->addTab(myAxes[ 0 ], tr("X_AXIS"));
233 myTabWg->addTab(myAxes[ 1 ], tr("Y_AXIS"));
234 myTabWg->addTab(myAxes[ 2 ], tr("Z_AXIS"));
236 myIsVisible = new QCheckBox(tr("IS_VISIBLE"), aFrame);
238 QVBoxLayout* aLay = new QVBoxLayout(aFrame);
241 aLay->addWidget(myTabWg);
242 aLay->addWidget(myIsVisible);
248 Create frame containing buttons
250 QWidget* ViewerTools_CubeAxesDlgBase::createButtonFrame(QWidget* theParent)
252 QFrame* aFrame = new QFrame(theParent);
253 aFrame->setFrameStyle(QFrame::Box | QFrame::Sunken);
255 myOkBtn = new QPushButton(tr("BUT_OK"), aFrame);
256 myApplyBtn = new QPushButton(tr("BUT_APPLY"), aFrame);
257 myCloseBtn = new QPushButton(tr("BUT_CLOSE"), aFrame);
259 QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
261 QHBoxLayout* aLay = new QHBoxLayout(aFrame);
265 aLay->addWidget(myOkBtn);
266 aLay->addWidget(myApplyBtn);
267 aLay->addItem(aSpacer);
268 aLay->addWidget(myCloseBtn);
270 connect(myOkBtn, SIGNAL(clicked()), SLOT(onOk()));
271 connect(myApplyBtn, SIGNAL(clicked()), SLOT(onApply()));
272 connect(myCloseBtn, SIGNAL(clicked()), SLOT(onClose()));
280 ViewerTools_CubeAxesDlgBase::~ViewerTools_CubeAxesDlgBase()
285 Update dialog fields, connect signals and slots, show dialog
287 void ViewerTools_CubeAxesDlgBase::Update()
292 Verify validity of entry data
294 bool ViewerTools_CubeAxesDlgBase::isValid() const
300 Verify validity of entry data
302 bool ViewerTools_CubeAxesDlgBase::onApply()
308 SLOT called when "Ok" button pressed.
310 void ViewerTools_CubeAxesDlgBase::onOk()
317 SLOT: called when "Close" button pressed. Close dialog
319 void ViewerTools_CubeAxesDlgBase::onClose()