Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
7dd5fd61
Commit
7dd5fd61
authored
Oct 26, 2011
by
Pierre Kraemer
Browse files
diverses petites modifs..
parent
4eff38ed
Changes
11
Hide whitespace changes
Inline
Side-by-side
include/Algo/Geometry/curvature.hpp
View file @
7dd5fd61
...
...
@@ -117,12 +117,12 @@ void computeCurvatureVertex_QuadraticFitting(
template
<
typename
PFP
>
void
vertexQuadraticFitting
(
typename
PFP
::
MAP
&
map
,
Dart
dart
,
typename
PFP
::
MATRIX33
&
localFrame
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
float
&
a
,
float
&
b
,
float
&
c
,
float
&
d
,
float
&
e
)
typename
PFP
::
MAP
&
map
,
Dart
dart
,
typename
PFP
::
MATRIX33
&
localFrame
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
,
float
&
a
,
float
&
b
,
float
&
c
,
float
&
d
,
float
&
e
)
{
typename
PFP
::
VEC3
p
=
position
[
dart
]
;
...
...
@@ -352,7 +352,7 @@ void computeCurvatureVertex_NormalCycles(
const
std
::
vector
<
Dart
>&
vd1
=
neigh
.
getInsideEdges
()
;
for
(
std
::
vector
<
Dart
>::
const_iterator
it
=
vd1
.
begin
();
it
!=
vd1
.
end
();
++
it
)
{
const
VEC3
e
=
position
[
map
.
phi2
(
*
it
)]
-
position
[
*
it
]
;
const
VEC3
e
=
Algo
::
Geometry
::
vectorOutOfDart
<
PFP
>
(
map
,
*
it
,
position
)
;
tensor
+=
Geom
::
transposed_vectors_mult
(
e
,
e
)
*
edgeangle
[
*
it
]
*
(
1
/
e
.
norm
())
;
}
// border
...
...
include/Algo/Geometry/feature.h
View file @
7dd5fd61
...
...
@@ -38,7 +38,7 @@ template <typename PFP>
void
featureEdgeDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
CellMarker
&
featureEdge
)
;
template
<
typename
PFP
>
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
viewDir
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
;
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
cameraPosition
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
;
}
// namespace Geometry
...
...
include/Algo/Geometry/feature.hpp
View file @
7dd5fd61
...
...
@@ -62,7 +62,7 @@ void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position,
}
template
<
typename
PFP
>
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
viewDir
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
std
::
vector
<
typename
PFP
::
VEC3
>
occludingContoursDetection
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
VEC3
&
cameraPosition
,
const
typename
PFP
::
TVEC3
&
position
,
const
typename
PFP
::
TVEC3
&
normal
)
{
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
typename
PFP
::
REAL
REAL
;
...
...
@@ -75,38 +75,44 @@ std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& ma
if
(
!
m
.
isMarked
(
d
))
{
m
.
mark
(
d
)
;
REAL
dp1
=
viewDir
*
normal
[
d
]
;
REAL
dp2
=
viewDir
*
normal
[
map
.
phi1
(
d
)]
;
REAL
dp3
=
viewDir
*
normal
[
map
.
phi_1
(
d
)]
;
VEC3
p1
=
position
[
d
]
;
VEC3
p2
=
position
[
map
.
phi1
(
d
)]
;
VEC3
p3
=
position
[
map
.
phi_1
(
d
)]
;
REAL
dp1
=
(
p1
-
cameraPosition
)
*
normal
[
d
]
;
REAL
dp2
=
(
p2
-
cameraPosition
)
*
normal
[
map
.
phi1
(
d
)]
;
REAL
dp3
=
(
p3
-
cameraPosition
)
*
normal
[
map
.
phi_1
(
d
)]
;
if
(
dp1
<
0
&&
dp2
>
0
)
{
REAL
alpha
=
-
dp1
/
(
-
dp1
+
dp2
)
;
occludingContours
.
push_back
(
alpha
*
p
osition
[
d
]
+
(
1
-
alpha
)
*
p
osition
[
map
.
phi1
(
d
)]
)
;
occludingContours
.
push_back
(
alpha
*
p
1
+
(
1
-
alpha
)
*
p
2
)
;
}
if
(
dp2
<
0
&&
dp1
>
0
)
{
REAL
alpha
=
dp1
/
(
dp1
-
dp2
)
;
occludingContours
.
push_back
(
alpha
*
p
osition
[
d
]
+
(
1
-
alpha
)
*
p
osition
[
map
.
phi1
(
d
)]
)
;
occludingContours
.
push_back
(
alpha
*
p
1
+
(
1
-
alpha
)
*
p
2
)
;
}
if
(
dp1
<
0
&&
dp3
>
0
)
{
REAL
alpha
=
-
dp1
/
(
-
dp1
+
dp3
)
;
occludingContours
.
push_back
(
alpha
*
p
osition
[
d
]
+
(
1
-
alpha
)
*
p
osition
[
map
.
phi_1
(
d
)]
)
;
occludingContours
.
push_back
(
alpha
*
p
1
+
(
1
-
alpha
)
*
p
3
)
;
}
if
(
dp3
<
0
&&
dp1
>
0
)
{
REAL
alpha
=
dp1
/
(
dp1
-
dp3
)
;
occludingContours
.
push_back
(
alpha
*
p
osition
[
d
]
+
(
1
-
alpha
)
*
p
osition
[
map
.
phi_1
(
d
)]
)
;
occludingContours
.
push_back
(
alpha
*
p
1
+
(
1
-
alpha
)
*
p
3
)
;
}
if
(
dp2
<
0
&&
dp3
>
0
)
{
REAL
alpha
=
-
dp2
/
(
-
dp2
+
dp3
)
;
occludingContours
.
push_back
(
alpha
*
p
osition
[
map
.
phi1
(
d
)]
+
(
1
-
alpha
)
*
position
[
map
.
phi_1
(
d
)]
)
;
occludingContours
.
push_back
(
alpha
*
p
2
+
(
1
-
alpha
)
*
p3
)
;
}
if
(
dp3
<
0
&&
dp2
>
0
)
{
REAL
alpha
=
dp2
/
(
dp2
-
dp3
)
;
occludingContours
.
push_back
(
alpha
*
p
osition
[
map
.
phi1
(
d
)]
+
(
1
-
alpha
)
*
position
[
map
.
phi_1
(
d
)]
)
;
occludingContours
.
push_back
(
alpha
*
p
2
+
(
1
-
alpha
)
*
p3
)
;
}
}
}
...
...
include/Algo/Geometry/normal.hpp
View file @
7dd5fd61
...
...
@@ -84,7 +84,7 @@ typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const typename PFP
{
VEC3
n
=
triangleNormal
<
PFP
>
(
map
,
it
,
position
)
;
//if(!std::isnan(n[0]) && !std::isnan(n[1]) && !std::isnan(n[2]))
if
(
n
[
0
]
==
n
[
0
]
&&
n
[
1
]
==
n
[
1
]
&&
n
[
2
]
==
n
[
2
]
)
if
(
!
n
.
hasNan
()
)
N
+=
n
;
it
=
map
.
phi1
(
it
)
;
}
while
(
it
!=
d
)
;
...
...
@@ -130,24 +130,6 @@ void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& posit
}
}
template
<
typename
PFP
>
class
computeNormalVerticesFunctor
:
public
FunctorMap
<
typename
PFP
::
MAP
>
{
protected:
typename
PFP
::
MAP
&
m_map
;
const
typename
PFP
::
TVEC3
&
m_position
;
typename
PFP
::
TVEC3
&
m_normal
;
public:
computeNormalVerticesFunctor
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
)
:
m_map
(
map
),
m_position
(
position
),
m_normal
(
normal
)
{}
bool
operator
()(
Dart
d
)
{
m_normal
[
d
]
=
vertexNormal
<
PFP
>
(
m_map
,
d
,
m_position
)
;
return
false
;
}
};
template
<
typename
PFP
>
void
computeNormalVertices
(
typename
PFP
::
MAP
&
map
,
const
typename
PFP
::
TVEC3
&
position
,
typename
PFP
::
TVEC3
&
normal
,
const
FunctorSelect
&
select
,
unsigned
int
thread
)
{
...
...
@@ -186,7 +168,8 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Dart
if
(
s
>=
0
)
a
=
acos
(
c
)
;
else
a
=
-
acos
(
c
)
;
}
if
(
isnan
(
a
))
// if (isnan(a))
if
(
a
!=
a
)
std
::
cerr
<<
"Warning : computeAngleBetweenNormalsOnEdge returns NaN on edge "
<<
d
<<
"-"
<<
dd
<<
std
::
endl
;
return
a
;
}
...
...
include/Algo/LinearSolving/basic.h
View file @
7dd5fd61
...
...
@@ -106,9 +106,9 @@ void addRowsRHS_Equality(
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
float
amoun
t
)
const
AttributeHandler
<
typename
PFP
::
REAL
>&
weigh
t
)
{
FunctorEquality_Scalar
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
amoun
t
)
;
FunctorEquality_
PerVertexWeight_
Scalar
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
weigh
t
)
;
m
.
foreach_orbit
(
VERTEX
,
ec
)
;
}
...
...
@@ -118,10 +118,35 @@ void addRowsRHS_Equality(
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
float
amount
,
float
weight
)
{
FunctorEquality_UniformWeight_Scalar
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
weight
)
;
m
.
foreach_orbit
(
VERTEX
,
ec
)
;
}
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
void
addRowsRHS_Equality
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
const
AttributeHandler
<
typename
PFP
::
REAL
>&
weight
,
unsigned
int
coord
)
{
FunctorEquality_PerVertexWeight_Vector
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
weight
,
coord
)
;
m
.
foreach_orbit
(
VERTEX
,
ec
)
;
}
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
void
addRowsRHS_Equality
(
typename
PFP
::
MAP
&
m
,
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
float
weight
,
unsigned
int
coord
)
{
FunctorEquality_Vector
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
amoun
t
,
coord
)
;
FunctorEquality_
UniformWeight_
Vector
<
PFP
,
ATTR_TYPE
,
SOLVER_TRAITS
>
ec
(
s
,
index
,
attr
,
weigh
t
,
coord
)
;
m
.
foreach_orbit
(
VERTEX
,
ec
)
;
}
...
...
include/Algo/LinearSolving/matrixSetup.h
View file @
7dd5fd61
...
...
@@ -36,7 +36,36 @@ namespace LinearSolving
*******************************************************************************/
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorEquality_Scalar
:
public
FunctorType
class
FunctorEquality_PerVertexWeight_Scalar
:
public
FunctorType
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
const
AttributeHandler
<
unsigned
int
>&
indexTable
;
const
AttributeHandler
<
ATTR_TYPE
>&
attrTable
;
const
AttributeHandler
<
typename
PFP
::
REAL
>&
weightTable
;
public:
FunctorEquality_PerVertexWeight_Scalar
(
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>&
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
const
AttributeHandler
<
typename
PFP
::
REAL
>&
weight
)
:
solver
(
s
),
indexTable
(
index
),
attrTable
(
attr
),
weightTable
(
weight
)
{}
bool
operator
()(
Dart
d
)
{
solver
->
begin_row
()
;
solver
->
add_coefficient
(
indexTable
[
d
],
1
)
;
solver
->
set_right_hand_side
(
attrTable
[
d
])
;
solver
->
normalize_row
(
weightTable
[
d
])
;
solver
->
end_row
()
;
return
false
;
}
}
;
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorEquality_UniformWeight_Scalar
:
public
FunctorType
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
...
...
@@ -45,7 +74,7 @@ protected:
float
weight
;
public:
FunctorEquality_Scalar
(
FunctorEquality_
UniformWeight_
Scalar
(
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>&
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
...
...
@@ -69,7 +98,38 @@ public:
*******************************************************************************/
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorEquality_Vector
:
public
FunctorType
class
FunctorEquality_PerVertexWeight_Vector
:
public
FunctorType
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
const
AttributeHandler
<
unsigned
int
>&
indexTable
;
const
AttributeHandler
<
ATTR_TYPE
>&
attrTable
;
const
AttributeHandler
<
typename
PFP
::
REAL
>&
weightTable
;
unsigned
int
coord
;
public:
FunctorEquality_PerVertexWeight_Vector
(
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>&
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
const
AttributeHandler
<
typename
PFP
::
REAL
>&
weight
,
unsigned
int
c
)
:
solver
(
s
),
indexTable
(
index
),
attrTable
(
attr
),
weightTable
(
weight
),
coord
(
c
)
{}
bool
operator
()(
Dart
d
)
{
solver
->
begin_row
()
;
solver
->
add_coefficient
(
indexTable
[
d
],
1
)
;
solver
->
set_right_hand_side
((
attrTable
[
d
])[
coord
])
;
solver
->
normalize_row
(
weightTable
[
d
])
;
solver
->
end_row
()
;
return
false
;
}
}
;
template
<
typename
PFP
,
typename
ATTR_TYPE
,
class
SOLVER_TRAITS
>
class
FunctorEquality_UniformWeight_Vector
:
public
FunctorType
{
protected:
LinearSolver
<
SOLVER_TRAITS
>*
solver
;
...
...
@@ -79,7 +139,7 @@ protected:
unsigned
int
coord
;
public:
FunctorEquality_Vector
(
FunctorEquality_
UniformWeight_
Vector
(
LinearSolver
<
SOLVER_TRAITS
>*
s
,
const
AttributeHandler
<
unsigned
int
>&
index
,
const
AttributeHandler
<
ATTR_TYPE
>&
attr
,
...
...
include/Utils/pointSprite.h
View file @
7dd5fd61
...
...
@@ -60,6 +60,7 @@ protected:
GLuint
m_uniform_size
;
GLuint
m_uniform_color
;
public:
/**
* init shaders, texture and variables
...
...
include/Utils/qtSimple.h
View file @
7dd5fd61
...
...
@@ -80,7 +80,7 @@ public:
* @param signal use macro SIGNAL(qt_signal)
* @param method use macro SLOT(name_of_method(params))
*/
void
setCallBack
(
const
QObject
*
sender
,
const
char
*
signal
,
const
char
*
method
);
void
setCallBack
(
const
QObject
*
sender
,
const
char
*
signal
,
const
char
*
method
);
/**
* set window Title
...
...
@@ -147,11 +147,11 @@ public:
void
setGLWidgetMouseTracking
(
bool
b
);
protected:
GLWidget
*
m_glWidget
;
GLWidget
*
m_glWidget
;
QDockWidget
*
m_dock
;
QDockWidget
*
m_dock
;
QDockWidget
*
m_dockConsole
;
QDockWidget
*
m_dockConsole
;
QTextEdit
*
m_textConsole
;
...
...
@@ -219,7 +219,7 @@ public:
* @param pixel_width width on pixel on screen
* @param center reference point on world to use (defaut 0,0,0)
*/
float
getWidthInWorld
(
unsigned
int
pixel_width
,
const
Geom
::
Vec3f
&
center
=
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
0.0
f
));
float
getWidthInWorld
(
unsigned
int
pixel_width
,
const
Geom
::
Vec3f
&
center
=
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
0.0
f
));
const
glm
::
mat4
&
transfoMatrix
()
const
{
return
m_transfo_matrix
;
}
glm
::
mat4
&
transfoMatrix
()
{
return
m_transfo_matrix
;
}
...
...
include/Utils/qtgl.h
View file @
7dd5fd61
...
...
@@ -88,6 +88,8 @@ protected:
int
m_state_modifier
;
bool
allow_rotation
;
/**
* met a jour la matrice modelview
*/
...
...
@@ -102,6 +104,8 @@ protected:
public:
void
setParamObject
(
float
width
,
float
*
pos
);
void
setRotation
(
bool
b
);
void
initializeGL
();
void
paintGL
();
...
...
src/Utils/qtSimple.cpp
View file @
7dd5fd61
...
...
@@ -41,10 +41,10 @@ namespace QT
{
SimpleQT
::
SimpleQT
()
:
m_dock
(
NULL
),
m_projection_matrix
(
m_mat
.
m_matrices
[
0
]),
m_modelView_matrix
(
m_mat
.
m_matrices
[
1
]),
m_transfo_matrix
(
m_mat
.
m_matrices
[
2
])
m_dock
(
NULL
),
m_projection_matrix
(
m_mat
.
m_matrices
[
0
]),
m_modelView_matrix
(
m_mat
.
m_matrices
[
1
]),
m_transfo_matrix
(
m_mat
.
m_matrices
[
2
])
{
m_glWidget
=
new
GLWidget
(
this
);
setCentralWidget
(
m_glWidget
);
...
...
@@ -56,17 +56,17 @@ SimpleQT::SimpleQT() :
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_New
()));
m_fileMenu
->
addAction
(
action
);
action
=
new
QAction
(
tr
(
"Open"
),
this
);
action
=
new
QAction
(
tr
(
"Open"
),
this
);
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_Open
()));
m_fileMenu
->
addAction
(
action
);
action
=
new
QAction
(
tr
(
"Save"
),
this
);
action
=
new
QAction
(
tr
(
"Save"
),
this
);
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_Save
()));
m_fileMenu
->
addAction
(
action
);
m_fileMenu
->
addSeparator
();
action
=
new
QAction
(
tr
(
"Quit"
),
this
);
action
=
new
QAction
(
tr
(
"Quit"
),
this
);
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_Quit
()));
m_fileMenu
->
addAction
(
action
);
...
...
@@ -74,25 +74,25 @@ SimpleQT::SimpleQT() :
QMenu
*
m_helpMenu
=
menuBar
()
->
addMenu
(
tr
(
"&Help"
));
action
=
new
QAction
(
tr
(
"console on/off"
),
this
);
action
=
new
QAction
(
tr
(
"console on/off"
),
this
);
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_consoleOnOff
()));
m_helpMenu
->
addAction
(
action
);
action
=
new
QAction
(
tr
(
"console clear"
),
this
);
action
=
new
QAction
(
tr
(
"console clear"
),
this
);
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_consoleClear
()));
m_helpMenu
->
addAction
(
action
);
action
=
new
QAction
(
tr
(
"About"
),
this
);
action
=
new
QAction
(
tr
(
"About"
),
this
);
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_about
()));
m_helpMenu
->
addAction
(
action
);
action
=
new
QAction
(
tr
(
"About CGoGN"
),
this
);
action
=
new
QAction
(
tr
(
"About CGoGN"
),
this
);
connect
(
action
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
cb_about_cgogn
()));
m_helpMenu
->
addAction
(
action
);
m_dockConsole
=
new
QDockWidget
(
tr
(
"Console"
),
this
);
m_dockConsole
->
setAllowedAreas
(
Qt
::
BottomDockWidgetArea
);
m_dockConsole
->
setFeatures
(
QDockWidget
::
DockWidgetMovable
|
QDockWidget
::
DockWidgetFloatable
|
QDockWidget
::
DockWidgetClosable
);
m_dockConsole
->
setFeatures
(
QDockWidget
::
DockWidgetMovable
|
QDockWidget
::
DockWidgetFloatable
|
QDockWidget
::
DockWidgetClosable
);
addDockWidget
(
Qt
::
BottomDockWidgetArea
,
m_dockConsole
);
m_textConsole
=
new
QTextEdit
();
...
...
@@ -108,11 +108,11 @@ SimpleQT::SimpleQT() :
}
SimpleQT
::
SimpleQT
(
const
SimpleQT
&
sqt
)
:
m_dock
(
NULL
),
m_mat
(
m_mat
),
m_projection_matrix
(
m_mat
.
m_matrices
[
0
]),
m_modelView_matrix
(
m_mat
.
m_matrices
[
1
]),
m_transfo_matrix
(
m_mat
.
m_matrices
[
2
])
m_dock
(
NULL
),
m_mat
(
m_mat
),
m_projection_matrix
(
m_mat
.
m_matrices
[
0
]),
m_modelView_matrix
(
m_mat
.
m_matrices
[
1
]),
m_transfo_matrix
(
m_mat
.
m_matrices
[
2
])
{
m_glWidget
=
new
GLWidget
(
this
);
setCentralWidget
(
m_glWidget
);
...
...
@@ -383,11 +383,6 @@ float SimpleQT::getWidthInWorld(unsigned int pixel_width, const Geom::Vec3f& cen
return
glm
::
distance
(
P
,
Q
);
}
void
SimpleQT
::
synchronize
(
SimpleQT
*
sqt
)
{
m_glWidget
->
getObjPos
()
=
sqt
->
m_glWidget
->
getObjPos
()
;
...
...
@@ -454,7 +449,7 @@ void SimpleQT::updateGL()
void
SimpleQT
::
updateGLMatrices
()
{
m_glWidget
->
modelModified
();
m_glWidget
->
updateGL
();
//
m_glWidget->updateGL();
}
void
SimpleQT
::
transfoRotate
(
float
angle
,
float
x
,
float
y
,
float
z
)
...
...
src/Utils/qtgl.cpp
View file @
7dd5fd61
...
...
@@ -40,14 +40,13 @@ namespace Utils
namespace
QT
{
float
GLWidget
::
FAR_PLANE
=
500.0
f
;
float
GLWidget
::
FAR_PLANE
=
500.0
f
;
GLWidget
::
GLWidget
(
SimpleQT
*
cbs
,
QWidget
*
parent
)
:
QGLWidget
(
QGLFormat
(
QGL
::
Rgba
|
QGL
::
DoubleBuffer
|
QGL
::
DepthBuffer
),
parent
),
m_cbs
(
cbs
),
m_state_modifier
(
0
)
m_state_modifier
(
0
),
allow_rotation
(
true
)
{
makeCurrent
();
glewInit
();
...
...
@@ -73,6 +72,11 @@ void GLWidget::setParamObject(float width, float* pos)
m_obj_pos
=
glm
::
vec3
(
-
pos
[
0
],
-
pos
[
1
],
-
pos
[
2
]);
}
void
GLWidget
::
setRotation
(
bool
b
)
{
allow_rotation
=
b
;
}
void
GLWidget
::
setFocal
(
float
df
)
{
if
(
df
>
5.0
f
)
...
...
@@ -106,7 +110,7 @@ void GLWidget::recalcModelView()
// tourne l'objet / mvt souris
glm
::
mat4
m
;
build_rotmatrixgl3
(
m
,
m_cbs
->
curquat
());
//
// update matrice
// update matrice
m_cbs
->
modelViewMatrix
()
*=
m
;
// transfo pour que l'objet soit centre et a la bonne taille
...
...
@@ -197,7 +201,6 @@ void GLWidget::paintGL()
Utils
::
GLSLShader
::
s_current_matrices
=
m_cbs
->
matricesPtr
();
m_cbs
->
cb_redraw
();
}
}
void
GLWidget
::
mousePressEvent
(
QMouseEvent
*
event
)
...
...
@@ -276,13 +279,16 @@ void GLWidget::mouseMoveEvent(QMouseEvent* event)
break
;
case
Qt
::
LeftButton
:
{
trackball
(
m_cbs
->
lastquat
(),
(
2.0
f
*
beginx
-
W
)
/
W
,
(
H
-
2.0
f
*
beginy
)
/
H
,
(
2.0
f
*
x
-
W
)
/
W
,(
H
-
2.0
f
*
y
)
/
H
);
add_quats
(
m_cbs
->
lastquat
(),
m_cbs
->
curquat
(),
m_cbs
->
curquat
());
if
(
allow_rotation
)
{
trackball
(
m_cbs
->
lastquat
(),
(
2.0
f
*
beginx
-
W
)
/
W
,
(
H
-
2.0
f
*
beginy
)
/
H
,
(
2.0
f
*
x
-
W
)
/
W
,(
H
-
2.0
f
*
y
)
/
H
);
add_quats
(
m_cbs
->
lastquat
(),
m_cbs
->
curquat
(),
m_cbs
->
curquat
());
}
}
break
;
}
...
...
@@ -324,19 +330,16 @@ void GLWidget::closeEvent(QCloseEvent *event)
void
GLWidget
::
keyPressEvent
(
QKeyEvent
*
event
)
{
if
(
event
->
key
()
==
Qt
::
Key_Escape
)
close
();
// else
// QWidget::keyPressEvent(event);
close
();
m_state_modifier
=
event
->
modifiers
();
m_state_modifier
=
event
->
modifiers
();
int
k
=
event
->
key
();
if
(
(
k
>=
65
)
&&
(
k
<=
91
)
&&
!
(
event
->
modifiers
()
&
Qt
::
ShiftModifier
)
)
k
+=
32
;
int
k
=
event
->
key
();
//
if ( (k >= 65) && (k <= 91) && !(event->modifiers() & Qt::ShiftModifier) )
//
k += 32;
if
(
m_cbs
)
if
(
m_cbs
)
m_cbs
->
cb_keyPress
(
k
);
}
...
...
@@ -372,7 +375,6 @@ void GLWidget::keyReleaseEvent(QKeyEvent *event)
updateGL
();
}
if
(
(
k
>=
65
)
&&
(
k
<=
91
)
&&
(
event
->
modifiers
()
!=
Qt
::
ShiftModifier
)
)
k
+=
32
;
...
...
@@ -395,7 +397,6 @@ void GLWidget::oglScale(float sx, float sy, float sz)
m_cbs
->
modelViewMatrix
()
=
glm
::
scale
(
m_cbs
->
modelViewMatrix
(),
glm
::
vec3
(
sx
,
sy
,
sz
));
}
}
// namespace QT
}
// namespace Utils
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment