Commit 326e47d1 authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: update camera draw

parent 4af88cba
cmake_minimum_required(VERSION 2.8)
INCLUDE_DIRECTORIES(
${SCHNApps_ROOT_DIR}/include
${SCHNApps_ROOT_DIR}/Plugins/cameraControl
${CMAKE_CURRENT_BINARY_DIR}
)
SET( PLUGIN_SRC
${SCHNApps_ROOT_DIR}/Plugins/cameraControl/cameraControl.cpp
)
SET( PLUGIN_H
${SCHNApps_ROOT_DIR}/Plugins/cameraControl/cameraControl.h
)
IF( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
ADD_DEFINITIONS(-DDEBUG)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Debug ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
# QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( CameraControlD SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( CameraControlD
${CGoGN_LIBS_D}
${COMMON_LIBS}
)
ADD_DEPENDENCIES( CameraControlD SCHNAppsD )
SET_TARGET_PROPERTIES( CameraControlD PROPERTIES COMPILE_DEFINITIONS "DEBUG" )
ELSE ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ELSE (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF (WIN32)
# QT4_WRAP_UI( PLUGIN_UI ${PLUGIN_FORM} )
QT4_WRAP_CPP( PLUGIN_MOC ${PLUGIN_H} )
ADD_LIBRARY( CameraControl SHARED
${PLUGIN_SRC}
${PLUGIN_UI}
${PLUGIN_MOC}
)
TARGET_LINK_LIBRARIES( CameraControl
${CGoGN_LIBS_R}
${COMMON_LIBS}
)
ADD_DEPENDENCIES( CameraControl SCHNApps )
ENDIF ( ${CMAKE_BUILD_TYPE} STREQUAL Debug )
#include "cameraControl.h"
#include "mapHandler.h"
#include "Algo/Import/import.h"
#include <QFileDialog>
#include <QFileInfo>
bool CameraControlPlugin::enable()
{
return true;
}
#ifndef DEBUG
Q_EXPORT_PLUGIN2(CameraControlPlugin, CameraControlPlugin)
#else
Q_EXPORT_PLUGIN2(CameraControlPluginD, CameraControlPlugin)
#endif
#ifndef _CAMERACONTROL_PLUGIN_H_
#define _CAMERACONTROL_PLUGIN_H_
#include "plugin.h"
using namespace CGoGN;
using namespace SCHNApps;
class CameraControlPlugin : public Plugin
{
Q_OBJECT
Q_INTERFACES(CGoGN::SCHNApps::Plugin)
public:
CameraControlPlugin()
{
setProvidesRendering(false);
}
~CameraControlPlugin()
{}
virtual bool enable();
virtual void disable() {}
virtual void redraw(View *view) {}
virtual void keyPress(View* view, int key) {}
virtual void keyRelease(View* view, int key) {}
virtual void mousePress(View* view, int button, int x, int y) {}
virtual void mouseRelease(View* view, int button, int x, int y) {}
virtual void mouseMove(View* view, int buttons, int x, int y) {}
virtual void wheelEvent(View* view, int delta, int x, int y) {}
public slots:
private:
};
#endif
......@@ -22,50 +22,34 @@
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Position :</string>
<string>Color :</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Position :</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="button_refreshVBOs">
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="combo_colorVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>cColor :</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="combo_colorVBO">
<item row="0" column="2">
<widget class="QComboBox" name="combo_positionVBO">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......
......@@ -6,43 +6,56 @@
<rect>
<x>0</x>
<y>0</y>
<width>198</width>
<height>318</height>
<width>287</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
<string>CamerasDialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="addCameraButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeCamerasButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
<widget class="QPushButton" name="addCameraButton">
<property name="text">
<string>Add</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="cameraList">
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
<widget class="QPushButton" name="removeCamerasButton">
<property name="text">
<string>Remove</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeWidget" name="cameraList">
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Ortho</string>
</property>
</column>
<column>
<property name="text">
<string>Draw</string>
</property>
</column>
<column>
<property name="text">
<string>Draw path</string>
</property>
</column>
</widget>
</item>
<item>
<widget class="QPushButton" name="OKButton">
<property name="text">
......
......@@ -20,6 +20,7 @@ public:
Camera(const QString& name, Window* window);
~Camera();
public slots:
const QString& getName() const { return m_name; }
void setName(const QString& name) { m_name = name; }
......@@ -29,29 +30,20 @@ public:
bool isUsed() const { return !l_views.empty(); }
bool isShared() const { return l_views.size() > 1; }
void changeType(qglviewer::Camera::Type type);
/*********************************************************
* CAMERA DRAWING
*********************************************************/
virtual void draw();
bool getDraw() const { return m_draw; }
void setDraw(bool b = true) { m_draw = b; }
bool getDrawFarPlane() const { return m_drawFarPlane; }
void setDrawFarPlane(bool b) { m_drawFarPlane = b; }
double getDrawScale() const { return m_drawScale; }
void setDrawScale(double s) { m_drawScale = s; }
void setDraw(bool b);
bool getDrawPath() const { return m_drawPath; }
void setDrawPath(bool b) { m_drawPath = b; }
void setDrawPath(bool b);
bool getDrawPathAxis() const { return m_drawPathAxis; }
void setDrawPathAxis(bool b) { m_drawPathAxis = b; }
double getDrawPathScale() const { return m_drawPathScale; }
void setDrawPathScale(double s) { m_drawPathScale = s;}
public:
// virtual void draw();
/*********************************************************
* MANAGE LINKED VIEWS
......@@ -76,12 +68,7 @@ protected:
QList<View*> l_views;
bool m_draw;
bool m_drawFarPlane;
double m_drawScale;
bool m_drawPath;
bool m_drawPathAxis;
double m_drawPathScale;
int m_snapCount;
};
......
......@@ -2,6 +2,7 @@
#define _CAMERASDIALOG_H_
#include "ui_camerasDialog.h"
#include "view.h"
namespace CGoGN
{
......@@ -22,12 +23,18 @@ public:
private:
Window* m_window;
bool b_refreshingUI;
public slots:
void setCameraType(const QString& name, qglviewer::Camera::Type type);
void setDrawCamera(const QString& name, bool b);
void setDrawCameraPath(const QString& name, bool b);
void cb_addCamera();
void cb_removeCameras();
void cb_addCameraToList(Camera* c);
void cb_removeCameraFromList(Camera* c);
void cb_itemChanged(QTreeWidgetItem* item, int column);
};
} // namespace SCHNApps
......
......@@ -27,19 +27,14 @@ class Window : public QMainWindow, Ui::Window
Q_OBJECT
public:
/**
* \fn Window()
* \brief Constructor
*/
Window(const QString& appPath, PythonQtObjectPtr& pythonContext, PythonQtScriptingConsole& pythonConsole);
/**
* \fn ~Window()
* \brief Destructor
*/
~Window();
public slots:
const QString& getAppPath() { return m_appPath; }
CamerasDialog* getCamerasDialog() { return m_camerasDialog; }
PluginsDialog* getPluginsDialog() { return m_pluginsDialog; }
MapsDialog* getMapsDialog() { return m_mapsDialog; }
/*********************************************************
* MANAGE DOCK
......@@ -47,24 +42,8 @@ public:
QTabWidget* getDockTabWidget() const { return m_dockTabWidget; }
/**
* \fn void addTabInDock(QWidget* tabWidget, const QString& tabText, bool enable)
* \brief Adds the widget as a new tab in the interface's dock
*
* \param tabWidget the created and allocated pointer to the QWidget to add in the dock
* \param tabText The text that will appears in the tab label
* \param enable is the new tab enabled ?
*/
public:
void addTabInDock(QWidget* tabWidget, const QString& tabText, bool enable);
/**
* \fn void removeTabInDock(QWidget* tabWidget)
* \brief removes a given widget from the tab
*
* \param tabWidget the reference to the widget you want to remove
*
* If the widget does belong to the tab, it will be destroyed.
*/
void removeTabInDock(QWidget* tabWidget);
public slots:
......@@ -76,55 +55,7 @@ public slots:
*********************************************************/
public:
/**
* \fn bool addMenuAction(const QString& menuPath, QAction* action)
* \brief adds an action in the program menu bar
*
* \param menuPath the menu path (see details below) to specify a location for the action in the menu.
* \param action a pointer to the allocated action to add in the menu. All the details on that action (such as
* QObject::connect() calls) are not dealt in this function.
*
* The menu path is a string used to specify the location of the new action in the menu bar.
* In such path every menu step of the path should be separate by ';'. The action is the last substring after
* the last ';', and will be added in the menu with that name. All non-existing menu specified in the path
* shall be created.
*
* <b>Example 1:</b> if you want to add an entry <em>"action"</em> to the existing menu <em>"Plugins"</em> the
* menu path shall be: <em>Plugins;action</em>
*
* <b>Example 2:</b> if you want to add an entry <em>"action"</em> in a new menu <em>"config"</em> that is also a
* submenu of a new menu <em>"Settings"</em>, the menu path
* shall be: <em>Settings;config;action</em>
*
* A new action should at least belong to one menu (already existing or not). Otherwise the method will fail.
*
* This method is called by Plugin methods
*
* \return a boolean whether the method succeeded or not.
*
* If the function failed, the error code ( Error::code ) is affected with a value
* depending on the error. This error can be shown with Error::showError
*
* \see deleteMenuAction()
* \see Plugin::addMenuAction()
*/
bool addMenuAction(const QString& menuPath, QAction* action);
/**
* \fn void deleteMenuAction(QAction* action)
* \brief delete an action from the menu bar
*
* \param action pointer to the allocated action to delete.
*
* If this action was the only action remaining in a menu, this menu will also be deleted.
*
* \warning DO NOT use this method with an action that hasn't been added with addMenuAction()
*
* This method is called by Plugin methods
*
* \see addMenuAction()
* \see Plugin::removeMenuAction()
*/
void removeMenuAction(QAction* action);
/*********************************************************
......@@ -132,7 +63,6 @@ public:
*********************************************************/
bool addToolbarAction(QAction* action);
void removeToolbarAction(QAction* action);
/*********************************************************
......@@ -173,42 +103,9 @@ public:
public slots:
void registerPluginsDirectory(const QString& path);
/**
* \fn bool loadPlugin(QString pluginPath)
* \brief Loads and references a Plugin
*
* \param pluginPath the absolute path of the Plugin location
*
* The Plugin is loaded and referenced under a name that is the Plugin file name
* where the extension ('.so', '.dylib') and the prefix 'lib' were removed.
*
* <b>Example:</b> <em>/path/libExample.so</em> will be referenced as <em>Example</em>
*
* You have to make sure that a Plugin file with a similar name hasn't been loaded yet, otherwise
* the loading will fail.
*
* This method calls the Plugin::enable() method of the concerned Plugin. That is why
* when Plugin are written, this method is overriden and used as an initialization method.
*
* \return a boolean whether the loading succeeded or not.
*/
Plugin* loadPlugin(const QString& pluginFilePath);
/**
* \fn void unloadPlugin(QString pluginName)
* \brief Unload the Plugin of a given name
*
* \param pluginName the name under which the Plugin is referenced
*
* The Plugin of the given name is dereferenced and deleted, if it exists and was previously
* referenced, if not, the method does nothing.
*
* This method calls the Plugin::disable() method of the concerned Plugin. That is why,
* when Plugin are written, this method is overriden and used as a destruction method.
*/
void unloadPlugin(const QString& pluginName);
public:
Plugin* getPlugin(const QString& name) const;
QList<Plugin*> getPluginsList() const { return h_plugins.values(); }
const PluginHash& getPluginsHash() const { return h_plugins; }
......@@ -219,9 +116,14 @@ public:
* MANAGE MAPS
*********************************************************/
public:
MapHandlerGen* addMap(const QString& name, unsigned int dim);
void removeMap(const QString& name);
public slots:
MapHandlerGen* getMap(const QString& name) const;
public:
QList<MapHandlerGen*> getMapsList() const { return h_maps.values(); }
const MapHash& getMapsHash() const { return h_maps; }
......@@ -288,9 +190,9 @@ public slots:
void cb_showHideDock();
void cb_showHidePythonDock();
void cb_manageCameras();
void cb_managePlugins();
void cb_manageMaps();
void cb_showCamerasDialog();
void cb_showPluginsDialog();
void cb_showMapsDialog();
signals:
void cameraAdded(Camera* camera);
......
#include "camera.h"
#include "dialogs/camerasDialog.h"
namespace CGoGN
{
......@@ -11,12 +12,8 @@ unsigned int Camera::cameraCount = 0;
Camera::Camera(const QString& name, Window* window) :
m_name(name),
m_window(window),
m_draw(true),
m_drawFarPlane(true),
m_drawScale(0.1),
m_draw(false),
m_drawPath(false),
m_drawPathAxis(false),
m_drawPathScale(1.0),
m_snapCount(0)
{
++cameraCount;
......@@ -25,20 +22,31 @@ Camera::Camera(const QString& name, Window* window) :
Camera::~Camera()
{}
void Camera::draw()
void Camera::changeType(qglviewer::Camera::Type type)
{
if(m_draw)
{
qglviewer::Camera::draw(m_drawFarPlane, m_drawScale);
if(m_drawPath)
{
int mask = 1;
if(m_drawPathAxis)
mask = mask | 4;
if(this->keyFrameInterpolator(0))
this->keyFrameInterpolator(0)->drawPath(mask, 6, m_drawPathScale);
}
}
setType(type);
foreach(View* view, m_window->getViewsList())
view->updateGL();
m_window->getCamerasDialog()->setCameraType(m_name, type);
}
void Camera::setDraw(bool b)
{
m_draw = b;
foreach(View* view, m_window->getViewsList())
view->updateGL();
m_window->getCamerasDialog()->setDrawCamera(m_name, b);
}
void Camera::setDrawPath(bool b)
{
m_drawPath = b;
foreach(View* view, m_window->getViewsList())
view->updateGL();
m_window->getCamerasDialog()->setDrawCameraPath(m_name, b);
}
void Camera::linkView(View* view)
......
......@@ -24,11 +24,59 @@ CamerasDialog::CamerasDialog(Window* window) :
connect(m_window, SIGNAL(cameraAdded(Camera*)), this, SLOT(cb_addCameraToList(Camera*)));
connect(m_window, SIGNAL(cameraRemoved(Camera*)), this, SLOT(cb_removeCameraFromList(Camera*)));
connect(cameraList, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(cb_itemChanged(QTreeWidgetItem*,int)));
cameraList->resizeColumnToContents(1);
cameraList->resizeColumnToContents(2);
cameraList->resizeColumnToContents(3);
}
CamerasDialog::~CamerasDialog()
{}
void CamerasDialog::setCameraType(const QString& name, qglviewer::Camera::Type type)
{
b_refreshingUI = true;
QList<QTreeWidgetItem*> items = cameraList->findItems(name, Qt::MatchExactly);
if(!items.empty())
{
if(type == qglviewer::Camera::ORTHOGRAPHIC)
items[0]->setCheckState(1, Qt::Checked);
else
items[0]->setCheckState(1, Qt::Unchecked);
}
b_refreshingUI = false;
}
void CamerasDialog::setDrawCamera(const QString& name, bool b)
{
b_refreshingUI = true;
QList<QTreeWidgetItem*> items = cameraList->findItems(name, Qt::MatchExactly);
if(!items.empty())
{
if(b)