BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::RealSpace::Model Class Reference

Description

Definition at line 27 of file model.h.

Inheritance diagram for GUI::RealSpace::Model:
[legend]
Collaboration diagram for GUI::RealSpace::Model:
[legend]

Signals

void updated (bool withEye)
 

Public Member Functions

 Model ()
 
 ~Model () override
 
void add (Object *)
 add an opaque object, the model takes ownership More...
 
void addBlend (Object *)
 add a transparent object, the model takes ownership More...
 
virtual void cameraUpdated (Camera const &)
 
void clearBlend ()
 
void clearOpaque ()
 
bool modelIsEmpty ()
 
void releaseGeometries ()
 may be called any time More...
 
void rem (Object *)
 removes an object, the caller becomes responsible More...
 

Static Public Member Functions

static Particles::ParticlenewParticle (Particles::EShape k, float R)
 

Public Attributes

Camera::Position defCamPos
 default camera params More...
 

Private Member Functions

void draw (Canvas &) const
 
void drawBlend (Canvas &) const
 

Private Attributes

QVector< Object * > objects
 
QVector< Object * > objectsBlend
 

Friends

class Camera
 
class Canvas
 
class Object
 

Constructor & Destructor Documentation

◆ Model()

GUI::RealSpace::Model::Model ( )

Definition at line 21 of file model.cpp.

23 {
24 }
Camera::Position defCamPos
default camera params
Definition: model.h:52
static Vector3D const _z
Definition: def.h:46
static Vector3D const _0
Definition: def.h:46
static Vector3D const _1
Definition: def.h:46

◆ ~Model()

GUI::RealSpace::Model::~Model ( )
override

Definition at line 26 of file model.cpp.

27 {
28  for (auto* o : objects) {
29  o->model = nullptr;
30  delete o;
31  }
32 
33  for (auto* o : objectsBlend) {
34  o->model = nullptr;
35  delete o;
36  }
37 }
QVector< Object * > objectsBlend
Definition: model.h:58
QVector< Object * > objects
Definition: model.h:58

References objects, and objectsBlend.

Member Function Documentation

◆ add()

void GUI::RealSpace::Model::add ( Object o)

add an opaque object, the model takes ownership

Definition at line 128 of file model.cpp.

129 {
130  ASSERT(o);
131  ASSERT(!o->model);
132  o->model = this;
133  objects.append(o);
134 }

References GUI::RealSpace::Object::model, and objects.

Referenced by RealSpaceBuilder::populateParticleFromParticle3DContainer().

◆ addBlend()

void GUI::RealSpace::Model::addBlend ( Object o)

add a transparent object, the model takes ownership

Definition at line 136 of file model.cpp.

137 {
138  ASSERT(o);
139  ASSERT(!o->model);
140  o->model = this;
141  objectsBlend.append(o);
142 }

References GUI::RealSpace::Object::model, and objectsBlend.

Referenced by RealSpaceBuilder::populateLayer(), and RealSpaceBuilder::populateParticleFromParticle3DContainer().

◆ cameraUpdated()

virtual void GUI::RealSpace::Model::cameraUpdated ( Camera const &  )
inlinevirtual

Definition at line 50 of file model.h.

50 {}

◆ clearBlend()

void GUI::RealSpace::Model::clearBlend ( )

Definition at line 46 of file model.cpp.

47 {
48  while (!objectsBlend.isEmpty())
49  delete objectsBlend.first();
50  emit updated(false);
51 }
void updated(bool withEye)

References objectsBlend, and updated().

◆ clearOpaque()

void GUI::RealSpace::Model::clearOpaque ( )

Definition at line 39 of file model.cpp.

40 {
41  while (!objects.isEmpty())
42  delete objects.first();
43  emit updated(false);
44 }

References objects, and updated().

◆ draw()

void GUI::RealSpace::Model::draw ( Canvas canvas) const
private

Definition at line 170 of file model.cpp.

171 {
172  for (auto* o : objects)
173  o->draw(canvas);
174 }

References objects.

Referenced by GUI::RealSpace::Canvas::paintGL().

◆ drawBlend()

void GUI::RealSpace::Model::drawBlend ( Canvas canvas) const
private

Definition at line 176 of file model.cpp.

177 {
178  for (auto* o : objectsBlend)
179  o->draw(canvas);
180 }

References objectsBlend.

Referenced by GUI::RealSpace::Canvas::paintGL().

◆ modelIsEmpty()

bool GUI::RealSpace::Model::modelIsEmpty ( )

Definition at line 165 of file model.cpp.

166 {
167  return objects.isEmpty() && objectsBlend.isEmpty();
168 }

References objects, and objectsBlend.

Referenced by GUI::RealSpace::Canvas::paintGL().

◆ newParticle()

Particles::Particle * GUI::RealSpace::Model::newParticle ( Particles::EShape  k,
float  R 
)
static

Definition at line 53 of file model.cpp.

54 {
55  using namespace Particles;
56 
57  float D = 2 * R;
58 
59  switch (k) {
60  case EShape::None:
61  return nullptr;
62  case EShape::BarGauss:
63  return new BarGauss(D, D, 5 * D);
64  case EShape::BarLorentz:
65  return new BarLorentz(D, D, 5 * D);
66  case EShape::Box:
67  return new Box(D, D, D);
68  case EShape::Sphere:
69  return new Sphere(R);
70  case EShape::Spheroid:
71  return new Spheroid(R / 2, D);
72  case EShape::Cylinder:
73  return new Cylinder(R, D);
74  case EShape::TruncatedSphere:
75  return new TruncatedSphere(R, D / 3);
76  case EShape::TruncatedSpheroid:
77  return new TruncatedSpheroid(R, 2 * R, 1.5);
78  case EShape::Cone:
79  return new Cone(R, D, 1.3f);
80  case EShape::Icosahedron:
81  return new Icosahedron(R * IcosahedronL2R);
82  case EShape::Dodecahedron:
83  return new Dodecahedron(R * DodecahedronL2R);
84  case EShape::TruncatedCube:
85  return new TruncatedCube(D, D / 3);
86  case EShape::Prism6:
87  return new Prism6(R, D);
88  case EShape::Pyramid6:
89  return new Pyramid6(R, D, 1.3f);
90  case EShape::Pyramid4:
91  return new Pyramid4(D, D, 1.3f);
92  case EShape::Bipyramid4:
93  return new Bipyramid4(D, R * 3 / 2, 2.f / 3, 2);
94  case EShape::Prism3:
95  return new Prism3(R, D);
96  case EShape::Pyramid3:
97  return new Pyramid3(R, D, 1.3f);
98  case EShape::EllipsoidalCylinder:
99  return new EllipsoidalCylinder(R, R / 2, D);
100  case EShape::HemiEllipsoid:
101  return new HemiEllipsoid(R, R, D);
102  case EShape::CosineRippleBox:
103  return new CosineRippleBox(D, D, D); // TODO ripples should be elongated
104  case EShape::CosineRippleGauss:
105  return new CosineRippleGauss(D, D, D); // TODO ripples should be elongated
106  case EShape::CosineRippleLorentz:
107  return new CosineRippleLorentz(D, D, D); // TODO ripples should be elongated
108  case EShape::SawtoothRippleBox:
109  return new SawtoothRippleBox(D, D, D); // TODO ripples should be elongated
110  case EShape::SawtoothRippleGauss:
111  return new SawtoothRippleGauss(D, D, D); // TODO ripples should be elongated
112  case EShape::SawtoothRippleLorentz:
113  return new SawtoothRippleLorentz(D, D, D); // TODO ripples should be elongated
114  case EShape::CantellatedCube:
115  return new CantellatedCube(D, D / 3);
116  case EShape::HorizontalCylinder:
117  return new HorizontalCylinder(R, D, -R, R);
118  case EShape::PlatonicOctahedron:
119  return new PlatonicOctahedron(D);
120  case EShape::PlatonicTetrahedron:
121  return new PlatonicTetrahedron(D);
122  case EShape::Pyramid2:
123  return new Pyramid2(R, D, D, 1.3f);
124  }
125  return nullptr;
126 }
const float DodecahedronL2R
const float IcosahedronL2R

References GUI::RealSpace::DodecahedronL2R, and GUI::RealSpace::IcosahedronL2R.

◆ releaseGeometries()

void GUI::RealSpace::Model::releaseGeometries ( )

may be called any time

Definition at line 157 of file model.cpp.

158 {
159  for (auto* o : objects)
160  o->releaseGeometry();
161  for (auto* o : objectsBlend)
162  o->releaseGeometry();
163 }

References objects, and objectsBlend.

◆ rem()

void GUI::RealSpace::Model::rem ( Object o)

removes an object, the caller becomes responsible

Definition at line 144 of file model.cpp.

145 {
146  if (int i = objects.indexOf(o); i >= 0)
147  objects.remove(i);
148  else if (int i = objectsBlend.indexOf(o); i >= 0)
149  objectsBlend.remove(i);
150  else
151  ASSERT(false); // object not found, should not happen, bad caller!
152 
153  o->releaseGeometry();
154  o->model = nullptr;
155 }

References GUI::RealSpace::Object::model, objects, objectsBlend, and GUI::RealSpace::Object::releaseGeometry().

Referenced by GUI::RealSpace::Object::~Object().

Here is the call graph for this function:

◆ updated

void GUI::RealSpace::Model::updated ( bool  withEye)
signal

Friends And Related Function Documentation

◆ Camera

friend class Camera
friend

Definition at line 30 of file model.h.

◆ Canvas

friend class Canvas
friend

Definition at line 29 of file model.h.

◆ Object

friend class Object
friend

Definition at line 31 of file model.h.

Member Data Documentation

◆ defCamPos

Camera::Position GUI::RealSpace::Model::defCamPos

default camera params

Definition at line 52 of file model.h.

Referenced by RealSpaceBuilder::populate(), and GUI::RealSpace::Canvas::setCamera().

◆ objects

QVector<Object*> GUI::RealSpace::Model::objects
private

Definition at line 58 of file model.h.

Referenced by ~Model(), add(), clearOpaque(), draw(), modelIsEmpty(), releaseGeometries(), and rem().

◆ objectsBlend

QVector<Object*> GUI::RealSpace::Model::objectsBlend
private

Definition at line 58 of file model.h.

Referenced by ~Model(), addBlend(), clearBlend(), drawBlend(), modelIsEmpty(), releaseGeometries(), and rem().


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