Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
28fb7616
Commit
28fb7616
authored
2 years ago
by
Mikhail Svechnikov
Browse files
Options
Downloads
Patches
Plain Diff
RotationItems: refactor inheritance and interfaces
parent
0a973db4
No related branches found
No related tags found
1 merge request
!1157
GUI: DoubleDescriptor interfaces ---> DoubleProperty interfaces
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/Model/FromCore/ItemizeSample.cpp
+6
-6
6 additions, 6 deletions
GUI/Model/FromCore/ItemizeSample.cpp
GUI/Model/Sample/RotationItems.cpp
+11
-49
11 additions, 49 deletions
GUI/Model/Sample/RotationItems.cpp
GUI/Model/Sample/RotationItems.h
+15
-25
15 additions, 25 deletions
GUI/Model/Sample/RotationItems.h
with
32 additions
and
80 deletions
GUI/Model/FromCore/ItemizeSample.cpp
+
6
−
6
View file @
28fb7616
...
@@ -325,21 +325,21 @@ void setRotation(ItemWithParticles* parent, const IRotation* rotation)
...
@@ -325,21 +325,21 @@ void setRotation(ItemWithParticles* parent, const IRotation* rotation)
parent
->
setRotation
(
nullptr
);
parent
->
setRotation
(
nullptr
);
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationX
*>
(
rotation
))
{
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationX
*>
(
rotation
))
{
auto
*
item
=
new
XRotationItem
();
auto
*
item
=
new
XRotationItem
();
item
->
angle
().
set
(
Units
::
rad2deg
(
r
->
angle
()));
item
->
setAngle
(
Units
::
rad2deg
(
r
->
angle
()));
parent
->
setRotation
(
item
);
parent
->
setRotation
(
item
);
}
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationY
*>
(
rotation
))
{
}
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationY
*>
(
rotation
))
{
auto
*
item
=
new
YRotationItem
();
auto
*
item
=
new
YRotationItem
();
item
->
angle
().
set
(
Units
::
rad2deg
(
r
->
angle
()));
item
->
setAngle
(
Units
::
rad2deg
(
r
->
angle
()));
parent
->
setRotation
(
item
);
parent
->
setRotation
(
item
);
}
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationZ
*>
(
rotation
))
{
}
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationZ
*>
(
rotation
))
{
auto
*
item
=
new
ZRotationItem
();
auto
*
item
=
new
ZRotationItem
();
item
->
angle
().
set
(
Units
::
rad2deg
(
r
->
angle
()));
item
->
setAngle
(
Units
::
rad2deg
(
r
->
angle
()));
parent
->
setRotation
(
item
);
parent
->
setRotation
(
item
);
}
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationEuler
*>
(
rotation
))
{
}
else
if
(
const
auto
*
r
=
dynamic_cast
<
const
RotationEuler
*>
(
rotation
))
{
auto
*
item
=
new
EulerRotationItem
();
auto
*
item
=
new
EulerRotationItem
();
item
->
alpha
().
set
(
Units
::
rad2deg
(
r
->
alpha
()));
item
->
setAlpha
(
Units
::
rad2deg
(
r
->
alpha
()));
item
->
b
et
a
().
s
et
(
Units
::
rad2deg
(
r
->
beta
()));
item
->
s
et
B
et
a
(
Units
::
rad2deg
(
r
->
beta
()));
item
->
gamma
().
set
(
Units
::
rad2deg
(
r
->
gamma
()));
item
->
setGamma
(
Units
::
rad2deg
(
r
->
gamma
()));
parent
->
setRotation
(
item
);
parent
->
setRotation
(
item
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
GUI/Model/Sample/RotationItems.cpp
+
11
−
49
View file @
28fb7616
...
@@ -43,25 +43,23 @@ RotMatrix RotationItem::rotation() const
...
@@ -43,25 +43,23 @@ RotMatrix RotationItem::rotation() const
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
XRotationItem
::
XRotationItem
()
{
m_angle
.
init
(
"Angle"
,
"Rotation angle around x-axis"
,
0.0
,
Unit
::
degree
,
"angle"
);
}
void
XRotationItem
::
serialize
(
Streamer
&
s
)
void
X
YZ
RotationItem
::
serialize
(
Streamer
&
s
)
{
{
s
.
assertVersion
(
0
);
s
.
assertVersion
(
0
);
Serialize
::
rwProperty
(
s
,
Tag
::
Angle
,
m_angle
);
Serialize
::
rwProperty
(
s
,
Tag
::
Angle
,
m_angle
);
}
}
unique_ptr
<
IRotation
>
XRotationItem
::
createRotation
()
const
// ----------------------------------------------------------------------------
XRotationItem
::
XRotationItem
()
{
{
return
std
::
make_unique
<
RotationX
>
(
deg2rad
(
angle
())
);
m_angle
.
init
(
"Angle"
,
"Rotation angle around x-axis"
,
0.0
,
Unit
::
degree
,
"
angle
"
);
}
}
DoubleDescriptor
XRotationItem
::
angle
()
const
unique_ptr
<
IRotation
>
XRotationItem
::
createRotation
()
const
{
{
return
m_angle
;
return
std
::
make_unique
<
RotationX
>
(
deg2rad
(
m_angle
.
get
()))
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -71,20 +69,9 @@ YRotationItem::YRotationItem()
...
@@ -71,20 +69,9 @@ YRotationItem::YRotationItem()
m_angle
.
init
(
"Angle"
,
"Rotation angle around y-axis"
,
0.0
,
Unit
::
degree
,
"angle"
);
m_angle
.
init
(
"Angle"
,
"Rotation angle around y-axis"
,
0.0
,
Unit
::
degree
,
"angle"
);
}
}
void
YRotationItem
::
serialize
(
Streamer
&
s
)
{
s
.
assertVersion
(
0
);
Serialize
::
rwProperty
(
s
,
Tag
::
Angle
,
m_angle
);
}
unique_ptr
<
IRotation
>
YRotationItem
::
createRotation
()
const
unique_ptr
<
IRotation
>
YRotationItem
::
createRotation
()
const
{
{
return
std
::
make_unique
<
RotationY
>
(
deg2rad
(
angle
()));
return
std
::
make_unique
<
RotationY
>
(
deg2rad
(
m_angle
.
get
()));
}
DoubleDescriptor
YRotationItem
::
angle
()
const
{
return
m_angle
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -94,20 +81,9 @@ ZRotationItem::ZRotationItem()
...
@@ -94,20 +81,9 @@ ZRotationItem::ZRotationItem()
m_angle
.
init
(
"Angle"
,
"Rotation angle around z-axis"
,
0.0
,
Unit
::
degree
,
"angle"
);
m_angle
.
init
(
"Angle"
,
"Rotation angle around z-axis"
,
0.0
,
Unit
::
degree
,
"angle"
);
}
}
void
ZRotationItem
::
serialize
(
Streamer
&
s
)
{
s
.
assertVersion
(
0
);
Serialize
::
rwProperty
(
s
,
Tag
::
Angle
,
m_angle
);
}
unique_ptr
<
IRotation
>
ZRotationItem
::
createRotation
()
const
unique_ptr
<
IRotation
>
ZRotationItem
::
createRotation
()
const
{
{
return
std
::
make_unique
<
RotationZ
>
(
deg2rad
(
angle
()));
return
std
::
make_unique
<
RotationZ
>
(
deg2rad
(
m_angle
.
get
()));
}
DoubleDescriptor
ZRotationItem
::
angle
()
const
{
return
m_angle
;
}
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
...
@@ -129,20 +105,6 @@ void EulerRotationItem::serialize(Streamer& s)
...
@@ -129,20 +105,6 @@ void EulerRotationItem::serialize(Streamer& s)
unique_ptr
<
IRotation
>
EulerRotationItem
::
createRotation
()
const
unique_ptr
<
IRotation
>
EulerRotationItem
::
createRotation
()
const
{
{
return
std
::
make_unique
<
RotationEuler
>
(
deg2rad
(
alpha
()),
deg2rad
(
beta
()),
deg2rad
(
gamma
()));
return
std
::
make_unique
<
RotationEuler
>
(
deg2rad
(
m_alpha
.
get
()),
deg2rad
(
m_beta
.
get
()),
}
deg2rad
(
m_gamma
.
get
()));
DoubleDescriptor
EulerRotationItem
::
alpha
()
const
{
return
m_alpha
;
}
DoubleDescriptor
EulerRotationItem
::
beta
()
const
{
return
m_beta
;
}
DoubleDescriptor
EulerRotationItem
::
gamma
()
const
{
return
m_gamma
;
}
}
This diff is collapsed.
Click to expand it.
GUI/Model/Sample/RotationItems.h
+
15
−
25
View file @
28fb7616
...
@@ -36,49 +36,39 @@ protected:
...
@@ -36,49 +36,39 @@ protected:
virtual
unique_ptr
<
IRotation
>
createRotation
()
const
=
0
;
virtual
unique_ptr
<
IRotation
>
createRotation
()
const
=
0
;
};
};
class
XRotationItem
:
public
RotationItem
{
class
X
YZ
RotationItem
:
public
RotationItem
{
public:
public:
XRotationItem
();
void
serialize
(
Streamer
&
s
)
override
;
void
serialize
(
Streamer
&
s
)
override
;
DoubleDescriptors
rotationValues
()
const
override
{
return
{
m_angle
};
};
DoubleDescriptors
rotationValues
()
const
override
{
return
{
m_angle
};
};
DoubleDescriptor
angle
()
const
;
void
setAngle
(
double
v
)
{
m_angle
.
set
(
v
);
}
protected
:
protected
:
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
private
:
DoubleProperty
m_angle
;
DoubleProperty
m_angle
;
};
};
class
Y
RotationItem
:
public
RotationItem
{
class
X
RotationItem
:
public
XYZ
RotationItem
{
public:
public:
YRotationItem
();
XRotationItem
();
void
serialize
(
Streamer
&
s
)
override
;
DoubleDescriptors
rotationValues
()
const
override
{
return
{
m_angle
};
};
DoubleDescriptor
angle
()
const
;
protected:
protected:
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
};
private
:
class
YRotationItem
:
public
XYZRotationItem
{
DoubleProperty
m_angle
;
public:
YRotationItem
();
protected:
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
};
};
class
ZRotationItem
:
public
RotationItem
{
class
ZRotationItem
:
public
XYZ
RotationItem
{
public:
public:
ZRotationItem
();
ZRotationItem
();
void
serialize
(
Streamer
&
s
)
override
;
DoubleDescriptors
rotationValues
()
const
override
{
return
{
m_angle
};
};
DoubleDescriptor
angle
()
const
;
protected:
protected:
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
private
:
DoubleProperty
m_angle
;
};
};
class
EulerRotationItem
:
public
RotationItem
{
class
EulerRotationItem
:
public
RotationItem
{
...
@@ -87,9 +77,9 @@ public:
...
@@ -87,9 +77,9 @@ public:
void
serialize
(
Streamer
&
s
)
override
;
void
serialize
(
Streamer
&
s
)
override
;
DoubleDescriptors
rotationValues
()
const
override
{
return
{
m_alpha
,
m_beta
,
m_gamma
};
};
DoubleDescriptors
rotationValues
()
const
override
{
return
{
m_alpha
,
m_beta
,
m_gamma
};
};
DoubleDescriptor
alpha
()
const
;
void
setAlpha
(
double
v
)
{
m_alpha
.
set
(
v
);
}
DoubleDescriptor
beta
()
const
;
void
setBeta
(
double
v
)
{
m_beta
.
set
(
v
);
}
DoubleDescriptor
gamma
()
const
;
void
setGamma
(
double
v
)
{
m_gamma
.
set
(
v
);
}
protected
:
protected
:
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
unique_ptr
<
IRotation
>
createRotation
()
const
override
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment