ATLAS Offline Software
Classes | Signals | Public Member Functions | Private Slots | Private Attributes | List of all members
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;
66  updateNodes();
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 }

◆ ~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 {
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 }

◆ 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;
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;
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;
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;
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 }

◆ 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);
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;
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  }
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 }

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:
VP1DrawOptionsWidget::Imp::ui
Ui::DrawOptionsForm ui
Definition: VP1DrawOptionsWidget.cxx:29
VP1QtInventorUtils::getValueLineWidthSlider
static double getValueLineWidthSlider(const QSlider *)
Definition: VP1QtInventorUtils.cxx:1619
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
VP1Serialise
Definition: VP1Serialise.h:45
VP1DrawOptionsWidget::Imp::linewidthsDisabled
bool linewidthsDisabled
Definition: VP1DrawOptionsWidget.cxx:34
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
python.LumiCalcWorking.lw
lw
Definition: LumiCalcWorking.py:112
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
fillPileUpNoiseLumi.connect
string connect
Definition: fillPileUpNoiseLumi.py:70
VP1DrawOptionsWidget::Imp::pointsizesDisabled
bool pointsizesDisabled
Definition: VP1DrawOptionsWidget.cxx:35
VP1DrawOptionsWidget::complexityChanged
void complexityChanged(const double &)
VP1QtInventorUtils::setLimitsPointSizeSlider
static void setLimitsPointSizeSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1577
VP1QtInventorUtils::getValuePointSizeSlider
static double getValuePointSizeSlider(const QSlider *)
Definition: VP1QtInventorUtils.cxx:1630
VP1DrawOptionsWidget::Imp::baselightingDisabled
bool baselightingDisabled
Definition: VP1DrawOptionsWidget.cxx:37
VP1DrawOptionsWidget::Imp::lastEmittedComplexity
double lastEmittedComplexity
Definition: VP1DrawOptionsWidget.cxx:38
test_pyathena.parent
parent
Definition: test_pyathena.py:15
VP1DrawOptionsWidget::Imp::complexityDisabled
bool complexityDisabled
Definition: VP1DrawOptionsWidget.cxx:36
VP1Deserialise
Definition: VP1Deserialise.h:44
VP1QtInventorUtils::setValueLineWidthSlider
static void setValueLineWidthSlider(QSlider *, const double &value)
Definition: VP1QtInventorUtils.cxx:1593
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
VP1DrawOptionsWidget::updateNodes
void updateNodes()
Definition: VP1DrawOptionsWidget.cxx:183
VP1QtInventorUtils::setValuePointSizeSlider
static void setValuePointSizeSlider(QSlider *, const double &value)
Definition: VP1QtInventorUtils.cxx:1606
VP1QtInventorUtils::setLimitsLineWidthSlider
static void setLimitsLineWidthSlider(QSlider *)
Definition: VP1QtInventorUtils.cxx:1563
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
VP1DrawOptionsWidget::Imp::group
SoGroup * group
Definition: VP1DrawOptionsWidget.cxx:30
VP1DrawOptionsWidget::Imp::drawStyle
SoDrawStyle * drawStyle
Definition: VP1DrawOptionsWidget.cxx:33
VP1DrawOptionsWidget::m_d
Imp * m_d
Definition: VP1DrawOptionsWidget.h:59
python.compressB64.c
def c
Definition: compressB64.py:93
VP1DrawOptionsWidget::Imp::baseLightModel
SoLightModel * baseLightModel
Definition: VP1DrawOptionsWidget.cxx:32
VP1DrawOptionsWidget::complexity
double complexity() const
Definition: VP1DrawOptionsWidget.cxx:90
VP1DrawOptionsWidget::Imp::complexity
SoComplexity * complexity
Definition: VP1DrawOptionsWidget.cxx:31