diff --git a/Three/demo/Three/Example_plugin/Basic_dialog_plugin.ui b/Three/demo/Three/Example_plugin/Basic_dialog_plugin.ui new file mode 100644 index 00000000000..80339096691 --- /dev/null +++ b/Three/demo/Three/Example_plugin/Basic_dialog_plugin.ui @@ -0,0 +1,91 @@ + + + BasicDialog + + + + 0 + 0 + 400 + 300 + + + + Dialog + + + + + + + + Number to display : + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + BasicDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + BasicDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/Three/demo/Three/Example_plugin/Basic_dock_widget.ui b/Three/demo/Three/Example_plugin/Basic_dock_widget.ui new file mode 100644 index 00000000000..2f78fe35278 --- /dev/null +++ b/Three/demo/Three/Example_plugin/Basic_dock_widget.ui @@ -0,0 +1,61 @@ + + + BasicDockWidget + + + + 0 + 0 + 392 + 302 + + + + DockWidget + + + + + + + + + + + Number to display : + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Print + + + + + + + + + + + diff --git a/Three/demo/Three/Example_plugin/Basic_item_plugin.cpp b/Three/demo/Three/Example_plugin/Basic_item_plugin.cpp new file mode 100644 index 00000000000..3de16fa20f4 --- /dev/null +++ b/Three/demo/Three/Example_plugin/Basic_item_plugin.cpp @@ -0,0 +1,96 @@ +#include +#include +#include +#include +#include +#include +#include "Messages_interface.h" +#include "CGAL/Three/Scene_group_item.h" +#include "Scene_plane_item.h" + +//This plugin crates an action in Operations that displays "Hello World" in the 'console' dockwidet. +class BasicItemPlugin : + public QObject, + public CGAL::Three::Polyhedron_demo_plugin_interface +{ + Q_OBJECT + Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") +public: + //! [applicable] + //This plugin is only applicable if there is at exactly one selected item. + bool applicable(QAction*) const + { + return scene->selectionIndices().size() ==1; + } + //! [applicable] + //the list of the actions of the plugin. + QList actions() const + { + return _actions; + } + //this acts like a constructor for the plugin. It gets the references to the mainwindow and the scene, and connects the action. + void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* sc ) + { + //get the references + this->scene = sc; + this->mw = mainWindow; + + //creates the action + QAction *actionHelloWorld= new QAction(QString("Hello World"), mw); + //specifies the subMenu + actionHelloWorld->setProperty("submenuName", "Basic"); + //links the action + if(actionHelloWorld) { + connect(actionHelloWorld, SIGNAL(triggered()), + this, SLOT(helloWorld())); + _actions << actionHelloWorld; + } + } + + void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface* mi) + { + //gets the reference to the message interface, to display text in the console widget + this->messageInterface = mi; + init(mw, sc); + } +private Q_SLOTS: + + + void helloWorld() + { //! [use] + //get a reference to the selected item. + CGAL::Three::Scene_item *item = scene->item(scene->mainSelectionIndex()); + messageInterface->information(QString("The selected item's name is : %1").arg(item->name())); + //! [use] + //! [additem] + //creates a plane item + Scene_plane_item *new_item = new Scene_plane_item(scene); + new_item->setName("Trivial Plane"); + new_item->setColor(Qt::blue); + new_item->setNormal(0.0,0.0,1.0); + scene->addItem(new_item); + //! [additem] + //! [group] + //clears the selection to avoid adding unwanted items to the group. + scene->setSelectedItem(-1); + //Creates a new group + Scene_group_item *group = new Scene_group_item("New group"); + //Then gives it its children + scene->changeGroup(item, group); + scene->changeGroup(new_item,group); + //adds it to the scene + scene->add_group(group); + //! [group] + } + +private: + QList _actions; + Messages_interface* messageInterface; + //The reference to the scene + CGAL::Three::Scene_interface* scene; + //The reference to the main window + QMainWindow* mw; +}; + +#include "Basic_item_plugin.moc" diff --git a/Three/demo/Three/Example_plugin/Dock_widget_plugin.cpp b/Three/demo/Three/Example_plugin/Dock_widget_plugin.cpp new file mode 100644 index 00000000000..8164e377599 --- /dev/null +++ b/Three/demo/Three/Example_plugin/Dock_widget_plugin.cpp @@ -0,0 +1,111 @@ +#include "ui_Basic_dock_widget.h" +#include +#include +#include +#include +#include +#include "Messages_interface.h" + +//! [dock] +class DockWidget : + public QDockWidget, + public Ui::BasicDockWidget +{ +public: + DockWidget(QString name, QWidget *parent) + :QDockWidget(name,parent) + { + setupUi(this); + } +}; +//! [dock] +//This plugin crates an action in Operations that displays "Hello World" in the 'console' dockwidet. +class BasicPlugin : + public QObject, + public CGAL::Three::Polyhedron_demo_plugin_interface +{ + Q_OBJECT + Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") +public: + //decides if the plugin's actions will be displayed or not. + bool applicable(QAction*) const + { + return true; + } + //the list of the actions of the plugin. + QList actions() const + { + return _actions; + } + //! [init] + //this acts like a constructor for the plugin. It gets the references to the mainwindow and the scene, and connects the action. + void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* sc ) + { + //get the references + this->scene = sc; + this->mw = mainWindow; + + //creates the action + QAction *actionHelloWorld= new QAction(QString("Hello World"), mw); + //specifies the subMenu + actionHelloWorld->setProperty("submenuName", "Basic"); + //links the action + if(actionHelloWorld) { + connect(actionHelloWorld, SIGNAL(triggered()), + this, SLOT(helloWorld())); + _actions << actionHelloWorld; + } + + dock_widget = new DockWidget("Print a number", mw); + dock_widget->setVisible(false); // do not show at the beginning + + mw->addDockWidget(Qt::LeftDockWidgetArea, dock_widget); + + connect(dock_widget->pushButton, SIGNAL(clicked(bool)), + this, SLOT(on_dock_button_clicked())); + + } + //! [init] + + void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface* mi) + { + //gets the reference to the message interface, to display text in the console widget + this->messageInterface = mi; + init(mw, sc); + } +private Q_SLOTS: +//! [action] + void helloWorld() + { + // dock widget should be instancied in init() + if(dock_widget->isVisible()) { dock_widget->hide(); } + else { dock_widget->show(); } + } + + void on_dock_button_clicked() + { + messageInterface->information(QString("Here is your number :%1").arg(dock_widget->spinBox->value())); + + } + //! [action] + //! [closure] + void closure() + { + dock_widget->hide(); + } + //! [closure] +private: + QList _actions; + Messages_interface* messageInterface; + DockWidget* dock_widget; + //The reference to the scene + CGAL::Three::Scene_interface* scene; + //The reference to the main window + QMainWindow* mw; +}; + +#include "Dock_widget_plugin.moc" + + + diff --git a/Three/demo/Three/Example_plugin/Group_item_plugin.cpp b/Three/demo/Three/Example_plugin/Group_item_plugin.cpp new file mode 100644 index 00000000000..e4cf22a4c12 --- /dev/null +++ b/Three/demo/Three/Example_plugin/Group_item_plugin.cpp @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include +#include +#include "Messages_interface.h" +#include "Scene_plane_item.h" +#include + +//This plugin crates an action in Operations that displays "Hello World" in the 'console' dockwidet. +class GroupItemPlugin : + public QObject, + public CGAL::Three::Polyhedron_demo_plugin_interface +{ + Q_OBJECT + Q_INTERFACES(CGAL::Three::Polyhedron_demo_plugin_interface) + Q_PLUGIN_METADATA(IID "com.geometryfactory.PolyhedronDemo.PluginInterface/1.0") +public: + //This plugin is only applicable if there is at exactly one selected item. + bool applicable(QAction*) const + { + return true; + } + //the list of the actions of the plugin. + QList actions() const + { + return _actions; + } + //this acts like a constructor for the plugin. It gets the references to the mainwindow and the scene, and connects the action. + void init(QMainWindow* mainWindow, CGAL::Three::Scene_interface* sc ) + { + //get the references + this->scene = sc; + this->mw = mainWindow; + + //creates the action + QAction *actionHelloWorld= new QAction(QString("Hello World"), mw); + //specifies the subMenu + actionHelloWorld->setProperty("submenuName", "Basic"); + //links the action + if(actionHelloWorld) { + connect(actionHelloWorld, SIGNAL(triggered()), + this, SLOT(helloWorld())); + _actions << actionHelloWorld; + } + } + + void init(QMainWindow* mw, CGAL::Three::Scene_interface* sc, Messages_interface* mi) + { + //gets the reference to the message interface, to display text in the console widget + this->messageInterface = mi; + init(mw, sc); + } +private Q_SLOTS: + + + void helloWorld() + { + //creates an item + Scene_plane_item *child = new Scene_plane_item(scene); + child->setName("Trivial Plane"); + child->setColor(Qt::blue); + child->setNormal(0.0,0.0,1.0); + scene->addItem(child); + //clears the selection to avoid adding unwanted items to the group. + scene->setSelectedItem(-1); + //Creates a new group + Scene_group_item *group = new Scene_group_item("New group"); + //Then gives it its children + scene->changeGroup(child, group); + //adds it to the scene + scene->add_group(group); + + } + +private: + QList _actions; + Messages_interface* messageInterface; + //The reference to the scene + CGAL::Three::Scene_interface* scene; + //The reference to the main window + QMainWindow* mw; +}; + +#include "Group_item_plugin.moc" diff --git a/Three/doc/Three/fig/menu_4.png b/Three/doc/Three/fig/menu_4.png new file mode 100644 index 00000000000..826d35e999d Binary files /dev/null and b/Three/doc/Three/fig/menu_4.png differ diff --git a/Three/doc/Three/fig/menu_5.png b/Three/doc/Three/fig/menu_5.png new file mode 100644 index 00000000000..112ed1207f6 Binary files /dev/null and b/Three/doc/Three/fig/menu_5.png differ diff --git a/Three/doc/Three/fig/menu_6.png b/Three/doc/Three/fig/menu_6.png new file mode 100644 index 00000000000..850aaf4f1ba Binary files /dev/null and b/Three/doc/Three/fig/menu_6.png differ