Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CGoGN
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Thomas Pitiot
CGoGN
Commits
0994bb89
Commit
0994bb89
authored
Aug 11, 2011
by
Maire Nicolas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rajout d'un preset animé.
parent
cce1e8d4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
156 additions
and
17 deletions
+156
-17
Apps/Examples/clipping.cpp
Apps/Examples/clipping.cpp
+74
-15
Apps/Examples/clipping.ui
Apps/Examples/clipping.ui
+2
-2
include/Utils/clippingPresetsAnimated.h
include/Utils/clippingPresetsAnimated.h
+26
-0
src/Utils/clippingPresetsAnimated.cpp
src/Utils/clippingPresetsAnimated.cpp
+54
-0
No files found.
Apps/Examples/clipping.cpp
View file @
0994bb89
...
...
@@ -138,6 +138,10 @@ void Clipping::slot_explodTopoPhi3(double c)
void
Clipping
::
slot_pushButton_addPlane
()
{
// Check if no animation is active
if
(
m_lastAnimatedClippingPreset
!=
NULL
)
return
;
// Create clipping and pickable objects
unsigned
int
newPlaneId
=
m_shader
->
addClipPlane
();
Utils
::
Pickable
*
pickable
=
new
Utils
::
Pickable
(
m_planeDrawable
,
newPlaneId
);
...
...
@@ -176,6 +180,10 @@ void Clipping::slot_pushButton_changePlanesColor()
void
Clipping
::
slot_pushButton_addSphere
()
{
// Check if no animation is active
if
(
m_lastAnimatedClippingPreset
!=
NULL
)
return
;
// Create clipping and pickable objects
unsigned
int
newSphereId
=
m_shader
->
addClipSphere
();
Utils
::
Pickable
*
pickable
=
new
Utils
::
Pickable
(
m_sphereDrawable
,
newSphereId
);
...
...
@@ -247,6 +255,10 @@ void Clipping::slot_radioButton_ColorAttenuationMode(bool b)
void
Clipping
::
slot_pushButton_deleteSelectedObject
()
{
// Check if no animation is active
if
(
m_lastAnimatedClippingPreset
!=
NULL
)
return
;
if
(
m_lastPickedObject
)
{
// Delete clipping object
...
...
@@ -293,12 +305,16 @@ void Clipping::slot_pushButton_deleteSelectedObject()
void
Clipping
::
slot_pushButton_applyStaticClippingPreset
()
{
// Check if no animation is active
if
(
m_lastAnimatedClippingPreset
!=
NULL
)
return
;
// Create and apply preset
Utils
::
ClippingPreset
*
preset
=
NULL
;
switch
(
dock
.
comboBox_StaticClippingPresets
->
currentIndex
())
{
case
0
:
// Dual planes
{
{
using
namespace
CGoGN
::
Utils
::
QT
;
double
centerX
=
(
double
)
m_bb
.
center
()[
0
];
...
...
@@ -315,11 +331,11 @@ void Clipping::slot_pushButton_applyStaticClippingPreset()
VarBool
(
facing
,
"Facing"
)))))),
"Preset Setup"
))
preset
=
Utils
::
ClippingPreset
::
CreateDualPlanesPreset
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
(
float
)
size
,
axis
,
facing
);
}
break
;
}
break
;
case
1
:
// Cube
{
{
using
namespace
CGoGN
::
Utils
::
QT
;
double
centerX
=
(
double
)
m_bb
.
center
()[
0
];
...
...
@@ -334,11 +350,11 @@ void Clipping::slot_pushButton_applyStaticClippingPreset()
VarBool
(
facing
,
"Facing"
))))),
"Preset Setup"
))
preset
=
Utils
::
ClippingPreset
::
CreateCubePreset
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
(
float
)
size
,
facing
);
}
break
;
}
break
;
case
2
:
// Tube
{
{
using
namespace
CGoGN
::
Utils
::
QT
;
double
centerX
=
(
double
)
m_bb
.
center
()[
0
];
...
...
@@ -357,11 +373,11 @@ void Clipping::slot_pushButton_applyStaticClippingPreset()
VarBool
(
facing
,
"Facing"
))))))),
"Preset Setup"
))
preset
=
Utils
::
ClippingPreset
::
CreateTubePreset
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
(
float
)
size
,
axis
,
precision
,
facing
);
}
break
;
}
break
;
case
3
:
// Molecule
{
{
using
namespace
CGoGN
::
Utils
::
QT
;
double
centerX
=
(
double
)
m_bb
.
center
()[
0
];
...
...
@@ -378,8 +394,8 @@ void Clipping::slot_pushButton_applyStaticClippingPreset()
VarBool
(
orClipping
,
"OR clipping mode"
)))))),
"Preset Setup"
))
preset
=
Utils
::
ClippingPreset
::
CreateMoleculePreset
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
(
float
)
size
,
atomsRadiuses
,
orClipping
);
}
break
;
}
break
;
}
if
(
preset
==
NULL
)
...
...
@@ -429,12 +445,16 @@ void Clipping::slot_pushButton_applyStaticClippingPreset()
void
Clipping
::
slot_pushButton_applyAnimatedClippingPreset
()
{
// Check if no animation is active
if
(
m_lastAnimatedClippingPreset
!=
NULL
)
return
;
// Create and apply preset
Utils
::
ClippingPresetAnimated
*
animatedPreset
=
NULL
;
switch
(
dock
.
comboBox_AnimatedClippingPresets
->
currentIndex
())
{
case
0
:
// Moving Dual planes
{
{
Utils
::
ClippingPresetAnimatedDualPlanes
*
preset
=
NULL
;
using
namespace
CGoGN
::
Utils
::
QT
;
...
...
@@ -464,9 +484,29 @@ void Clipping::slot_pushButton_applyAnimatedClippingPreset()
(
float
)
size
,
axis
,
facing
,
zigzag
);
animatedPreset
=
preset
;
}
break
;
}
break
;
case
1
:
// Rotating Plane
{
Utils
::
ClippingPresetAnimatedRotatingPlane
*
preset
=
NULL
;
using
namespace
CGoGN
::
Utils
::
QT
;
double
centerX
=
(
double
)
m_bb
.
center
()[
0
];
double
centerY
=
(
double
)
m_bb
.
center
()[
1
];
double
centerZ
=
(
double
)
m_bb
.
center
()[
2
];
int
axis
=
0
;
if
(
inputValues
(
VarDbl
(
centerX
-
100.0
,
centerX
+
100.0
,
centerX
,
"Center X"
,
VarDbl
(
centerY
-
100.0
,
centerY
+
100.0
,
centerY
,
"Center Y"
,
VarDbl
(
centerZ
-
100.0
,
centerZ
+
100.0
,
centerZ
,
"Center Z"
,
VarSlider
(
0
,
2
,
axis
,
"Axis"
)))),
"Preset Setup"
))
preset
=
new
Utils
::
ClippingPresetAnimatedRotatingPlane
(
Geom
::
Vec3f
((
float
)
centerX
,
(
float
)
centerY
,
(
float
)
centerZ
),
axis
);
animatedPreset
=
preset
;
}
break
;
}
...
...
@@ -651,6 +691,7 @@ void Clipping::initGUI()
setCallBack
(
dock
.
PushButton_ApplyAnimatedClippingPreset
,
SIGNAL
(
clicked
()),
SLOT
(
slot_pushButton_applyAnimatedClippingPreset
()));
dock
.
comboBox_AnimatedClippingPresets
->
addItem
(
"Moving Dual Planes"
);
dock
.
comboBox_AnimatedClippingPresets
->
addItem
(
"Rotating Plane"
);
setCallBack
(
dock
.
pushButton_StopAnimation
,
SIGNAL
(
clicked
()),
SLOT
(
slot_pushButton_StopAnimation
()));
setCallBack
(
dock
.
doubleSpinBox_AnimatedClippingPresetSpeed
,
SIGNAL
(
valueChanged
(
double
)),
SLOT
(
slot_doubleSpinBox_AnimatedClippingPresetSpeed
(
double
)));
...
...
@@ -832,11 +873,25 @@ void Clipping::cb_keyPress(int code)
case
16777223
:
// Suppr
slot_pushButton_deleteSelectedObject
();
break
;
case
'+'
:
dock
.
doubleSpinBox_AnimatedClippingPresetSpeed
->
setValue
(
dock
.
doubleSpinBox_AnimatedClippingPresetSpeed
->
value
()
+
0.1
);
break
;
case
'-'
:
dock
.
doubleSpinBox_AnimatedClippingPresetSpeed
->
setValue
(
dock
.
doubleSpinBox_AnimatedClippingPresetSpeed
->
value
()
-
0.1
);
break
;
}
}
void
Clipping
::
cb_mousePress
(
int
button
,
int
x
,
int
y
)
{
// Check if no animation is active
if
(
m_lastAnimatedClippingPreset
!=
NULL
)
return
;
if
(
!
Shift
())
return
;
...
...
@@ -889,6 +944,10 @@ void Clipping::cb_mousePress(int button, int x, int y)
void
Clipping
::
cb_mouseMove
(
int
buttons
,
int
x
,
int
y
)
{
// Check if no animation is active
if
(
m_lastAnimatedClippingPreset
!=
NULL
)
return
;
if
(
!
Shift
())
return
;
...
...
Apps/Examples/clipping.ui
View file @
0994bb89
...
...
@@ -454,10 +454,10 @@
<item>
<widget
class=
"QDoubleSpinBox"
name=
"doubleSpinBox_AnimatedClippingPresetSpeed"
>
<property
name=
"minimum"
>
<double>
-10.000000000000000
</double>
<double>
-10
0
.000000000000000
</double>
</property>
<property
name=
"maximum"
>
<double>
10.000000000000000
</double>
<double>
10
0
.000000000000000
</double>
</property>
<property
name=
"singleStep"
>
<double>
0.100000000000000
</double>
...
...
include/Utils/clippingPresetsAnimated.h
View file @
0994bb89
...
...
@@ -28,6 +28,7 @@
#include "Utils/clippingPresets.h"
#include "Utils/clippingShader.h"
#include "Geometry/vector_gen.h"
#include <cmath>
namespace
CGoGN
{
...
...
@@ -154,6 +155,31 @@ private :
};
class
ClippingPresetAnimatedRotatingPlane
:
public
ClippingPresetAnimated
{
public
:
/**
* constructor
* @param center center of plane
* @param axis axis on which plane is aligned (0 for x, 1 for y, 2 for z)
*/
ClippingPresetAnimatedRotatingPlane
(
Geom
::
Vec3f
center
,
int
axis
);
/**
* runs the animation some steps further
* @param amount amount of steps the animation should do
*/
void
step
(
unsigned
int
amount
);
private
:
/// axis of plane
int
m_axis
;
};
}
// namespace Utils
...
...
src/Utils/clippingPresetsAnimated.cpp
View file @
0994bb89
...
...
@@ -158,6 +158,60 @@ void ClippingPresetAnimatedDualPlanes::step(unsigned int amount)
m_attachedClippingShader
->
setClipPlaneParamsOrigin
(
m_planesIds
[
1
],
plane2CurrPos
+
newCenter
-
oldCenter
);
}
ClippingPresetAnimatedRotatingPlane
::
ClippingPresetAnimatedRotatingPlane
(
Geom
::
Vec3f
center
,
int
axis
)
{
// Correct axis if necessary and store it
if
((
axis
<
0
)
||
(
axis
>
2
))
axis
=
0
;
m_axis
=
axis
;
// Axis on which planes will be aligned
Geom
::
Vec3f
normal
(
0.0
f
,
0.0
f
,
0.0
f
);
normal
[(
axis
+
1
)
%
3
]
=
1.0
f
;
// Add plane to preset
addClipPlane
(
normal
,
center
);
// Set clipping mode
setClippingMode
(
ClippingShader
::
CLIPPING_MODE_AND
);
}
void
ClippingPresetAnimatedRotatingPlane
::
step
(
unsigned
int
amount
)
{
// Check if the animation has been stopped
if
(
m_animationSpeedFactor
==
0.0
f
)
return
;
// Check the validity of planes or spheres ids
if
(
!
m_attachedClippingShader
->
isClipPlaneIdValid
(
m_planesIds
[
0
]))
{
CGoGNerr
<<
"ERROR -"
<<
"ClippingPresetAnimatedDualPlanes::step"
<<
" - Some planes or spheres ids are not valid anymore - Animation stopped"
<<
CGoGNendl
;
m_animationSpeedFactor
=
0.0
f
;
return
;
}
// Update animation parameter value
m_animParam
+=
(
float
)
amount
*
m_animationOneStepIncrement
*
m_animationSpeedFactor
;
while
(
m_animParam
<
0.0
f
)
m_animParam
+=
1.0
f
;
while
(
m_animParam
>
1.0
f
)
m_animParam
-=
1.0
f
;
// Calculate new normal
Geom
::
Vec3f
planeNormal
=
m_attachedClippingShader
->
getClipPlaneParamsNormal
(
m_planesIds
[
0
]);
float
angle
=
m_animParam
*
2.0
*
M_PI
;
planeNormal
[(
m_axis
+
1
)
%
3
]
=
cos
(
angle
);
planeNormal
[(
m_axis
+
2
)
%
3
]
=
sin
(
angle
);
m_attachedClippingShader
->
setClipPlaneParamsNormal
(
m_planesIds
[
0
],
planeNormal
);
}
}
// namespace Utils
}
// namespace CGoGN
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment