mirror of https://github.com/CGAL/cgal
Moved the plugin in a sub-directory
This commit is contained in:
parent
7ad45de6ef
commit
448bda4221
|
|
@ -175,6 +175,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
|||
|
||||
add_item(scene_c2t3_item Scene_c2t3_item.cpp)# Scene_c2t3_item.moc)
|
||||
|
||||
add_item(scene_group_item Scene_group_item.cpp)
|
||||
add_item(scene_polyhedron_item Scene_polyhedron_item.cpp ${statisticsPolyhedronUI_FILES})# Scene_polyhedron_item.moc)
|
||||
add_item(scene_polyhedron_transform_item Plugins/PCA/Scene_polyhedron_transform_item.cpp )#Scene_polyhedron_transform_item.moc)
|
||||
|
||||
|
|
@ -257,6 +258,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
|||
|
||||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Polyhedron_3 )
|
||||
|
||||
|
||||
###########
|
||||
# PLUGINS #
|
||||
###########
|
||||
|
|
@ -265,9 +267,7 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
|
|||
FOREACH(SUB_DIR ${DEMO_PLUGINS})
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/Plugins/${SUB_DIR}")
|
||||
ENDFOREACH()
|
||||
add_item(scene_group_item Scene_group_item.cpp)
|
||||
polyhedron_demo_plugin(group_plugin Polyhedron_demo_group_plugin ${groupUI_FILES})
|
||||
target_link_libraries(group_plugin scene_group_item)
|
||||
|
||||
#
|
||||
# Exporting
|
||||
#
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
#include "Polyhedron_demo_group_plugin.h"
|
||||
#include "Polyhedron_demo_group_plugin.moc"
|
||||
#include "Scene.h"
|
||||
#include <QMenu>
|
||||
/****************
|
||||
* Group Plugin *
|
||||
****************/
|
||||
|
||||
void Polyhedron_demo_group_plugin::init(QMainWindow* mainWindow,
|
||||
CGAL::Three::Scene_interface* scene_interface,Messages_interface* m ) {
|
||||
//get the references
|
||||
trueScene = dynamic_cast<Scene*>(scene_interface);
|
||||
this->scene = scene_interface;
|
||||
this->mw = mainWindow;
|
||||
messages = m;
|
||||
//creates and link the actions
|
||||
actionAddToGroup= new QAction("Add new group", mw);
|
||||
|
||||
if(actionAddToGroup) {
|
||||
connect(actionAddToGroup, SIGNAL(triggered()),
|
||||
this, SLOT(add_group()));
|
||||
}
|
||||
|
||||
QMenu* menuFile = mw->findChild<QMenu*>("menuFile");
|
||||
if ( NULL != menuFile )
|
||||
{
|
||||
QList<QAction*> menuFileActions = menuFile->actions();
|
||||
|
||||
// Look for action just after "Load..." action
|
||||
QAction* actionAfterLoad = NULL;
|
||||
for ( QList<QAction*>::iterator it_action = menuFileActions.begin(),
|
||||
end = menuFileActions.end() ; it_action != end ; ++ it_action ) //Q_FOREACH( QAction* action, menuFileActions)
|
||||
{
|
||||
if ( NULL != *it_action && (*it_action)->text().contains("Load") )
|
||||
{
|
||||
++it_action;
|
||||
if ( it_action != end && NULL != *it_action )
|
||||
{
|
||||
actionAfterLoad = *it_action;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Insert "Load implicit function" action
|
||||
if ( NULL != actionAfterLoad )
|
||||
{
|
||||
menuFile->insertAction(actionAfterLoad,actionAddToGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
#ifndef POLYHEDRON_DEMO_GROUP_H
|
||||
#define POLYHEDRON_DEMO_GROUP_H
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QAction>
|
||||
#include <QList>
|
||||
#include "Scene_group_item.h"
|
||||
#include "CGAL/Three/Scene_interface.h"
|
||||
#include "Scene.h"
|
||||
|
||||
class Scene_interface;
|
||||
#include "CGAL/Three/Polyhedron_demo_plugin_helper.h"
|
||||
class Polyhedron_demo_group_plugin :
|
||||
public QObject,
|
||||
public CGAL::Three::Polyhedron_demo_plugin_helper
|
||||
{
|
||||
//Configures CMake to use MOC correctly
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface)
|
||||
Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0")
|
||||
public :
|
||||
// To silent a warning -Woverloaded-virtual
|
||||
// See http://stackoverflow.com/questions/9995421/gcc-woverloaded-virtual-warnings
|
||||
using Polyhedron_demo_plugin_helper::init;
|
||||
void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface*);
|
||||
|
||||
bool applicable(QAction*) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Scene* trueScene;
|
||||
public Q_SLOTS:
|
||||
void add_group() {
|
||||
//Find the indices of the selected items
|
||||
QList<int> indices;
|
||||
QList<int> blacklist;
|
||||
Q_FOREACH(int id, scene->selectionIndices()){
|
||||
Scene_group_item* group =
|
||||
qobject_cast<Scene_group_item*>(trueScene->item(id));
|
||||
if(group)
|
||||
Q_FOREACH(Scene_item *item, group->getChildren())
|
||||
blacklist<<trueScene->item_id(item);
|
||||
|
||||
if(!indices.contains(id) && !blacklist.contains(id))
|
||||
indices<<id;
|
||||
}
|
||||
//checks if all the selected items are in the same group
|
||||
bool all_in_one = true;
|
||||
if(indices.isEmpty())
|
||||
all_in_one = false;
|
||||
// new group to create
|
||||
Scene_group_item * group = new Scene_group_item("new group");
|
||||
//group containing the selected item
|
||||
Scene_group_item * existing_group = 0;
|
||||
//for each selected item
|
||||
Q_FOREACH(int id, indices){
|
||||
//if the selected item is in a group
|
||||
if(trueScene->item(id)->has_group!=0){
|
||||
//for each group
|
||||
Q_FOREACH(Scene_group_item *item, trueScene->group_entries())
|
||||
{
|
||||
//if the group contains the selected item
|
||||
if(item->getChildren().contains(trueScene->item(id))){
|
||||
//if it is the first one, we initialize existing_group
|
||||
if(existing_group == 0)
|
||||
existing_group = item;
|
||||
//else we check if it is the same group as before.
|
||||
//If not, all selected items are not in the same group
|
||||
else if(existing_group != item)
|
||||
all_in_one = false;
|
||||
break;
|
||||
}
|
||||
}//end for each group
|
||||
}
|
||||
//else it is impossible that all the selected items are in the same group
|
||||
else{
|
||||
all_in_one = false;
|
||||
break;
|
||||
}
|
||||
}//end foreach selected item
|
||||
|
||||
//If all the selected items are in the same group, we put them in a sub_group of this group
|
||||
if(all_in_one)
|
||||
{
|
||||
Q_FOREACH(int id, indices)
|
||||
trueScene->changeGroup(trueScene->item(id),group);
|
||||
trueScene->changeGroup(group, existing_group);
|
||||
scene->addItem(group);
|
||||
trueScene->group_added();
|
||||
}
|
||||
//else wer create a new group
|
||||
else
|
||||
{
|
||||
Q_FOREACH(int id, indices)
|
||||
trueScene->changeGroup(trueScene->item(id),group);
|
||||
scene->addItem(group);
|
||||
trueScene->group_added();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
QAction* actionAddToGroup;
|
||||
void print_message(QString message) { messages->information(message); }
|
||||
Messages_interface* messages;
|
||||
|
||||
}; //end of class Polyhedron_demo_group_plugin
|
||||
#endif
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>GroupDialog</class>
|
||||
<widget class="QDialog" name="GroupDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>9</x>
|
||||
<y>9</y>
|
||||
<width>371</width>
|
||||
<height>211</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListView" name="itemsView"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListView" name="groupsView"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>GroupDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>GroupDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
Loading…
Reference in New Issue