Salome HOME
Updated copyright comment
[modules/gui.git] / src / SVTK / SVTK_PsOptionsDlg.cxx
1 // Copyright (C) 2007-2024  CEA, EDF, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "SVTK_PsOptionsDlg.h"
21
22 #include <QtxDoubleSpinBox.h>
23
24 #include <QCheckBox>
25 #include <QComboBox>
26 #include <QGroupBox>
27 #include <QLabel>
28 #include <QLayout>
29 #include <QSlider>
30 #include <QPushButton>
31
32 /*!
33  * Constructor
34  */
35 SVTK_PsOptionsDlg::SVTK_PsOptionsDlg( QWidget* theParent):
36   QDialog( theParent )
37 {
38   setWindowTitle( tr( "DLG_PSOPTIONS_TITLE" ) );
39   QVBoxLayout* aTopLayout = new QVBoxLayout( this );
40   aTopLayout->setSpacing( 6 );
41   aTopLayout->setMargin( 6 );
42   
43   // 1. Options
44   QGroupBox* anOptionsBox = new QGroupBox( tr( "PS_OPTIONS" ), this );
45   QGridLayout* anOptionsLayout = new QGridLayout( anOptionsBox );
46   anOptionsLayout->setSpacing( 6 );
47   anOptionsLayout->setMargin( 11 );
48
49   // 1.1 Line width factor
50   QLabel* lineLabel = new QLabel( tr( "PS_LINE_WIDTH" ), anOptionsBox);
51   myLineFactor = new QtxDoubleSpinBox(0.0, 10.0, 0.1, anOptionsBox);
52   myLineFactor->setValue(0.714);
53   
54   // 1.2 Point size factor
55   QLabel* pointLabel = new QLabel( tr( "PS_POINT_SIZE" ), anOptionsBox);
56   myPointFactor = new QtxDoubleSpinBox(0.0, 10.0, 0.1, anOptionsBox);
57   myPointFactor->setValue(0.714);
58
59   // 1.3 Sort method ("No sorting (fastest, poor)", "Simple sorting (fast, good)" and "BSP sorting (slow, best)"
60   QLabel* sortLabel = new QLabel( tr( "PS_SORT_METHOD" ), anOptionsBox);
61   mySortType = new QComboBox( anOptionsBox );
62   mySortType->addItem( tr( "PS_NO_SORTING" ) );
63   mySortType->addItem( tr( "PS_SIMPLE_SORTING" ) );
64   mySortType->addItem( tr( "PS_BPS_SORTING" ) );
65   
66   // 1.4 Rasterize 3D geometry
67   myRasterize3D = new QCheckBox( tr( "PS_RASTERIZE_3D" ), anOptionsBox );
68   
69   // 1.5 Use shfill shading operator
70   myPs3Shading = new QCheckBox( tr( "PS_USE_SHFILL" ), anOptionsBox );
71
72   // Add widgets to layout
73   anOptionsLayout->addWidget( lineLabel, 0, 0 );
74   anOptionsLayout->addWidget( myLineFactor, 0, 1 );
75   anOptionsLayout->addWidget( pointLabel, 1, 0 );
76   anOptionsLayout->addWidget( myPointFactor, 1, 1 );
77   anOptionsLayout->addWidget( sortLabel, 2, 0 );
78   anOptionsLayout->addWidget( mySortType, 2, 1 );
79   anOptionsLayout->addWidget( myRasterize3D, 3, 0, 1, 2 );
80   anOptionsLayout->addWidget( myPs3Shading, 4, 0, 1, 2 );
81
82   
83   QGroupBox* aButtonBox = new QGroupBox(theParent);
84
85   QPushButton* okBtn    = new QPushButton(tr("BUT_OK"), aButtonBox);
86   QPushButton* closeBtn = new QPushButton(tr("BUT_CLOSE"), aButtonBox);
87
88   QSpacerItem* aSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);
89
90   QHBoxLayout* aLay = new QHBoxLayout(aButtonBox);
91   aLay->setMargin(6);
92   aLay->setSpacing(11);
93
94   aLay->addWidget(okBtn);
95   aLay->addItem(aSpacer);
96   aLay->addWidget(closeBtn);
97
98   connect(okBtn,    SIGNAL(clicked()), SLOT(accept()));
99   connect(closeBtn, SIGNAL(clicked()), SLOT(reject()));
100   
101   aTopLayout->addWidget( anOptionsBox );
102   aTopLayout->addWidget( aButtonBox );
103 }
104
105 /*!
106  * Destructor
107  */  
108 SVTK_PsOptionsDlg::~SVTK_PsOptionsDlg()
109 {
110 }
111
112 /*!
113  * Return line scale factor
114  */  
115 double SVTK_PsOptionsDlg::getLineFactor() const {
116   return myLineFactor->value();
117 }
118
119 /*!
120  * Return point scale factor
121  */  
122 double SVTK_PsOptionsDlg::getPointFactor() const {
123   return myPointFactor->value();
124 }
125
126 /*!
127  * Return sort type
128  */  
129 int SVTK_PsOptionsDlg::getSortType() const {
130   return mySortType->currentIndex();
131 }
132
133 /*!
134  * Return rasterize 3D flag
135  */  
136 bool SVTK_PsOptionsDlg::isRasterize3D() const {
137   return myRasterize3D->isChecked();
138 }
139
140 /*!
141  * Return Ps3Shading flag
142  */  
143 bool SVTK_PsOptionsDlg::isPs3Shading() const {
144   return myPs3Shading->isChecked();
145 }