BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
RealSpace::Object Class Reference
Inheritance diagram for RealSpace::Object:
[legend]
Collaboration diagram for 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
 

Detailed Description

Definition at line 27 of file object.h.

Constructor & Destructor Documentation

◆ Object()

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

Definition at line 34 of file object.cpp.

34  : color(clrObject), isNull(false), model(nullptr), gky(gky_)
35 {
36 }
Model * model
Definition: object.h:48
GeometricID::Key gky
Definition: object.h:50
QColor color
Definition: object.h:34
QColor const clrObject
Definition: object.cpp:31

◆ ~Object()

RealSpace::Object::~Object ( )
virtual

Definition at line 38 of file object.cpp.

39 {
41  if (model)
42  model->rem(this);
43 }
void rem(Object *)
Definition: model.cpp:135
void releaseGeometry()
Definition: object.cpp:91

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

Here is the call graph for this function:

Member Function Documentation

◆ addExtrinsicRotation()

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

Definition at line 73 of file object.cpp.

75 {
76  mat.setToIdentity();
77  mat.rotate(EulerToQuaternion(rotateExtrinsic));
78  mat.translate(translate);
79  mat.rotate(EulerToQuaternion(rotate));
80  mat.scale(scale);
81  mat.rotate(EulerToQuaternion(turn));
82 
83  // first apply the particle's intrinsic and then extrinsic rotations
84  QQuaternion q = EulerToQuaternion(rotateExtrinsic) * EulerToQuaternion(rotate);
85  rotate = QuaternionToEuler(q);
86 
87  // translate the object to the extrinsically rotated translation vector
88  translate = EulerToQuaternion(rotateExtrinsic).rotatedVector(translate);
89 }
QMatrix4x4 mat
Definition: object.h:54

References mat.

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

◆ draw()

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

Definition at line 96 of file object.cpp.

97 {
98  if (isNull)
99  return;
100 
101  if (!geo)
103  canvas.draw(color, mat, *geo);
104 }
GeometryHandle getGeometry(GeometricID::Key)
Definition: geometry.cpp:148
GeometryHandle geo
Definition: object.h:51
GeometryStore & geometryStore()
Definition: geometry.cpp:166

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

Here is the call graph for this function:

◆ releaseGeometry()

void RealSpace::Object::releaseGeometry ( )
private

Definition at line 91 of file object.cpp.

92 {
93  geo.reset();
94 }

References geo.

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

◆ transform() [1/4]

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

Definition at line 45 of file object.cpp.

46 {
47  transform(Vector3D(scale, scale, scale), rotate, translate);
48 }
void transform(float scale, Vector3D rotate, Vector3D translate)
Definition: object.cpp:45

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

◆ transform() [2/4]

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

◆ transform() [3/4]

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

Definition at line 50 of file object.cpp.

51 {
52  mat.setToIdentity();
53  mat.translate(translate);
54  mat.rotate(EulerToQuaternion(rotate));
55  mat.scale(scale);
56 }

References mat.

◆ transform() [4/4]

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

Definition at line 58 of file object.cpp.

59 {
60  // 1. turn to align with x/y/z as needed
61  // 2. scale to desired x/y/z size
62  // 3. rotate as needed by the scene
63  // 4. move to the position
64  mat.setToIdentity();
65  mat.translate(translate);
66  mat.rotate(EulerToQuaternion(rotate));
67  mat.scale(scale);
68  mat.rotate(EulerToQuaternion(turn));
69 }

References mat.

Friends And Related Function Documentation

◆ Model

friend class Model
friend

Definition at line 28 of file object.h.

Member Data Documentation

◆ color

QColor RealSpace::Object::color

Definition at line 34 of file object.h.

Referenced by RealSpaceBuilderUtils::applyParticleColor(), and draw().

◆ geo

GeometryHandle RealSpace::Object::geo
private

Definition at line 51 of file object.h.

Referenced by draw(), and releaseGeometry().

◆ gky

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

Definition at line 50 of file object.h.

Referenced by draw().

◆ isNull

bool RealSpace::Object::isNull
protected

◆ mat

QMatrix4x4 RealSpace::Object::mat
private

Definition at line 54 of file object.h.

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

◆ model

Model* RealSpace::Object::model
private

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