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
Thomas Pitiot
CGoGN
Commits
e50b4eb7
Commit
e50b4eb7
authored
Jan 26, 2015
by
Pierre Kraemer
Browse files
Merge branch 'develop' into 'master'
Develop new SCHNApps plugin : surface_distance See merge request !31
parents
95e60c11
a0619054
Changes
11
Hide whitespace changes
Inline
Side-by-side
SCHNApps/Plugins/CMakeLists.txt
View file @
e50b4eb7
...
...
@@ -11,6 +11,7 @@ ADD_SUBDIRECTORY(surface_selection)
ADD_SUBDIRECTORY
(
surface_deformation
)
ADD_SUBDIRECTORY
(
surface_modelisation
)
#ADD_SUBDIRECTORY(surface_tilings)
ADD_SUBDIRECTORY
(
surface_distance
)
ADD_SUBDIRECTORY
(
volume_import
)
#ADD_SUBDIRECTORY(volume_render)
SCHNApps/Plugins/surface_distance/CMakeLists.txt
0 → 100644
View file @
e50b4eb7
cmake_minimum_required
(
VERSION 2.8
)
SET
(
PLUGIN_NAME Surface_Distance
)
SET
(
PLUGIN_ROOT_DIR
${
SCHNApps_ROOT_DIR
}
/Plugins/surface_distance
)
INCLUDE_DIRECTORIES
(
${
PLUGIN_ROOT_DIR
}
/include
${
CMAKE_CURRENT_BINARY_DIR
}
)
file
(
GLOB_RECURSE
PLUGIN_FILES
${
PLUGIN_ROOT_DIR
}
/src/*.cpp
${
PLUGIN_ROOT_DIR
}
/include/*.h
${
PLUGIN_ROOT_DIR
}
/include/*.hpp
)
file
(
GLOB_RECURSE
PLUGIN_UI_FILES
${
PLUGIN_ROOT_DIR
}
/forms/*.ui
)
SET
(
PLUGIN_QOBJECT_FILES
${
PLUGIN_ROOT_DIR
}
/include/surface_distance.h
${
PLUGIN_ROOT_DIR
}
/include/dialog_computeDistance.h
)
include
(
${
SCHNApps_ROOT_DIR
}
/Plugins/plugins_cmake.txt
)
SCHNApps/Plugins/surface_distance/forms/dialog_computeDistance.ui
0 → 100644
View file @
e50b4eb7
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
Dialog_ComputeDistance
</class>
<widget
class=
"QDialog"
name=
"Dialog_ComputeDistance"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
607
</width>
<height>
359
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Compute Distance
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_5"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_8"
>
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_3"
>
<item>
<widget
class=
"QListWidget"
name=
"list_maps_1"
/>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<item>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Position attribute :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"combo_positionAttribute_1"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QGroupBox"
name=
"groupBox"
>
<property
name=
"title"
>
<string>
Distance attribute
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QLabel"
name=
"label_3"
>
<property
name=
"text"
>
<string>
Existing attribute :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"combo_distanceAttribute_1"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_5"
>
<item>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
New attribute :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"distanceAttributeName_1"
/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_4"
>
<item>
<widget
class=
"QListWidget"
name=
"list_maps_2"
/>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_4"
>
<item>
<widget
class=
"QLabel"
name=
"label_4"
>
<property
name=
"text"
>
<string>
Position attribute :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"combo_positionAttribute_2"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Preferred"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget
class=
"QGroupBox"
name=
"groupBox_2"
>
<property
name=
"title"
>
<string>
Distance attribute
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_6"
>
<item>
<widget
class=
"QLabel"
name=
"label_5"
>
<property
name=
"text"
>
<string>
Existing attribute :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QComboBox"
name=
"combo_distanceAttribute_2"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"Expanding"
vsizetype=
"Fixed"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_7"
>
<item>
<widget
class=
"QLabel"
name=
"label_6"
>
<property
name=
"text"
>
<string>
New attribute :
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QLineEdit"
name=
"distanceAttributeName_2"
/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"enableVBO"
>
<property
name=
"text"
>
<string>
Create VBOs
</string>
</property>
<property
name=
"checked"
>
<bool>
false
</bool>
</property>
</widget>
</item>
<item>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_3"
>
<item>
<widget
class=
"QPushButton"
name=
"button_cancel"
>
<property
name=
"text"
>
<string>
Cancel
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"button_apply"
>
<property
name=
"text"
>
<string>
Apply
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QPushButton"
name=
"button_ok"
>
<property
name=
"text"
>
<string>
OK
</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>
button_ok
</sender>
<signal>
clicked()
</signal>
<receiver>
Dialog_ComputeDistance
</receiver>
<slot>
accept()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
232
</x>
<y>
283
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
140
</x>
<y>
156
</y>
</hint>
</hints>
</connection>
<connection>
<sender>
button_cancel
</sender>
<signal>
clicked()
</signal>
<receiver>
Dialog_ComputeDistance
</receiver>
<slot>
reject()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
52
</x>
<y>
283
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
140
</x>
<y>
156
</y>
</hint>
</hints>
</connection>
</connections>
</ui>
SCHNApps/Plugins/surface_distance/include/dialog_computeDistance.h
0 → 100644
View file @
e50b4eb7
#ifndef _DIALOG_COMPUTEDISTANCE_H_
#define _DIALOG_COMPUTEDISTANCE_H_
#include
"ui_dialog_computeDistance.h"
namespace
CGoGN
{
namespace
SCHNApps
{
class
SCHNApps
;
class
MapHandlerGen
;
class
Dialog_ComputeDistance
:
public
QDialog
,
public
Ui
::
Dialog_ComputeDistance
{
Q_OBJECT
public:
Dialog_ComputeDistance
(
SCHNApps
*
s
);
private:
SCHNApps
*
m_schnapps
;
MapHandlerGen
*
m_selectedMap1
;
MapHandlerGen
*
m_selectedMap2
;
public
slots
:
void
selectedMap1Changed
();
void
selectedMap2Changed
();
void
addMapToList
(
MapHandlerGen
*
map
);
void
removeMapFromList
(
MapHandlerGen
*
map
);
void
addAttributeToList1
(
unsigned
int
orbit
,
const
QString
&
nameAttr
);
void
addAttributeToList2
(
unsigned
int
orbit
,
const
QString
&
nameAttr
);
};
}
// namespace SCHNApps
}
// namespace CGoGN
#endif
SCHNApps/Plugins/surface_distance/include/surface_distance.h
0 → 100644
View file @
e50b4eb7
#ifndef _SURFACE_DISTANCE_PLUGIN_H_
#define _SURFACE_DISTANCE_PLUGIN_H_
#include
"plugin_processing.h"
#include
"dialog_computeDistance.h"
namespace
CGoGN
{
namespace
SCHNApps
{
class
Surface_Distance_Plugin
:
public
PluginProcessing
{
Q_OBJECT
Q_INTERFACES
(
CGoGN
::
SCHNApps
::
Plugin
)
public:
Surface_Distance_Plugin
()
{}
~
Surface_Distance_Plugin
()
{}
virtual
bool
enable
();
virtual
void
disable
();
private
slots
:
void
openComputeDistanceDialog
();
void
computeDistanceFromDialog
();
void
appsFinished
();
public
slots
:
void
computeDistance
(
const
QString
&
mapName1
,
const
QString
&
positionAttributeName1
,
const
QString
&
distanceAttributeName1
,
const
QString
&
mapName2
,
const
QString
&
positionAttributeName2
,
const
QString
&
distanceAttributeName2
);
private:
Dialog_ComputeDistance
*
m_computeDistanceDialog
;
QAction
*
m_computeDistanceAction
;
};
}
// namespace SCHNApps
}
// namespace CGoGN
#endif
SCHNApps/Plugins/surface_distance/src/dialog_computeDistance.cpp
0 → 100644
View file @
e50b4eb7
#include
"dialog_computeDistance.h"
#include
"surface_distance.h"
#include
"schnapps.h"
#include
"mapHandler.h"
namespace
CGoGN
{
namespace
SCHNApps
{
Dialog_ComputeDistance
::
Dialog_ComputeDistance
(
SCHNApps
*
s
)
:
m_schnapps
(
s
),
m_selectedMap1
(
NULL
),
m_selectedMap2
(
NULL
)
{
setupUi
(
this
);
distanceAttributeName_1
->
setText
(
"distance"
);
distanceAttributeName_2
->
setText
(
"distance"
);
connect
(
m_schnapps
,
SIGNAL
(
mapAdded
(
MapHandlerGen
*
)),
this
,
SLOT
(
addMapToList
(
MapHandlerGen
*
)));
connect
(
m_schnapps
,
SIGNAL
(
mapRemoved
(
MapHandlerGen
*
)),
this
,
SLOT
(
removeMapFromList
(
MapHandlerGen
*
)));
connect
(
list_maps_1
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedMap1Changed
()));
connect
(
list_maps_2
,
SIGNAL
(
itemSelectionChanged
()),
this
,
SLOT
(
selectedMap2Changed
()));
foreach
(
MapHandlerGen
*
map
,
m_schnapps
->
getMapSet
().
values
())
{
QListWidgetItem
*
item1
=
new
QListWidgetItem
(
map
->
getName
(),
list_maps_1
);
QListWidgetItem
*
item2
=
new
QListWidgetItem
(
map
->
getName
(),
list_maps_2
);
}
}
void
Dialog_ComputeDistance
::
selectedMap1Changed
()
{
if
(
m_selectedMap1
)
disconnect
(
m_selectedMap1
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
addAttributeToList1
(
unsigned
int
,
const
QString
&
)));
QList
<
QListWidgetItem
*>
currentItems
=
list_maps_1
->
selectedItems
();
if
(
!
currentItems
.
empty
())
{
combo_positionAttribute_1
->
clear
();
combo_distanceAttribute_1
->
clear
();
const
QString
&
mapname
=
currentItems
[
0
]
->
text
();
MapHandlerGen
*
mh
=
m_schnapps
->
getMap
(
mapname
);
QString
vec3TypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
VEC3
()));
QString
realTypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
REAL
()));
const
AttributeSet
&
attribs
=
mh
->
getAttributeSet
(
VERTEX
);
for
(
AttributeSet
::
const_iterator
i
=
attribs
.
constBegin
();
i
!=
attribs
.
constEnd
();
++
i
)
{
if
(
i
.
value
()
==
vec3TypeName
)
{
combo_positionAttribute_1
->
addItem
(
i
.
key
());
}
if
(
i
.
value
()
==
realTypeName
)
{
combo_distanceAttribute_1
->
addItem
(
i
.
key
());
}
}
m_selectedMap1
=
mh
;
connect
(
m_selectedMap1
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
addAttributeToList1
(
unsigned
int
,
const
QString
&
)));
}
else
m_selectedMap1
=
NULL
;
}
void
Dialog_ComputeDistance
::
selectedMap2Changed
()
{
if
(
m_selectedMap2
)
disconnect
(
m_selectedMap2
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
addAttributeToList2
(
unsigned
int
,
const
QString
&
)));
QList
<
QListWidgetItem
*>
currentItems
=
list_maps_2
->
selectedItems
();
if
(
!
currentItems
.
empty
())
{
combo_positionAttribute_2
->
clear
();
combo_distanceAttribute_2
->
clear
();
const
QString
&
mapname
=
currentItems
[
0
]
->
text
();
MapHandlerGen
*
mh
=
m_schnapps
->
getMap
(
mapname
);
QString
vec3TypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
VEC3
()));
QString
realTypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
REAL
()));
const
AttributeSet
&
attribs
=
mh
->
getAttributeSet
(
VERTEX
);
for
(
AttributeSet
::
const_iterator
i
=
attribs
.
constBegin
();
i
!=
attribs
.
constEnd
();
++
i
)
{
if
(
i
.
value
()
==
vec3TypeName
)
{
combo_positionAttribute_2
->
addItem
(
i
.
key
());
}
if
(
i
.
value
()
==
realTypeName
)
{
combo_distanceAttribute_2
->
addItem
(
i
.
key
());
}
}
m_selectedMap2
=
mh
;
connect
(
m_selectedMap2
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
addAttributeToList2
(
unsigned
int
,
const
QString
&
)));
}
else
m_selectedMap2
=
NULL
;
}
void
Dialog_ComputeDistance
::
addMapToList
(
MapHandlerGen
*
map
)
{
QListWidgetItem
*
item1
=
new
QListWidgetItem
(
map
->
getName
(),
list_maps_1
);
QListWidgetItem
*
item2
=
new
QListWidgetItem
(
map
->
getName
(),
list_maps_2
);
}
void
Dialog_ComputeDistance
::
removeMapFromList
(
MapHandlerGen
*
map
)
{
QList
<
QListWidgetItem
*>
items1
=
list_maps_1
->
findItems
(
map
->
getName
(),
Qt
::
MatchExactly
);
if
(
!
items1
.
empty
())
delete
items1
[
0
];
QList
<
QListWidgetItem
*>
items2
=
list_maps_2
->
findItems
(
map
->
getName
(),
Qt
::
MatchExactly
);
if
(
!
items2
.
empty
())
delete
items2
[
0
];
if
(
m_selectedMap1
==
map
)
{
disconnect
(
m_selectedMap1
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
addAttributeToList1
(
unsigned
int
,
const
QString
&
)));
m_selectedMap1
=
NULL
;
}
if
(
m_selectedMap2
==
map
)
{
disconnect
(
m_selectedMap2
,
SIGNAL
(
attributeAdded
(
unsigned
int
,
const
QString
&
)),
this
,
SLOT
(
addAttributeToList2
(
unsigned
int
,
const
QString
&
)));
m_selectedMap2
=
NULL
;
}
}
void
Dialog_ComputeDistance
::
addAttributeToList1
(
unsigned
int
orbit
,
const
QString
&
nameAttr
)
{
if
(
orbit
==
VERTEX
)
{
QString
vec3TypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
VEC3
()));
QString
realTypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
REAL
()));
const
QString
&
typeAttr
=
m_selectedMap1
->
getAttributeTypeName
(
orbit
,
nameAttr
);
if
(
typeAttr
==
vec3TypeName
)
{
combo_positionAttribute_1
->
addItem
(
nameAttr
);
}
if
(
typeAttr
==
realTypeName
)
{
combo_distanceAttribute_1
->
addItem
(
nameAttr
);
}
}
}
void
Dialog_ComputeDistance
::
addAttributeToList2
(
unsigned
int
orbit
,
const
QString
&
nameAttr
)
{
if
(
orbit
==
VERTEX
)
{
QString
vec3TypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
VEC3
()));
QString
realTypeName
=
QString
::
fromStdString
(
nameOfType
(
PFP2
::
REAL
()));
const
QString
&
typeAttr
=
m_selectedMap2
->
getAttributeTypeName
(
orbit
,
nameAttr
);
if
(
typeAttr
==
vec3TypeName
)
{
combo_positionAttribute_2
->
addItem
(
nameAttr
);
}
if
(
typeAttr
==
realTypeName
)
{
combo_distanceAttribute_2
->
addItem
(
nameAttr
);
}
}
}
}
// namespace SCHNApps
}
// namespace CGoGN
SCHNApps/Plugins/surface_distance/src/surface_distance.cpp
0 → 100644
View file @
e50b4eb7
#include
"surface_distance.h"
#include
"mapHandler.h"
#include
"Algo/Geometry/distances.h"
namespace
CGoGN
{
namespace
SCHNApps
{
bool
Surface_Distance_Plugin
::
enable
()
{
// magic line that init static variables of GenericMap in the plugins
GenericMap
::
copyAllStatics
(
m_schnapps
->
getStaticPointers
());
m_computeDistanceDialog
=
new
Dialog_ComputeDistance
(
m_schnapps
);
m_computeDistanceAction
=
new
QAction
(
"Compute Distance"
,
this
);
m_schnapps
->
addMenuAction
(
this
,
"Surface;Compute Distance"
,
m_computeDistanceAction
);
connect
(
m_computeDistanceAction
,
SIGNAL
(
triggered
()),
this
,
SLOT
(
openComputeDistanceDialog
()));
connect
(
m_computeDistanceDialog
,
SIGNAL
(
accepted
()),
this
,
SLOT
(
computeDistanceFromDialog
()));
connect
(
m_computeDistanceDialog
->
button_apply
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
computeDistanceFromDialog
()));
connect
(
m_schnapps
,
SIGNAL
(
appsFinished
()),
this
,
SLOT
(
appsFinished
()));
return
true
;
}
void
Surface_Distance_Plugin
::
disable
()
{