ATLAS Offline Software
Loading...
Searching...
No Matches
VP1DrawOptionsWidget Class Reference

#include <VP1DrawOptionsWidget.h>

Inheritance diagram for VP1DrawOptionsWidget:
Collaboration diagram for VP1DrawOptionsWidget:

Classes

class  Imp

Signals

void complexityChanged (const double &)

Public Member Functions

 VP1DrawOptionsWidget (QWidget *parent=0)
virtual ~VP1DrawOptionsWidget ()
SoGroup * drawOptionsGroup () const
void setComplexity (const double &)
void setLineWidths (const double &)
void setPointSizes (const double &)
void setUseBaseLighting (bool)
void setComplexityDisabled (bool b=true)
void setLineWidthsDisabled (bool b=true)
void setPointSizesDisabled (bool b=true)
void setBaseLightingDisabled (bool b=true)
QByteArray state () const
void applyState (const QByteArray &)
double complexity () const

Private Slots

void updateNodes ()

Private Attributes

Impm_d

Detailed Description

Definition at line 25 of file VP1DrawOptionsWidget.h.

Constructor & Destructor Documentation

◆ VP1DrawOptionsWidget()

VP1DrawOptionsWidget::VP1DrawOptionsWidget ( QWidget * parent = 0)

Definition at line 43 of file VP1DrawOptionsWidget.cxx.

44 : QWidget(parent), m_d(new Imp)
45{
46 m_d->ui.setupUi(this);
47 VP1QtInventorUtils::setLimitsLineWidthSlider(m_d->ui.horizontalSlider_linewidths);
48 VP1QtInventorUtils::setValueLineWidthSlider(m_d->ui.horizontalSlider_linewidths,1.2);
49 VP1QtInventorUtils::setLimitsPointSizeSlider(m_d->ui.horizontalSlider_pointsizes);
50 VP1QtInventorUtils::setValuePointSizeSlider(m_d->ui.horizontalSlider_pointsizes,1.2);
51 m_d->linewidthsDisabled = false;
52 m_d->pointsizesDisabled = false;
53 m_d->complexityDisabled = false;
54 m_d->baselightingDisabled = false;
55 m_d->group = new SoGroup;
56 m_d->group->setName("DrawOptionsGroup");
57 m_d->group->ref();
58 m_d->complexity = new SoComplexity;
59 m_d->complexity->ref();
60 m_d->drawStyle = new SoDrawStyle;
61 m_d->drawStyle->ref();
62 m_d->baseLightModel = new SoLightModel;
63 m_d->baseLightModel->ref();
64 m_d->baseLightModel->model = SoLightModel::BASE_COLOR;
65 m_d->lastEmittedComplexity = 0.5;
67 connect(m_d->ui.horizontalSlider_linewidths,SIGNAL(valueChanged(int)),this,SLOT(updateNodes()));
68 connect(m_d->ui.horizontalSlider_pointsizes,SIGNAL(valueChanged(int)),this,SLOT(updateNodes()));
69 connect(m_d->ui.horizontalSlider_complexity,SIGNAL(valueChanged(int)),this,SLOT(updateNodes()));
70 connect(m_d->ui.checkBox_useBaseLightModel,SIGNAL(toggled(bool)),this,SLOT(updateNodes()));
71}
static void setLimitsLineWidthSlider(QSlider *)
static void setValuePointSizeSlider(QSlider *, const double &value)
static void setLimitsPointSizeSlider(QSlider *)
static void setValueLineWidthSlider(QSlider *, const double &value)

◆ ~VP1DrawOptionsWidget()

VP1DrawOptionsWidget::~VP1DrawOptionsWidget ( )
virtual

Definition at line 74 of file VP1DrawOptionsWidget.cxx.

75{
76 m_d->group->unref();
77 m_d->complexity->unref();
78 m_d->drawStyle->unref();
79 m_d->baseLightModel->unref();
80 delete m_d;
81}

Member Function Documentation

◆ applyState()

void VP1DrawOptionsWidget::applyState ( const QByteArray & ba)

Definition at line 262 of file VP1DrawOptionsWidget.cxx.

263{
264 VP1Deserialise s(ba);
265
266 if (s.version()!=0)
267 return;//ignore silently
268
269 VP1QtInventorUtils::setValueLineWidthSlider(m_d->ui.horizontalSlider_linewidths,s.restoreDouble());
270 VP1QtInventorUtils::setValuePointSizeSlider(m_d->ui.horizontalSlider_pointsizes,s.restoreDouble());
271 s.widgetHandled(m_d->ui.horizontalSlider_linewidths);
272 s.widgetHandled(m_d->ui.horizontalSlider_pointsizes);
273
274 s.restore(m_d->ui.horizontalSlider_complexity);
275 s.restore(m_d->ui.checkBox_useBaseLightModel);
276
277 s.widgetHandled(this);
278 s.warnUnrestored(this);
279
280 updateNodes();
281
282}

◆ complexity()

double VP1DrawOptionsWidget::complexity ( ) const

Definition at line 90 of file VP1DrawOptionsWidget.cxx.

91{
92 if (m_d->complexityDisabled)
93 return 0.5;
94 const int val = m_d->ui.horizontalSlider_complexity->value();
95 const int min = m_d->ui.horizontalSlider_complexity->minimum();
96 const int max = m_d->ui.horizontalSlider_complexity->maximum();
97 if(val==min)
98 return 0.0;
99 if(val==max)
100 return 1.0;
101 return std::min<double>(1.0,std::max<double>(0.0,(val-min)/(max*1.0)));
102}
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41

◆ complexityChanged

void VP1DrawOptionsWidget::complexityChanged ( const double & )
signal

◆ drawOptionsGroup()

SoGroup * VP1DrawOptionsWidget::drawOptionsGroup ( ) const

Definition at line 84 of file VP1DrawOptionsWidget.cxx.

85{
86 return m_d->group;
87}

◆ setBaseLightingDisabled()

void VP1DrawOptionsWidget::setBaseLightingDisabled ( bool b = true)

Definition at line 173 of file VP1DrawOptionsWidget.cxx.

174{
175 if (m_d->baselightingDisabled==b)
176 return;
177 m_d->baselightingDisabled=b;
178 m_d->ui.checkBox_useBaseLightModel->setVisible(!b);
179 updateNodes();
180}

◆ setComplexity()

void VP1DrawOptionsWidget::setComplexity ( const double & c)

Definition at line 105 of file VP1DrawOptionsWidget.cxx.

106{
107 int min = m_d->ui.horizontalSlider_complexity->minimum();
108 int max = m_d->ui.horizontalSlider_complexity->maximum();
109 int newval = std::min(max,std::max(min,(min+static_cast<int>((max-min)*c+0.5))));
110 if (m_d->ui.horizontalSlider_complexity->value()!=newval) {
111 m_d->ui.horizontalSlider_complexity->setValue(newval);
112 updateNodes();
113 }
114}

◆ setComplexityDisabled()

void VP1DrawOptionsWidget::setComplexityDisabled ( bool b = true)

Definition at line 140 of file VP1DrawOptionsWidget.cxx.

141{
142 if (m_d->complexityDisabled==b)
143 return;
144 m_d->complexityDisabled = b;
145 m_d->ui.label_curve_realism->setVisible(!b);
146 m_d->ui.horizontalSlider_complexity->setVisible(!b);
147 updateNodes();
148}

◆ setLineWidths()

void VP1DrawOptionsWidget::setLineWidths ( const double & lw)

Definition at line 117 of file VP1DrawOptionsWidget.cxx.

118{
119 VP1QtInventorUtils::setValueLineWidthSlider(m_d->ui.horizontalSlider_linewidths,lw);
120 updateNodes();
121}

◆ setLineWidthsDisabled()

void VP1DrawOptionsWidget::setLineWidthsDisabled ( bool b = true)

Definition at line 151 of file VP1DrawOptionsWidget.cxx.

152{
153 if (m_d->linewidthsDisabled==b)
154 return;
155 m_d->linewidthsDisabled=b;
156 m_d->ui.label_linewidths->setVisible(!b);
157 m_d->ui.horizontalSlider_linewidths->setVisible(!b);
158 updateNodes();
159}

◆ setPointSizes()

void VP1DrawOptionsWidget::setPointSizes ( const double & ps)

Definition at line 124 of file VP1DrawOptionsWidget.cxx.

125{
126 VP1QtInventorUtils::setValuePointSizeSlider(m_d->ui.horizontalSlider_pointsizes,ps);
127 updateNodes();
128}

◆ setPointSizesDisabled()

void VP1DrawOptionsWidget::setPointSizesDisabled ( bool b = true)

Definition at line 162 of file VP1DrawOptionsWidget.cxx.

163{
164 if (m_d->pointsizesDisabled==b)
165 return;
166 m_d->pointsizesDisabled = b;
167 m_d->ui.label_pointsizes->setVisible(!b);
168 m_d->ui.horizontalSlider_pointsizes->setVisible(!b);
169 updateNodes();
170}

◆ setUseBaseLighting()

void VP1DrawOptionsWidget::setUseBaseLighting ( bool b)

Definition at line 131 of file VP1DrawOptionsWidget.cxx.

132{
133 if (m_d->ui.checkBox_useBaseLightModel->isChecked()==b)
134 return;
135 m_d->ui.checkBox_useBaseLightModel->setChecked(b);
136 updateNodes();
137}

◆ state()

QByteArray VP1DrawOptionsWidget::state ( ) const

Definition at line 242 of file VP1DrawOptionsWidget.cxx.

243{
244 VP1Serialise s(0/*version*/);
245
246 //Line width/point size:
247 s.save(VP1QtInventorUtils::getValueLineWidthSlider(m_d->ui.horizontalSlider_linewidths));
248 s.save(VP1QtInventorUtils::getValuePointSizeSlider(m_d->ui.horizontalSlider_pointsizes));
249 s.widgetHandled(m_d->ui.horizontalSlider_linewidths);
250 s.widgetHandled(m_d->ui.horizontalSlider_pointsizes);
251
252 s.save(m_d->ui.horizontalSlider_complexity);
253 s.save(m_d->ui.checkBox_useBaseLightModel);
254
255 s.widgetHandled(this);
256 s.warnUnsaved(this);
257
258 return s.result();
259}
static double getValueLineWidthSlider(const QSlider *)
static double getValuePointSizeSlider(const QSlider *)

◆ updateNodes

void VP1DrawOptionsWidget::updateNodes ( )
privateslot

Definition at line 183 of file VP1DrawOptionsWidget.cxx.

184{
185 // 1) Update attachments
186
187 bool drawStyleAttached(m_d->group->findChild(m_d->drawStyle)>=0);
188 if (m_d->linewidthsDisabled&&m_d->pointsizesDisabled) {
189 if (drawStyleAttached)
190 m_d->group->removeChild(m_d->drawStyle);
191 } else {
192 if (!drawStyleAttached)
193 m_d->group->addChild(m_d->drawStyle);
194 }
195
196 bool complexityAttached(m_d->group->findChild(m_d->complexity)>=0);
197 if (m_d->complexityDisabled) {
198 if (complexityAttached)
199 m_d->group->removeChild(m_d->complexity);
200 } else {
201 if (!complexityAttached)
202 m_d->group->addChild(m_d->complexity);
203 }
204
205 bool lightModelAttached(m_d->group->findChild(m_d->baseLightModel)>=0);
206 bool lightModelAttachedGoal = !m_d->baselightingDisabled && m_d->ui.checkBox_useBaseLightModel->isChecked();
207 if (lightModelAttachedGoal!=lightModelAttached) {
208 if (lightModelAttached)
209 m_d->group->removeChild(m_d->baseLightModel);
210 else
211 m_d->group->addChild(m_d->baseLightModel);
212 }
213
214 // 2) Emit complexityChanged?
215 double complexityval = complexity();
216 if (m_d->lastEmittedComplexity!=complexityval) {
217 m_d->lastEmittedComplexity=complexityval;
218 complexityChanged(m_d->lastEmittedComplexity);
219 }
220
221 // 3) Update fields
222 if (!m_d->complexityDisabled){
223 //We avoid setting the complexity value exactly to 0:
224 complexityval = std::min<double>(1.0,std::max<double>(0.0,0.01+0.991*complexityval));
225 }
226 if (m_d->complexity->value.getValue()!=complexityval){
227 m_d->complexity->value.setValue(complexityval);
228 }
229 if (!m_d->linewidthsDisabled||!m_d->pointsizesDisabled) {
230 double val_lw = m_d->linewidthsDisabled ? 0 : VP1QtInventorUtils::getValueLineWidthSlider(m_d->ui.horizontalSlider_linewidths);
231 double val_ps = m_d->pointsizesDisabled ? 0 : VP1QtInventorUtils::getValuePointSizeSlider(m_d->ui.horizontalSlider_pointsizes);
232 if (m_d->drawStyle->lineWidth.getValue()!=val_lw)
233 m_d->drawStyle->lineWidth = val_lw;
234 if (m_d->drawStyle->pointSize.getValue()!=val_ps)
235 m_d->drawStyle->pointSize = val_ps;
236 }
237
238
239}
void complexityChanged(const double &)

Member Data Documentation

◆ m_d

Imp* VP1DrawOptionsWidget::m_d
private

Definition at line 60 of file VP1DrawOptionsWidget.h.


The documentation for this class was generated from the following files: