Commit 5c229ffd authored by Pierre Kraemer's avatar Pierre Kraemer

SCHNApps: allow to enable/disable camera fitting to views bounding box

parent 8d7b97a3
......@@ -5,6 +5,8 @@
#include "Algo/Topo/basic.h"
#include "camera.h"
#include <QKeyEvent>
#include <QMouseEvent>
......@@ -153,6 +155,7 @@ void Surface_Deformation_Plugin::keyPress(View* view, QKeyEvent* event)
m_dragging = true;
m_draginit = false;
view->setMouseTracking(true);
view->getCurrentCamera()->disableViewsBoundingBoxFitting();
}
}
else
......@@ -160,6 +163,7 @@ void Surface_Deformation_Plugin::keyPress(View* view, QKeyEvent* event)
m_dragging = false;
m_draginit = false;
view->setMouseTracking(false);
view->getCurrentCamera()->enableViewsBoundingBoxFitting();
}
}
break;
......@@ -184,17 +188,17 @@ void Surface_Deformation_Plugin::keyPress(View* view, QKeyEvent* event)
void Surface_Deformation_Plugin::mouseMove(View* view, QMouseEvent* event)
{
if(m_dragging)
if (m_dragging)
{
MapHandlerGen* mh = m_schnapps->getSelectedMap();
MapParameters& p = h_parameterSet[mh];
const std::vector<Vertex>& handle = p.handleSelector->getSelectedCells();
if(!m_draginit)
if (!m_draginit)
{
m_dragZ = 0;
for(std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
for (std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
{
const PFP2::VEC3& pp = p.positionAttribute[*it];
qglviewer::Vec q = view->camera()->projectedCoordinatesOf(qglviewer::Vec(pp[0],pp[1],pp[2]));
......@@ -214,13 +218,13 @@ void Surface_Deformation_Plugin::mouseMove(View* view, QMouseEvent* event)
qglviewer::Vec vec = qq - m_dragPrevious;
PFP2::VEC3 t(vec.x, vec.y, vec.z);
for(std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
for (std::vector<Vertex>::const_iterator it = handle.begin(); it != handle.end(); ++it)
p.positionAttribute[*it] += t;
m_dragPrevious = qq;
// matchDiffCoord(map);
if(p.initialized)
if (p.initialized)
{
asRigidAsPossible(mh);
mh->notifyAttributeModification(p.positionAttribute);
......
......@@ -37,8 +37,8 @@ public slots:
bool isShared() const { return l_views.size() > 1; }
qglviewer::Camera::Type getProjectionType() { return type(); }
bool getDraw() const { return m_draw; }
bool getDrawPath() const { return m_drawPath; }
bool getDraw() const { return b_draw; }
bool getDrawPath() const { return b_drawPath; }
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
......@@ -47,13 +47,16 @@ public slots:
void setDraw(bool b);
void setDrawPath(bool b);
void enableViewsBoundingBoxFitting() { b_fitToViewsBoundingBox = true; }
void disableViewsBoundingBoxFitting() { b_fitToViewsBoundingBox = false; }
private:
void linkView(View* view);
void unlinkView(View* view);
private slots:
void frameModified();
void updateParams();
void fitToViewsBoundingBox();
signals:
void projectionTypeChanged(int);
......@@ -66,8 +69,10 @@ protected:
QList<View*> l_views;
bool m_draw;
bool m_drawPath;
bool b_draw;
bool b_drawPath;
bool b_fitToViewsBoundingBox;
};
} // namespace SCHNApps
......
......@@ -50,19 +50,13 @@ public slots:
GenericMap* getGenericMap() const { return m_map; }
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
float getBBdiagSize() const { return m_bbDiagSize; }
Utils::GLSLShader* getBBDrawerShader() const
{
if(m_bbDrawer)
return m_bbDrawer->getShader();
else
return NULL;
}
/*********************************************************
* MANAGE FRAME
*********************************************************/
public slots:
qglviewer::ManipulatedFrame* getFrame() const { return m_frame; }
glm::mat4 getFrameMatrix() const
{
GLdouble m[16];
......@@ -76,19 +70,27 @@ public slots:
return matrix;
}
private slots:
void frameModified()
{
DEBUG_EMIT("frameModified");
emit(boundingBoxModified());
}
/*********************************************************
* MANAGE BOUNDING BOX
*********************************************************/
public slots:
void setBBVertexAttribute(const QString& name)
{
m_bbVertexAttribute = m_map->getAttributeVectorGen(VERTEX, name.toStdString());
updateBB();
}
AttributeMultiVectorGen* getBBVertexAttribute() { return m_bbVertexAttribute; }
QString getBBVertexAttributeName()
AttributeMultiVectorGen* getBBVertexAttribute() const { return m_bbVertexAttribute; }
QString getBBVertexAttributeName() const
{
if (m_bbVertexAttribute)
return QString::fromStdString(m_bbVertexAttribute->getName());
......@@ -96,15 +98,29 @@ public slots:
return QString();
}
public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
virtual void drawBB() = 0;
float getBBdiagSize() const { return m_bbDiagSize; }
Utils::GLSLShader* getBBDrawerShader() const
{
if(m_bbDrawer)
return m_bbDrawer->getShader();
else
return NULL;
}
virtual void transformedBB(qglviewer::Vec& bbMin, qglviewer::Vec& bbMax) = 0;
protected:
virtual void updateBB() = 0;
/*********************************************************
* MANAGE DRAWING
*********************************************************/
public:
virtual void draw(Utils::GLSLShader* shader, int primitive) = 0;
virtual void drawBB() = 0;
void setPrimitiveDirty(int primitive) { m_render->setPrimitiveDirty(primitive); }
/*********************************************************
......@@ -171,11 +187,15 @@ private:
void linkView(View* view);
void unlinkView(View* view);
public slots:
const QList<View*>& getLinkedViews() const { return l_views; }
bool isLinkedToView(View* view) const { return l_views.contains(view); }
/*********************************************************
* MANAGE TOPO_RENDERING
*********************************************************/
public:
public:
virtual void createTopoRender(CGoGN::Utils::GLSLShader* s) = 0;
void deleteTopoRender();
virtual void updateTopoRender(const QString& positionAttributeName) = 0;
......
......@@ -4,7 +4,9 @@
#include <QMap>
#include <QString>
#include "Topology/generic/parameters.h"
#include "Geometry/vector_gen.h"
#include "Geometry/matrix.h"
#include "Topology/generic/attributeHandler.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
......@@ -17,12 +19,28 @@ class VBO;
class GLSLShader;
}
struct PFP2: public PFP_STANDARD
struct PFP_SCHNAPPS
{
typedef float REAL;
typedef Geom::Vector<3,REAL> VEC3;
typedef Geom::Vector<4,REAL> VEC4;
typedef Geom::Vector<6,REAL> VEC6;
typedef Geom::Matrix<3,3,REAL> MATRIX33;
typedef Geom::Matrix<4,4,REAL> MATRIX44;
typedef Geom::Matrix<3,6,REAL> MATRIX36;
static inline Geom::Vec3f toVec3f(const VEC3& P)
{
return P;
}
};
struct PFP2 : public PFP_SCHNAPPS
{
typedef EmbeddedMap2 MAP;
};
struct PFP3: public PFP_STANDARD
struct PFP3 : public PFP_SCHNAPPS
{
typedef EmbeddedMap3 MAP;
};
......@@ -39,7 +57,6 @@ class Camera;
class MapHandlerGen;
class CellSelectorGen;
struct Texture;
class ObjectHandlerGen;
typedef QMap<QString, Plugin*> PluginSet;
typedef QMap<QString, View*> ViewSet;
......@@ -49,11 +66,8 @@ typedef QMap<QString, Utils::VBO*> VBOSet;
typedef QMap<QString, QString> AttributeSet;
typedef QMap<QString, CellSelectorGen*> CellSelectorSet;
typedef QMap<QString, Utils::GLSLShader*> ShaderSet;
typedef QMap<QString, Texture*> TextureSet;
typedef QMap<QString, ObjectHandlerGen*> ObjectSet;
} // namespace SCHNApps
} // namespace CGoGN
......
......@@ -14,8 +14,9 @@ unsigned int Camera::cameraCount = 0;
Camera::Camera(const QString& name, SCHNApps* s) :
m_name(name),
m_schnapps(s),
m_draw(false),
m_drawPath(false)
b_draw(false),
b_drawPath(false),
b_fitToViewsBoundingBox(true)
{
++cameraCount;
connect(this->frame(), SIGNAL(modified()), this, SLOT(frameModified()));
......@@ -35,7 +36,7 @@ void Camera::setProjectionType(int t)
void Camera::setDraw(bool b)
{
m_draw = b;
b_draw = b;
DEBUG_EMIT("drawChanged");
emit(drawChanged(b));
foreach(View* view, m_schnapps->getViewSet().values())
......@@ -44,7 +45,7 @@ void Camera::setDraw(bool b)
void Camera::setDrawPath(bool b)
{
m_drawPath = b;
b_drawPath = b;
DEBUG_EMIT("drawPathChanged");
emit(drawPathChanged(b));
foreach(View* view, m_schnapps->getViewSet().values())
......@@ -56,8 +57,8 @@ void Camera::linkView(View* view)
if(view && !l_views.contains(view))
{
l_views.push_back(view);
updateParams();
connect(view, SIGNAL(boundingBoxChanged()), this, SLOT(updateParams()));
fitToViewsBoundingBox();
connect(view, SIGNAL(boundingBoxChanged()), this, SLOT(fitToViewsBoundingBox()));
}
}
......@@ -65,14 +66,14 @@ void Camera::unlinkView(View* view)
{
if (l_views.removeOne(view))
{
updateParams();
disconnect(view, SIGNAL(boundingBoxChanged()), this, SLOT(updateParams()));
fitToViewsBoundingBox();
disconnect(view, SIGNAL(boundingBoxChanged()), this, SLOT(fitToViewsBoundingBox()));
}
}
void Camera::frameModified()
{
if(m_draw || m_drawPath)
if(b_draw || b_drawPath)
{
foreach(View* view, m_schnapps->getViewSet().values())
view->updateGL();
......@@ -84,37 +85,40 @@ void Camera::frameModified()
}
}
void Camera::updateParams()
void Camera::fitToViewsBoundingBox()
{
qglviewer::Vec bbMin;
qglviewer::Vec bbMax;
if (!l_views.empty())
if (b_fitToViewsBoundingBox)
{
l_views.first()->getBB(bbMin, bbMax);
qglviewer::Vec bbMin;
qglviewer::Vec bbMax;
foreach(View* v, l_views)
if (!l_views.empty())
{
qglviewer::Vec minbb;
qglviewer::Vec maxbb;
v->getBB(minbb, maxbb);
for(unsigned int dim = 0; dim < 3; ++dim)
l_views.first()->getBB(bbMin, bbMax);
foreach(View* v, l_views)
{
if(minbb[dim] < bbMin[dim])
bbMin[dim] = minbb[dim];
if(maxbb[dim] > bbMax[dim])
bbMax[dim] = maxbb[dim];
qglviewer::Vec minbb;
qglviewer::Vec maxbb;
v->getBB(minbb, maxbb);
for(unsigned int dim = 0; dim < 3; ++dim)
{
if(minbb[dim] < bbMin[dim])
bbMin[dim] = minbb[dim];
if(maxbb[dim] > bbMax[dim])
bbMax[dim] = maxbb[dim];
}
}
}
}
else
{
bbMin.setValue(0, 0, 0);
bbMax.setValue(0, 0, 0);
}
else
{
bbMin.setValue(0, 0, 0);
bbMax.setValue(0, 0, 0);
}
this->setSceneBoundingBox(bbMin, bbMax);
this->showEntireScene();
this->setSceneBoundingBox(bbMin, bbMax);
this->showEntireScene();
}
}
} // namespace SCHNApps
......
......@@ -289,7 +289,7 @@ void ControlDock_MapTab::updateSelectedMapInfo()
combo_bbVertexAttribute->clear();
combo_bbVertexAttribute->addItem("- select attribute -");
QString vec3TypeName = QString::fromStdString(nameOfType(PFP_STANDARD::VEC3()));
QString vec3TypeName = QString::fromStdString(nameOfType(PFP_SCHNAPPS::VEC3()));
list_dartAttributes->clear();
list_vertexAttributes->clear();
......
......@@ -201,7 +201,7 @@ void View::setCurrentCamera(Camera* c)
}
}
m_currentCamera->updateParams();
m_currentCamera->fitToViewsBoundingBox();
updateGL();
}
}
......
......@@ -43,10 +43,10 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fPIC")
#SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}${BINARIES_RELATIVE_PATH})
IF (EXISTS ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
MESSAGE(INFO: "Using local options file: " ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
INCLUDE(${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/OpenNL/CMakeOptions.txt)
IF (EXISTS ${CMAKE_SOURCE_DIR}/ThirdParty/OpenNL/CMakeOptions.txt)
MESSAGE(INFO: "Using local options file: " ${CMAKE_SOURCE_DIR}/ThirdParty/OpenNL/CMakeOptions.txt)
INCLUDE(${CMAKE_SOURCE_DIR}/ThirdParty/OpenNL/CMakeOptions.txt)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/ThirdParty/OpenNL/CMakeOptions.txt)
IF(USE_CNC)
ADD_DEFINITIONS(-DNL_USE_CNC)
......
......@@ -33,7 +33,6 @@
# plateforms.
##################################################################
SET(CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules)
# build exemple programs
......@@ -69,6 +68,7 @@ SET(USE_CHOLMOD TRUE)
IF (NOT WIN32)
find_package(SuiteSparse REQUIRED)
ENDIF (NOT WIN32)
###########
# CNC
###########
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment