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

Description

A geometric object.

Definition at line 28 of file object.h.

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

Public Member Functions

 Object (GeometricID::Key)
 
virtual ~Object ()
 
void addExtrinsicRotation (Vector3D turn, Vector3D scale, Vector3D &rotate, Vector3D rotateExtrinsic, Vector3D &translate)
 
void transform (float scale, Vector3D rotate, Vector3D translate)
 
void transform (Vector3D scale, QQuaternion, Vector3D translate)
 
void transform (Vector3D scale, Vector3D rotate, Vector3D translate)
 
void transform (Vector3D turn, Vector3D scale, Vector3D rotate, Vector3D translate)
 

Public Attributes

QColor color
 

Protected Attributes

bool isNull
 

Private Member Functions

void draw (Canvas &)
 
void releaseGeometry ()
 

Private Attributes

GeometryHandle geo
 
GeometricID::Key gky
 
QMatrix4x4 mat
 
Modelmodel
 

Friends

class Model
 

Constructor & Destructor Documentation

◆ Object()

GUI::RealSpace::Object::Object ( GeometricID::Key  gky_)

Definition at line 36 of file object.cpp.

37  : color(clrObject)
38  , isNull(false)
39  , model(nullptr)
40  , gky(gky_)
41 {
42 }
GeometricID::Key gky
Definition: object.h:51
QColor const clrObject
Definition: object.cpp:33

◆ ~Object()

GUI::RealSpace::Object::~Object ( )
virtual

Definition at line 44 of file object.cpp.

45 {
47  if (model)
48  model->rem(this);
49 }
void rem(Object *)
removes an object, the caller becomes responsible
Definition: model.cpp:144

References model, releaseGeometry(), and GUI::RealSpace::Model::rem().

Here is the call graph for this function:

Member Function Documentation

◆ addExtrinsicRotation()

void GUI::RealSpace::Object::addExtrinsicRotation ( Vector3D  turn,
Vector3D  scale,
Vector3D rotate,
Vector3D  rotateExtrinsic,
Vector3D translate 
)

Definition at line 79 of file object.cpp.

81 {
82  mat.setToIdentity();
83  mat.rotate(EulerToQuaternion(rotateExtrinsic));
84  mat.translate(translate);
85  mat.rotate(EulerToQuaternion(rotate));
86  mat.scale(scale);
87  mat.rotate(EulerToQuaternion(turn));
88 
89  // first apply the particle's intrinsic and then extrinsic rotations
90  QQuaternion q = EulerToQuaternion(rotateExtrinsic) * EulerToQuaternion(rotate);
91  rotate = QuaternionToEuler(q);
92 
93  // translate the object to the extrinsically rotated translation vector
94  translate = EulerToQuaternion(rotateExtrinsic).rotatedVector(translate);
95 }
QMatrix4x4 mat
Definition: object.h:55

References mat.

Referenced by GUI::RealSpace::Particles::Particle::addExtrinsicRotation().

◆ draw()

void GUI::RealSpace::Object::draw ( Canvas canvas)
private

Definition at line 102 of file object.cpp.

103 {
104  if (isNull)
105  return;
106 
107  if (!geo)
109  canvas.draw(color, mat, *geo);
110 }
GeometryHandle getGeometry(GeometricID::Key)
Definition: geometry.cpp:158
GeometryHandle geo
Definition: object.h:52
GeometryStore & geometryStore()
Definition: geometry.cpp:176

References color, GUI::RealSpace::Canvas::draw(), geo, GUI::RealSpace::geometryStore(), GUI::RealSpace::GeometryStore::getGeometry(), gky, isNull, and mat.

Here is the call graph for this function:

◆ releaseGeometry()

void GUI::RealSpace::Object::releaseGeometry ( )
private

Definition at line 97 of file object.cpp.

98 {
99  geo.reset();
100 }

References geo.

Referenced by ~Object(), and GUI::RealSpace::Model::rem().

◆ transform() [1/4]

void GUI::RealSpace::Object::transform ( float  scale,
Vector3D  rotate,
Vector3D  translate 
)

Definition at line 51 of file object.cpp.

52 {
53  transform(Vector3D(scale, scale, scale), rotate, translate);
54 }
void transform(float scale, Vector3D rotate, Vector3D translate)
Definition: object.cpp:51

Referenced by GUI::RealSpace::Layer::Layer(), GUI::RealSpace::Particles::Particle::addTransform(), GUI::RealSpace::Particles::Particle::addTranslation(), GUI::RealSpace::Particles::Particle::fancy(), and GUI::RealSpace::Particles::Particle::transform().

◆ transform() [2/4]

void GUI::RealSpace::Object::transform ( Vector3D  scale,
QQuaternion  ,
Vector3D  translate 
)

◆ transform() [3/4]

void GUI::RealSpace::Object::transform ( Vector3D  scale,
Vector3D  rotate,
Vector3D  translate 
)

Definition at line 56 of file object.cpp.

57 {
58  mat.setToIdentity();
59  mat.translate(translate);
60  mat.rotate(EulerToQuaternion(rotate));
61  mat.scale(scale);
62 }

References mat.

◆ transform() [4/4]

void GUI::RealSpace::Object::transform ( Vector3D  turn,
Vector3D  scale,
Vector3D  rotate,
Vector3D  translate 
)

Definition at line 64 of file object.cpp.

65 {
66  // 1. turn to align with x/y/z as needed
67  // 2. scale to desired x/y/z size
68  // 3. rotate as needed by the scene
69  // 4. move to the position
70  mat.setToIdentity();
71  mat.translate(translate);
72  mat.rotate(EulerToQuaternion(rotate));
73  mat.scale(scale);
74  mat.rotate(EulerToQuaternion(turn));
75 }

References mat.

Friends And Related Function Documentation

◆ Model

friend class Model
friend

Definition at line 29 of file object.h.

Member Data Documentation

◆ color

QColor GUI::RealSpace::Object::color

Definition at line 35 of file object.h.

Referenced by GUI::RealSpace::BuilderUtils::applyParticleColor(), and draw().

◆ geo

GeometryHandle GUI::RealSpace::Object::geo
private

Definition at line 52 of file object.h.

Referenced by draw(), and releaseGeometry().

◆ gky

GeometricID::Key GUI::RealSpace::Object::gky
private

Definition at line 51 of file object.h.

Referenced by draw().

◆ isNull

bool GUI::RealSpace::Object::isNull
protected

Definition at line 46 of file object.h.

Referenced by GUI::RealSpace::Particles::BarGauss::BarGauss(), GUI::RealSpace::Particles::BarLorentz::BarLorentz(), GUI::RealSpace::Particles::Bipyramid4::Bipyramid4(), GUI::RealSpace::Particles::Box::Box(), GUI::RealSpace::Particles::CantellatedCube::CantellatedCube(), GUI::RealSpace::Particles::Cone::Cone(), GUI::RealSpace::Particles::CosineRippleBox::CosineRippleBox(), GUI::RealSpace::Particles::CosineRippleGauss::CosineRippleGauss(), GUI::RealSpace::Particles::CosineRippleLorentz::CosineRippleLorentz(), GUI::RealSpace::Particles::Cylinder::Cylinder(), GUI::RealSpace::Particles::Dodecahedron::Dodecahedron(), GUI::RealSpace::Particles::EllipsoidalCylinder::EllipsoidalCylinder(), GUI::RealSpace::Particles::HemiEllipsoid::HemiEllipsoid(), GUI::RealSpace::Particles::HorizontalCylinder::HorizontalCylinder(), GUI::RealSpace::Particles::Icosahedron::Icosahedron(), GUI::RealSpace::Particles::PlatonicOctahedron::PlatonicOctahedron(), GUI::RealSpace::Particles::PlatonicTetrahedron::PlatonicTetrahedron(), GUI::RealSpace::Particles::Prism3::Prism3(), GUI::RealSpace::Particles::Prism6::Prism6(), GUI::RealSpace::Particles::Pyramid2::Pyramid2(), GUI::RealSpace::Particles::Pyramid3::Pyramid3(), GUI::RealSpace::Particles::Pyramid4::Pyramid4(), GUI::RealSpace::Particles::Pyramid6::Pyramid6(), GUI::RealSpace::Particles::SawtoothRippleBox::SawtoothRippleBox(), GUI::RealSpace::Particles::SawtoothRippleGauss::SawtoothRippleGauss(), GUI::RealSpace::Particles::SawtoothRippleLorentz::SawtoothRippleLorentz(), GUI::RealSpace::Particles::Sphere::Sphere(), GUI::RealSpace::Particles::Spheroid::Spheroid(), GUI::RealSpace::Particles::TruncatedCube::TruncatedCube(), GUI::RealSpace::Particles::TruncatedSphere::TruncatedSphere(), GUI::RealSpace::Particles::TruncatedSpheroid::TruncatedSpheroid(), and draw().

◆ mat

QMatrix4x4 GUI::RealSpace::Object::mat
private

Definition at line 55 of file object.h.

Referenced by addExtrinsicRotation(), draw(), and transform().

◆ model

Model* GUI::RealSpace::Object::model
private

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