BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
DesignerHelper Class Reference

collection of static methods with SampleDesigner geometry settings More...

Static Public Member Functions

static QGradient getDecorationGradient (const QColor &color, const QRectF &rect)
 
static QRectF getDefaultBoundingRect (const QString &name)
 returns default bounding rectangle for given IvView name More...
 
static QColor getDefaultColor (const QString &name)
 returns default color for IView with given name More...
 
static QColor getDefaultLayerColor ()
 
static QColor getDefaultMaterialColor ()
 
static QRectF getDefaultMultiLayerRect ()
 
static QColor getDefaultParticleColor ()
 
static QColor getDefaultTransformationColor ()
 
static int getHeaderFontSize ()
 returns system dependent font size More...
 
static QRectF getInterferenceFunctionBoundingRect ()
 
static int getLabelFontSize ()
 
static QGradient getLayerGradient (const QColor &color, const QRectF &rect)
 
static QPixmap getMimePixmap (const QString &name)
 returns Mime pixmap for givew IView name More...
 
static QRectF getParticleBoundingRect ()
 
static QRectF getParticleLayoutBoundingRect ()
 
static QPixmap getPixmapInterferenceFunction ()
 
static QPixmap getPixmapLayer ()
 
static QPixmap getPixmapMultiLayer ()
 
static QPixmap getPixmapParticle ()
 
static QPixmap getPixmapParticleLayout ()
 
static int getPortFontSize ()
 
static int getPythonEditorFontSize ()
 
static QColor getRandomColor ()
 
static QPixmap getSceneBackground ()
 
static int getSectionFontSize ()
 
static QRectF getTransformationBoundingRect ()
 
static int layerHeight ()
 
static int layerWidth ()
 
static int nanometerToScreen (double nanometer)
 non-linear conversion of layer's thickness in nanometers to screen size to have reasonable graphics representation of layer in the form of QRect More...
 
static bool sort_layers (QGraphicsItem *left, QGraphicsItem *right)
 sort graphics item according they y-coordinate More...
 

Detailed Description

collection of static methods with SampleDesigner geometry settings

Definition at line 24 of file DesignerHelper.h.

Member Function Documentation

◆ getDecorationGradient()

QGradient DesignerHelper::getDecorationGradient ( const QColor &  color,
const QRectF &  rect 
)
static

Definition at line 43 of file DesignerHelper.cpp.

44 {
45  QColor c = color;
46  // c.setAlpha(200);
47  QLinearGradient result(rect.x() + rect.width() / 2, rect.y(), rect.x() + rect.width() / 2,
48  rect.y() + rect.height());
49  result.setColorAt(0, c);
50  result.setColorAt(0.5, c.lighter(150));
51  result.setColorAt(1, c);
52  return std::move(result);
53 }

Referenced by getMimePixmap(), getPixmapInterferenceFunction(), getPixmapParticle(), getPixmapParticleLayout(), ConnectableView::paint(), and ParticleView::paint().

◆ getDefaultBoundingRect()

QRectF DesignerHelper::getDefaultBoundingRect ( const QString &  name)
static

returns default bounding rectangle for given IvView name

Definition at line 157 of file DesignerHelper.cpp.

158 {
159  if (name == "MultiLayer") {
160  return getDefaultMultiLayerRect();
161  } else if (name == "Layer") {
162  return QRectF(0, 0, layerWidth(), layerHeight());
163  } else if (name == "ParticleLayout") {
165  } else if (name == "Rotation") {
167  } else if (name.startsWith("FormFactor") || name == "Particle" || name == "ParticleCoreShell"
168  || name == "ParticleDistribution") {
169  return getParticleBoundingRect();
170  } else if (name.startsWith("Interference")) {
172  } else {
173  return QRectF(0, 0, 50, 50);
174  }
175 }
static QRectF getParticleLayoutBoundingRect()
static QRectF getInterferenceFunctionBoundingRect()
static QRectF getParticleBoundingRect()
static int layerWidth()
static int layerHeight()
static QRectF getDefaultMultiLayerRect()
static QRectF getTransformationBoundingRect()
QString const & name(EShape k)
Definition: particles.cpp:21

References getDefaultMultiLayerRect(), getInterferenceFunctionBoundingRect(), getParticleBoundingRect(), getParticleLayoutBoundingRect(), getTransformationBoundingRect(), layerHeight(), layerWidth(), and RealSpace::Particles::name().

Referenced by LayerView::LayerView(), MesoCrystalView::MesoCrystalView(), MultiLayerView::MultiLayerView(), ParticleCompositionView::ParticleCompositionView(), ParticleCoreShellView::ParticleCoreShellView(), ParticleDistributionView::ParticleDistributionView(), DesignerScene::dropEvent(), and getMimePixmap().

Here is the call graph for this function:

◆ getDefaultColor()

QColor DesignerHelper::getDefaultColor ( const QString &  name)
static

returns default color for IView with given name

Definition at line 177 of file DesignerHelper.cpp.

178 {
179  if (name == "MultiLayer") {
180  // return QColor(Qt::blue);
181  return QColor(51, 116, 255);
182  } else if (name == "Layer") {
183  // return QColor(Qt::green);
184  return QColor(26, 156, 9);
185  } else if (name == "ParticleLayout") {
186  return QColor(135, 206, 50);
187  } else if (name.startsWith("FormFactor") || name == "Particle" || name == "ParticleCoreShell") {
188  return QColor(210, 223, 237);
189  } else if (name.startsWith("InterferenceFunction")) {
190  return QColor(255, 236, 139);
191  } else if (name == "Transparant red") {
192  return QColor(0xFF, 0, 0, 0x80);
193  } else if (name == "Transparant blue") {
194  return QColor(0, 0, 0xFF, 0x80);
195  } else {
196  return QColor(Qt::lightGray);
197  }
198 }

References RealSpace::Particles::name().

Referenced by getMimePixmap().

Here is the call graph for this function:

◆ getDefaultLayerColor()

QColor DesignerHelper::getDefaultLayerColor ( )
static

Definition at line 230 of file DesignerHelper.cpp.

231 {
232  return QColor(Qt::lightGray);
233 }

◆ getDefaultMaterialColor()

QColor DesignerHelper::getDefaultMaterialColor ( )
static

Definition at line 270 of file DesignerHelper.cpp.

271 {
272  return getRandomColor();
273 }
static QColor getRandomColor()

References getRandomColor().

Here is the call graph for this function:

◆ getDefaultMultiLayerRect()

QRectF DesignerHelper::getDefaultMultiLayerRect ( )
static

Definition at line 235 of file DesignerHelper.cpp.

236 {
237  return QRectF(0, 0, layerWidth() * 1.15, layerHeight());
238 }

References layerHeight(), and layerWidth().

Referenced by getDefaultBoundingRect(), getPixmapMultiLayer(), DesignerScene::isMultiLayerNearby(), MultiLayerView::updateHeight(), and MultiLayerView::updateWidth().

Here is the call graph for this function:

◆ getDefaultParticleColor()

QColor DesignerHelper::getDefaultParticleColor ( )
static

◆ getDefaultTransformationColor()

QColor DesignerHelper::getDefaultTransformationColor ( )
static

Definition at line 260 of file DesignerHelper.cpp.

261 {
262  return QColor(145, 50, 220);
263 }

Referenced by TransformationView::TransformationView().

◆ getHeaderFontSize()

int DesignerHelper::getHeaderFontSize ( )
static

returns system dependent font size

Definition at line 215 of file DesignerHelper.cpp.

216 {
217  return StyleUtils::SystemPointSize() * 1.5;
218 }
int SystemPointSize()
Returns size in points of default system font.
Definition: StyleUtils.cpp:116

References StyleUtils::SystemPointSize().

Here is the call graph for this function:

◆ getInterferenceFunctionBoundingRect()

◆ getLabelFontSize()

int DesignerHelper::getLabelFontSize ( )
static

Definition at line 280 of file DesignerHelper.cpp.

281 {
282  return StyleUtils::SystemPointSize() * 0.9;
283 }

References StyleUtils::SystemPointSize().

Referenced by RunFitControlWidget::RunFitControlWidget(), AboutApplicationDialog::createTextLayout(), StyleUtils::labelFont(), ConnectableView::paint(), and ParticleView::paint().

Here is the call graph for this function:

◆ getLayerGradient()

QGradient DesignerHelper::getLayerGradient ( const QColor &  color,
const QRectF &  rect 
)
static

Definition at line 26 of file DesignerHelper.cpp.

27 {
28  QColor c = color;
29  c.setAlpha(160);
30  QLinearGradient result(rect.topLeft(), rect.bottomRight());
31 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0)
32  result.setColorAt(0, c.darker(150));
33  result.setColorAt(0.5, c.lighter(200));
34  result.setColorAt(1, c.darker(150));
35 #else
36  result.setColorAt(0, c.dark(150));
37  result.setColorAt(0.5, c.light(200));
38  result.setColorAt(1, c.dark(150));
39 #endif
40  return std::move(result);
41 }

Referenced by getPixmapLayer(), getPixmapMultiLayer(), LayerView::paint(), and MultiLayerView::paint().

◆ getMimePixmap()

QPixmap DesignerHelper::getMimePixmap ( const QString &  name)
static

returns Mime pixmap for givew IView name

Definition at line 200 of file DesignerHelper.cpp.

201 {
202  QRectF default_rect = getDefaultBoundingRect(name);
203  QRectF mime_rect(0, 0, default_rect.width() * m_current_zoom_level,
204  default_rect.height() * m_current_zoom_level);
205 
206  QPixmap pixmap(mime_rect.width() + 1, mime_rect.height() + 1);
207  pixmap.fill(Qt::transparent);
208  QPainter painter(&pixmap);
209  painter.setPen(Qt::black);
210  painter.setBrush(getDecorationGradient(getDefaultColor(name), mime_rect));
211  painter.drawRoundedRect(mime_rect, 1, 1);
212  return pixmap;
213 }
static QRectF getDefaultBoundingRect(const QString &name)
returns default bounding rectangle for given IvView name
static QGradient getDecorationGradient(const QColor &color, const QRectF &rect)
static QColor getDefaultColor(const QString &name)
returns default color for IView with given name

References getDecorationGradient(), getDefaultBoundingRect(), getDefaultColor(), and RealSpace::Particles::name().

Referenced by DesignerMimeData::getPixmap().

Here is the call graph for this function:

◆ getParticleBoundingRect()

QRectF DesignerHelper::getParticleBoundingRect ( )
static

Definition at line 255 of file DesignerHelper.cpp.

256 {
257  return QRectF(0, 0, layerHeight() * 3.5, layerHeight() * 4);
258 }

References layerHeight().

Referenced by ParticleView::ParticleView(), getDefaultBoundingRect(), and getPixmapParticle().

Here is the call graph for this function:

◆ getParticleLayoutBoundingRect()

QRectF DesignerHelper::getParticleLayoutBoundingRect ( )
static

Definition at line 240 of file DesignerHelper.cpp.

241 {
242  return QRectF(0, 0, layerHeight() * 3.5, layerHeight() * 4.5);
243 }

References layerHeight().

Referenced by ParticleLayoutView::ParticleLayoutView(), getDefaultBoundingRect(), and getPixmapParticleLayout().

Here is the call graph for this function:

◆ getPixmapInterferenceFunction()

QPixmap DesignerHelper::getPixmapInterferenceFunction ( )
static

Definition at line 107 of file DesignerHelper.cpp.

108 {
110  QPixmap pixmap(rect.width() + 1, rect.height() + 1);
111  pixmap.fill(Qt::transparent);
112  QPainter painter(&pixmap);
113  painter.setPen(Qt::black);
114  painter.setBrush(getDecorationGradient(Qt::lightGray, rect));
115  painter.drawRoundedRect(rect, 3, 3);
116  return pixmap;
117 }

References getDecorationGradient(), and getInterferenceFunctionBoundingRect().

Here is the call graph for this function:

◆ getPixmapLayer()

QPixmap DesignerHelper::getPixmapLayer ( )
static

Definition at line 68 of file DesignerHelper.cpp.

69 {
70  QRect rect(0, 0, layerWidth(), layerHeight());
71  QPixmap pixmap(rect.width() + 1, rect.height() + 1);
72  pixmap.fill(Qt::transparent);
73  QPainter painter(&pixmap);
74  painter.setPen(Qt::black);
75  painter.setBrush(getLayerGradient(Qt::green, rect));
76  painter.drawRect(rect);
77  return pixmap;
78 }
static QGradient getLayerGradient(const QColor &color, const QRectF &rect)

References getLayerGradient(), layerHeight(), and layerWidth().

Here is the call graph for this function:

◆ getPixmapMultiLayer()

QPixmap DesignerHelper::getPixmapMultiLayer ( )
static

Definition at line 80 of file DesignerHelper.cpp.

81 {
82  auto rect = getDefaultMultiLayerRect();
83  QPixmap pixmap(rect.width() + 1, rect.height() + 1);
84  pixmap.fill(Qt::transparent);
85  QPainter painter(&pixmap);
86  painter.setPen(Qt::black);
87  painter.setBrush(getLayerGradient(QColor(75, 157, 249), rect));
88  painter.drawRect(rect);
89  painter.setPen(Qt::DashLine);
90  painter.drawLine(0, layerHeight() * 0.3, rect.width(), layerHeight() * 0.3);
91  painter.drawLine(0, layerHeight() * 0.6, rect.width(), layerHeight() * 0.6);
92  return pixmap;
93 }

References getDefaultMultiLayerRect(), getLayerGradient(), and layerHeight().

Here is the call graph for this function:

◆ getPixmapParticle()

QPixmap DesignerHelper::getPixmapParticle ( )
static

Definition at line 119 of file DesignerHelper.cpp.

120 {
121  auto rect = getParticleBoundingRect();
122  QPixmap pixmap(rect.width() + 1, rect.height() + 1);
123  pixmap.fill(Qt::transparent);
124  QPainter painter(&pixmap);
125  painter.setPen(Qt::black);
126  painter.setBrush(getDecorationGradient(getDefaultParticleColor(), rect));
127  painter.drawRoundedRect(rect, 5, 5);
128  return pixmap;
129 }
static QColor getDefaultParticleColor()

References getDecorationGradient(), getDefaultParticleColor(), and getParticleBoundingRect().

Here is the call graph for this function:

◆ getPixmapParticleLayout()

QPixmap DesignerHelper::getPixmapParticleLayout ( )
static

Definition at line 95 of file DesignerHelper.cpp.

96 {
97  auto rect = getParticleLayoutBoundingRect();
98  QPixmap pixmap(rect.width() + 1, rect.height() + 1);
99  pixmap.fill(Qt::transparent);
100  QPainter painter(&pixmap);
101  painter.setPen(Qt::black);
102  painter.setBrush(getDecorationGradient(QColor(135, 206, 50), rect));
103  painter.drawRoundedRect(rect, 3, 3);
104  return pixmap;
105 }

References getDecorationGradient(), and getParticleLayoutBoundingRect().

Here is the call graph for this function:

◆ getPortFontSize()

int DesignerHelper::getPortFontSize ( )
static

Definition at line 285 of file DesignerHelper.cpp.

286 {
287  return StyleUtils::SystemPointSize() * 0.7;
288 }

References StyleUtils::SystemPointSize().

Referenced by RunFitControlWidget::RunFitControlWidget(), and NodeEditorPort::setLabel().

Here is the call graph for this function:

◆ getPythonEditorFontSize()

int DesignerHelper::getPythonEditorFontSize ( )
static

Definition at line 290 of file DesignerHelper.cpp.

291 {
293 }

References StyleUtils::SystemPointSize().

Referenced by PySampleWidget::PySampleWidget(), and PythonScriptWidget::PythonScriptWidget().

Here is the call graph for this function:

◆ getRandomColor()

QColor DesignerHelper::getRandomColor ( )
static

Definition at line 131 of file DesignerHelper.cpp.

132 {
133  static std::random_device r;
134  std::default_random_engine re(r());
135  std::uniform_int_distribution<int> ru(0, 255);
136 
137  return QColor(ru(re), ru(re), ru(re));
138 }

Referenced by getDefaultMaterialColor(), and MaterialItemUtils::suggestMaterialColor().

◆ getSceneBackground()

QPixmap DesignerHelper::getSceneBackground ( )
static

Definition at line 55 of file DesignerHelper.cpp.

56 {
57  const int size = 10;
58  QPixmap result(size, size);
59  result.fill(QColor(250, 250, 250));
60  QPainter tilePainter(&result);
61  QColor color(220, 220, 220);
62  tilePainter.fillRect(0.0, 0.0, 2, 2, color);
63  tilePainter.end();
64 
65  return result;
66 }

Referenced by DesignerScene::DesignerScene().

◆ getSectionFontSize()

int DesignerHelper::getSectionFontSize ( )
static

Definition at line 275 of file DesignerHelper.cpp.

276 {
277  return StyleUtils::SystemPointSize() * 1.2;
278 }

References StyleUtils::SystemPointSize().

Referenced by ProjectLoadWarningDialog::createDetailsPanel(), ProjectLoadWarningDialog::createExplanationPanel(), ProjectLoadWarningDialog::createTopPanel(), OverlayLabelWidget::paintEvent(), and StyleUtils::sectionFont().

Here is the call graph for this function:

◆ getTransformationBoundingRect()

QRectF DesignerHelper::getTransformationBoundingRect ( )
static

Definition at line 265 of file DesignerHelper.cpp.

266 {
267  return QRectF(0, 0, layerHeight() * 4, layerHeight() * 2);
268 }

References layerHeight().

Referenced by TransformationView::TransformationView(), and getDefaultBoundingRect().

Here is the call graph for this function:

◆ layerHeight()

int DesignerHelper::layerHeight ( )
static

Definition at line 225 of file DesignerHelper.cpp.

226 {
227  return StyleUtils::SizeOfLetterM().height() * 2;
228 }
QSize SizeOfLetterM(const QWidget *widget=nullptr)
Returns size of largest letter of default system font.
Definition: StyleUtils.cpp:110

References StyleUtils::SizeOfLetterM().

Referenced by getDefaultBoundingRect(), getDefaultMultiLayerRect(), getInterferenceFunctionBoundingRect(), getParticleBoundingRect(), getParticleLayoutBoundingRect(), getPixmapLayer(), getPixmapMultiLayer(), getTransformationBoundingRect(), and nanometerToScreen().

Here is the call graph for this function:

◆ layerWidth()

int DesignerHelper::layerWidth ( )
static

Definition at line 220 of file DesignerHelper.cpp.

221 {
222  return StyleUtils::SizeOfLetterM().width() * 18;
223 }

References StyleUtils::SizeOfLetterM().

Referenced by getDefaultBoundingRect(), getDefaultMultiLayerRect(), and getPixmapLayer().

Here is the call graph for this function:

◆ nanometerToScreen()

int DesignerHelper::nanometerToScreen ( double  nanometer)
static

non-linear conversion of layer's thickness in nanometers to screen size to have reasonable graphics representation of layer in the form of QRect

Definition at line 147 of file DesignerHelper.cpp.

148 {
149  const int ymin(layerHeight());
150  const int ymax(500);
151  int result(ymin);
152  if (nanometer > 0)
153  result = qBound(ymin, ymin + (int)std::pow(nanometer, 0.9), ymax);
154  return result;
155 }
static constexpr double nanometer
Internal unit for lengths.
Definition: Units.h:33

References layerHeight(), and Units::nanometer.

Referenced by ILayerView::updateHeight().

Here is the call graph for this function:

◆ sort_layers()

bool DesignerHelper::sort_layers ( QGraphicsItem *  left,
QGraphicsItem *  right 
)
static

sort graphics item according they y-coordinate

Definition at line 140 of file DesignerHelper.cpp.

141 {
142  return left->y() < right->y();
143 }

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