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
Hurstel
CGoGN
Commits
1803052b
Commit
1803052b
authored
Sep 30, 2013
by
Pierre Kraemer
Browse files
mutually exclusive cell selectors
parent
cb23b33c
Changes
9
Hide whitespace changes
Inline
Side-by-side
SCHNApps/Plugins/surface_deformation/forms/surface_deformation.ui
View file @
1803052b
...
...
@@ -33,7 +33,7 @@
<item
row=
"5"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Free selector :
</string>
<string>
Free
vertices
selector :
</string>
</property>
</widget>
</item>
...
...
@@ -59,6 +59,22 @@
</property>
</widget>
</item>
<item
row=
"10"
column=
"0"
colspan=
"2"
>
<widget
class=
"QPushButton"
name=
"button_start_stop"
>
<property
name=
"text"
>
<string>
Start
</string>
</property>
</widget>
</item>
<item
row=
"4"
column=
"0"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"combo_handleSelector"
>
<item>
<property
name=
"text"
>
<string>
- select selector -
</string>
</property>
</item>
</widget>
</item>
<item
row=
"11"
column=
"0"
colspan=
"2"
>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
...
...
@@ -72,29 +88,13 @@
</property>
</spacer>
</item>
<item
row=
"10"
column=
"0"
colspan=
"2"
>
<widget
class=
"QPushButton"
name=
"button_start_stop"
>
<property
name=
"text"
>
<string>
Start
</string>
</property>
</widget>
</item>
<item
row=
"3"
column=
"0"
>
<item
row=
"3"
column=
"0"
colspan=
"2"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Handle selector :
</string>
<string>
Handle
vertices
selector :
</string>
</property>
</widget>
</item>
<item
row=
"4"
column=
"0"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"combo_handleSelector"
>
<item>
<property
name=
"text"
>
<string>
- select selector -
</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<tabstops>
...
...
SCHNApps/Plugins/surface_selection/src/surface_selection.cpp
View file @
1803052b
...
...
@@ -81,26 +81,26 @@ void Surface_Selection_Plugin::drawMap(View* view, MapHandlerGen* map)
m_drawer
->
vertex
(
p
.
positionAttribute
[
*
it
]);
m_drawer
->
end
();
m_drawer
->
endList
();
}
}
if
(
m_selecting
)
{
std
::
vector
<
PFP2
::
VEC3
>
selectionPoint
;
selectionPoint
.
push_back
(
m_selectionCenter
);
m_selectionSphereVBO
->
updateData
(
selectionPoint
);
m_pointSprite
->
setAttributePosition
(
m_selectionSphereVBO
);
m_pointSprite
->
setSize
(
m_selectionRadius
);
m_pointSprite
->
setColor
(
CGoGN
::
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1.0
f
,
0.5
f
));
m_pointSprite
->
setLightPosition
(
CGoGN
::
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
1.0
f
));
m_pointSprite
->
enableVertexAttribs
();
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glDrawArrays
(
GL_POINTS
,
0
,
1
);
glDisable
(
GL_BLEND
);
m_pointSprite
->
disableVertexAttribs
();
if
(
m_selecting
)
{
std
::
vector
<
PFP2
::
VEC3
>
selectionPoint
;
selectionPoint
.
push_back
(
m_selectionCenter
);
m_selectionSphereVBO
->
updateData
(
selectionPoint
);
m_pointSprite
->
setAttributePosition
(
m_selectionSphereVBO
);
m_pointSprite
->
setSize
(
m_selectionRadius
);
m_pointSprite
->
setColor
(
CGoGN
::
Geom
::
Vec4f
(
0.0
f
,
0.0
f
,
1.0
f
,
0.5
f
));
m_pointSprite
->
setLightPosition
(
CGoGN
::
Geom
::
Vec3f
(
0.0
f
,
0.0
f
,
1.0
f
));
m_pointSprite
->
enableVertexAttribs
();
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glDrawArrays
(
GL_POINTS
,
0
,
1
);
glDisable
(
GL_BLEND
);
m_pointSprite
->
disableVertexAttribs
();
}
}
}
}
}
...
...
@@ -111,7 +111,7 @@ void Surface_Selection_Plugin::keyPress(View* view, QKeyEvent* event)
{
view
->
setMouseTracking
(
true
);
m_selecting
=
true
;
//
view->updateGL();
view
->
updateGL
();
}
}
...
...
@@ -121,7 +121,7 @@ void Surface_Selection_Plugin::keyRelease(View* view, QKeyEvent* event)
{
view
->
setMouseTracking
(
false
);
m_selecting
=
false
;
//
view->updateGL();
view
->
updateGL
();
}
}
...
...
SCHNApps/include/cellSelector.h
View file @
1803052b
#ifndef _CELL_SELECTOR_H_
#define _CELL_SELECTOR_H_
#include
<QObject>
#include
<QString>
#include
<QList>
#include
"Topology/generic/dart.h"
#include
"Topology/generic/genericmap.h"
#include
"Topology/generic/cellmarker.h"
#include
<QObject>
namespace
CGoGN
{
...
...
@@ -35,27 +35,69 @@ public:
virtual
void
select
(
Dart
d
,
bool
emitSignal
)
=
0
;
virtual
void
unselect
(
Dart
d
,
bool
emitSignal
)
=
0
;
virtual
void
select
(
const
std
::
vector
<
Dart
>&
d
)
=
0
;
virtual
void
unselect
(
const
std
::
vector
<
Dart
>&
d
)
=
0
;
inline
void
select
(
const
std
::
vector
<
Dart
>&
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
d
.
size
();
++
i
)
select
(
d
[
i
],
false
);
checkChange
();
if
(
m_isMutuallyExclusive
&&
!
m_mutuallyExclusive
.
empty
())
{
foreach
(
CellSelectorGen
*
cs
,
m_mutuallyExclusive
)
cs
->
checkChange
();
}
}
inline
void
unselect
(
const
std
::
vector
<
Dart
>&
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
d
.
size
();
++
i
)
unselect
(
d
[
i
],
false
);
checkChange
();
}
virtual
bool
isSelected
(
Dart
d
)
=
0
;
inline
void
setMutuallyExclusive
(
bool
b
)
{
m_isMutuallyExclusive
=
b
;
}
inline
bool
isMutuallyExclusive
()
const
{
return
m_isMutuallyExclusive
;
}
inline
void
setMutuallyExclusiveSet
(
const
QList
<
CellSelectorGen
*>&
mex
)
{
m_mutuallyExclusive
.
clear
();
foreach
(
CellSelectorGen
*
cs
,
mex
)
{
if
(
cs
!=
this
)
m_mutuallyExclusive
.
append
(
cs
);
}
}
inline
void
checkChange
()
{
if
(
m_selectionChanged
)
{
emit
(
selectedCellsChanged
());
m_selectionChanged
=
false
;
}
}
signals:
void
selectedCellsChanged
();
protected:
QString
m_name
;
std
::
vector
<
Dart
>
m_cells
;
bool
m_selectionChanged
;
bool
m_isMutuallyExclusive
;
QList
<
CellSelectorGen
*>
m_mutuallyExclusive
;
};
template
<
unsigned
int
ORBIT
>
class
CellSelector
:
public
CellSelectorGen
{
public:
CellSelector
(
GenericMap
&
m
,
const
QString
&
name
,
unsigned
int
thread
=
0
)
:
CellSelector
(
GenericMap
&
m
ap
,
const
QString
&
name
,
unsigned
int
thread
=
0
)
:
CellSelectorGen
(
name
),
m_map
(
m
),
m_cm
(
m
,
thread
)
m_map
(
m
ap
),
m_cm
(
m
ap
,
thread
)
{}
~
CellSelector
()
...
...
@@ -72,8 +114,15 @@ public:
{
m_cells
.
push_back
(
d
);
m_cm
.
mark
(
v
);
if
(
m_isMutuallyExclusive
&&
!
m_mutuallyExclusive
.
empty
())
{
foreach
(
CellSelectorGen
*
cs
,
m_mutuallyExclusive
)
cs
->
unselect
(
d
,
emitSignal
);
}
if
(
emitSignal
)
emit
(
selectedCellsChanged
());
else
m_selectionChanged
=
true
;
}
}
...
...
@@ -96,24 +145,12 @@ public:
m_cells
.
pop_back
();
if
(
emitSignal
)
emit
(
selectedCellsChanged
());
else
m_selectionChanged
=
true
;
}
}
}
inline
void
select
(
const
std
::
vector
<
Dart
>&
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
d
.
size
();
++
i
)
select
(
d
[
i
],
false
);
emit
(
selectedCellsChanged
());
}
inline
void
unselect
(
const
std
::
vector
<
Dart
>&
d
)
{
for
(
unsigned
int
i
=
0
;
i
<
d
.
size
();
++
i
)
unselect
(
d
[
i
],
false
);
emit
(
selectedCellsChanged
());
}
inline
bool
isSelected
(
Dart
d
)
{
return
m_cm
.
isMarked
(
d
);
...
...
SCHNApps/include/controlDock_mapTab.h
View file @
1803052b
...
...
@@ -38,6 +38,7 @@ private slots:
void
vertexAttributeCheckStateChanged
(
QListWidgetItem
*
item
);
void
selectedSelectorChanged
();
void
selectorCheckStateChanged
(
QListWidgetItem
*
item
);
void
addSelector
();
void
removeSelector
();
...
...
SCHNApps/include/mapHandler.h
View file @
1803052b
...
...
@@ -152,6 +152,8 @@ public:
template
<
unsigned
int
ORBIT
>
CellSelector
<
ORBIT
>*
getCellSelector
(
const
QString
&
name
)
const
;
void
updateMutuallyExclusiveSelectors
(
unsigned
int
orbit
);
/*********************************************************
* MANAGE LINKED VIEWS
*********************************************************/
...
...
SCHNApps/src/cellSelector.cpp
View file @
1803052b
...
...
@@ -9,7 +9,9 @@ namespace SCHNApps
unsigned
int
CellSelectorGen
::
selectorCount
=
0
;
CellSelectorGen
::
CellSelectorGen
(
const
QString
&
name
)
:
m_name
(
name
)
m_name
(
name
),
m_selectionChanged
(
false
),
m_isMutuallyExclusive
(
false
)
{
++
selectorCount
;
}
...
...
SCHNApps/src/controlDock_mapTab.cpp
View file @
1803052b
...
...
@@ -28,22 +28,27 @@ ControlDock_MapTab::ControlDock_MapTab(SCHNApps* s) :
connect
(
m_schnapps
,
SIGNAL
(
selectedViewChanged
(
View
*
,
View
*
)),
this
,
SLOT
(
selectedViewChanged
(
View
*
,
View
*
)));
connect
(
list_dartSelectors
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedSelectorChanged
()));
connect
(
list_dartSelectors
,
SIGNAL
(
itemChanged
(
QListWidgetItem
*
)),
this
,
SLOT
(
selectorCheckStateChanged
(
QListWidgetItem
*
)));
connect
(
button_dartAddSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addSelector
()));
connect
(
button_dartRemoveSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
removeSelector
()));
connect
(
list_vertexSelectors
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedSelectorChanged
()));
connect
(
list_vertexSelectors
,
SIGNAL
(
itemChanged
(
QListWidgetItem
*
)),
this
,
SLOT
(
selectorCheckStateChanged
(
QListWidgetItem
*
)));
connect
(
button_vertexAddSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addSelector
()));
connect
(
button_vertexRemoveSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
removeSelector
()));
connect
(
list_edgeSelectors
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedSelectorChanged
()));
connect
(
list_edgeSelectors
,
SIGNAL
(
itemChanged
(
QListWidgetItem
*
)),
this
,
SLOT
(
selectorCheckStateChanged
(
QListWidgetItem
*
)));
connect
(
button_edgeAddSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addSelector
()));
connect
(
button_edgeRemoveSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
removeSelector
()));
connect
(
list_faceSelectors
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedSelectorChanged
()));
connect
(
list_faceSelectors
,
SIGNAL
(
itemChanged
(
QListWidgetItem
*
)),
this
,
SLOT
(
selectorCheckStateChanged
(
QListWidgetItem
*
)));
connect
(
button_faceAddSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addSelector
()));
connect
(
button_faceRemoveSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
removeSelector
()));
connect
(
list_volumeSelectors
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedSelectorChanged
()));
connect
(
list_volumeSelectors
,
SIGNAL
(
itemChanged
(
QListWidgetItem
*
)),
this
,
SLOT
(
selectorCheckStateChanged
(
QListWidgetItem
*
)));
connect
(
button_volumeAddSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
addSelector
()));
connect
(
button_volumeRemoveSelector
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
removeSelector
()));
}
...
...
@@ -157,6 +162,20 @@ void ControlDock_MapTab::selectedSelectorChanged()
}
}
void
ControlDock_MapTab
::
selectorCheckStateChanged
(
QListWidgetItem
*
item
)
{
if
(
!
b_updatingUI
)
{
if
(
m_selectedMap
)
{
unsigned
int
orbit
=
getCurrentOrbit
();
CellSelectorGen
*
cs
=
m_selectedMap
->
getCellSelector
(
orbit
,
item
->
text
());
cs
->
setMutuallyExclusive
(
item
->
checkState
()
==
Qt
::
Checked
);
m_selectedMap
->
updateMutuallyExclusiveSelectors
(
orbit
);
}
}
}
void
ControlDock_MapTab
::
addSelector
()
{
if
(
!
b_updatingUI
)
...
...
@@ -327,75 +346,60 @@ void ControlDock_MapTab::updateSelectedMapInfo()
for
(
unsigned
int
orbit
=
DART
;
orbit
<=
VOLUME
;
++
orbit
)
{
unsigned
int
nbc
=
m
->
getNbCells
(
orbit
);
QListWidget
*
selectorList
=
NULL
;
switch
(
orbit
)
{
case
DART
:
{
unsigned
int
nb
=
m
->
getNbDarts
();
label_dartNbOrbits
->
setText
(
QString
::
number
(
nb
));
label_dartNbCells
->
setText
(
QString
::
number
(
nbc
));
foreach
(
CellSelectorGen
*
cs
,
m_selectedMap
->
getCellSelectorSet
(
orbit
).
values
())
{
QListWidgetItem
*
item
=
new
QListWidgetItem
(
cs
->
getName
(),
list_dartSelectors
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
if
(
m_selectedSelector
[
orbit
]
==
cs
)
item
->
setSelected
(
true
);
}
selectorList
=
list_dartSelectors
;
break
;
}
case
VERTEX
:
{
unsigned
int
nb
=
m
->
getNbOrbits
<
VERTEX
>
();
label_vertexNbOrbits
->
setText
(
QString
::
number
(
nb
));
label_vertexNbCells
->
setText
(
QString
::
number
(
nbc
));
foreach
(
CellSelectorGen
*
cs
,
m_selectedMap
->
getCellSelectorSet
(
orbit
).
values
())
{
QListWidgetItem
*
item
=
new
QListWidgetItem
(
cs
->
getName
(),
list_vertexSelectors
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
if
(
m_selectedSelector
[
orbit
]
==
cs
)
item
->
setSelected
(
true
);
}
selectorList
=
list_vertexSelectors
;
break
;
}
case
EDGE
:
{
unsigned
int
nb
=
m
->
getNbOrbits
<
EDGE
>
();
label_edgeNbOrbits
->
setText
(
QString
::
number
(
nb
));
label_edgeNbCells
->
setText
(
QString
::
number
(
nbc
));
foreach
(
CellSelectorGen
*
cs
,
m_selectedMap
->
getCellSelectorSet
(
orbit
).
values
())
{
QListWidgetItem
*
item
=
new
QListWidgetItem
(
cs
->
getName
(),
list_edgeSelectors
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
if
(
m_selectedSelector
[
orbit
]
==
cs
)
item
->
setSelected
(
true
);
}
selectorList
=
list_edgeSelectors
;
break
;
}
case
FACE
:
{
unsigned
int
nb
=
m
->
getNbOrbits
<
FACE
>
();
label_faceNbOrbits
->
setText
(
QString
::
number
(
nb
));
label_faceNbCells
->
setText
(
QString
::
number
(
nbc
));
foreach
(
CellSelectorGen
*
cs
,
m_selectedMap
->
getCellSelectorSet
(
orbit
).
values
())
{
QListWidgetItem
*
item
=
new
QListWidgetItem
(
cs
->
getName
(),
list_faceSelectors
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
if
(
m_selectedSelector
[
orbit
]
==
cs
)
item
->
setSelected
(
true
);
}
selectorList
=
list_faceSelectors
;
break
;
}
case
VOLUME
:
{
unsigned
int
nb
=
m
->
getNbOrbits
<
VOLUME
>
();
label_volumeNbOrbits
->
setText
(
QString
::
number
(
nb
));
label_volumeNbCells
->
setText
(
QString
::
number
(
nbc
));
foreach
(
CellSelectorGen
*
cs
,
m_selectedMap
->
getCellSelectorSet
(
orbit
).
values
())
{
QListWidgetItem
*
item
=
new
QListWidgetItem
(
cs
->
getName
(),
list_volumeSelectors
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
if
(
m_selectedSelector
[
orbit
]
==
cs
)
item
->
setSelected
(
true
);
}
selectorList
=
list_volumeSelectors
;
break
;
}
}
foreach
(
CellSelectorGen
*
cs
,
m_selectedMap
->
getCellSelectorSet
(
orbit
).
values
())
{
QListWidgetItem
*
item
=
new
QListWidgetItem
(
cs
->
getName
(),
selectorList
);
item
->
setFlags
(
item
->
flags
()
|
Qt
::
ItemIsEditable
);
if
(
m_selectedSelector
[
orbit
]
==
cs
)
item
->
setSelected
(
true
);
if
(
cs
->
isMutuallyExclusive
())
item
->
setCheckState
(
Qt
::
Checked
);
else
item
->
setCheckState
(
Qt
::
Unchecked
);
}
if
(
m
->
isOrbitEmbedded
(
orbit
))
{
AttributeContainer
&
cont
=
m
->
getAttributeContainer
(
orbit
);
...
...
SCHNApps/src/mapHandler.cpp
View file @
1803052b
...
...
@@ -47,9 +47,7 @@ Utils::VBO* MapHandlerGen::createVBO(const AttributeMultiVectorGen* attr)
emit
(
vboAdded
(
vbo
));
}
else
{
vbo
->
updateData
(
attr
);
}
return
vbo
;
}
else
...
...
@@ -158,6 +156,18 @@ CellSelectorGen* MapHandlerGen::getCellSelector(unsigned int orbit, const QStrin
return
NULL
;
}
void
MapHandlerGen
::
updateMutuallyExclusiveSelectors
(
unsigned
int
orbit
)
{
QList
<
CellSelectorGen
*>
mex
;
foreach
(
CellSelectorGen
*
cs
,
m_cellSelectors
[
orbit
])
{
if
(
cs
->
isMutuallyExclusive
())
mex
.
append
(
cs
);
}
foreach
(
CellSelectorGen
*
cs
,
m_cellSelectors
[
orbit
])
cs
->
setMutuallyExclusiveSet
(
mex
);
}
/*********************************************************
* MANAGE LINKED VIEWS
*********************************************************/
...
...
SCHNApps/src/view.cpp
View file @
1803052b
...
...
@@ -139,7 +139,7 @@ void View::linkMap(MapHandlerGen* map)
connect
(
map
->
getFrame
(),
SIGNAL
(
modified
()),
this
,
SLOT
(
updateGL
()));
connect
(
map
,
SIGNAL
(
selectedCellsChanged
()),
this
,
SLOT
(
updateGL
()));
if
(
map
==
m_schnapps
->
get
SelectedMap
())
if
(
map
->
is
SelectedMap
())
setManipulatedFrame
(
map
->
getFrame
());
}
}
...
...
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