Commit 87aed8c0 authored by Jan Möbius's avatar Jan Möbius

Separated Plane Datatype

parents
include(ACGCommon)
include_directories (
..
${ACG_INCLUDE_DIR}
${OPENMESH_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
)
link_directories (
${GLEW_LIBRARY_DIR}
${ADDITIONAL_PLUGINLIB_LINK_DIRS}
)
#=======================================================
# General defines
#=======================================================
# generate dllexport macros on windows
if (WIN32)
add_definitions (
-DPLUGINLIBDLL
-DACGDLL
-DUSEACG
)
endif ()
#=======================================================
# Cleanup
#=======================================================
# remove template cc files from source file list
acg_drop_templates (sources)
# collect all header,source files
acg_append_files (headers "*.hh" . )
acg_append_files (sources "*.cc" . )
# Match our current directory name
string (REGEX MATCH "[^/\\]*$" TYPENAME ${CMAKE_CURRENT_SOURCE_DIR})
string(TOUPPER ${TYPENAME} TYPENAME )
include_directories (
..
${ACG_INCLUDE_DIR}
${OPENMESH_INCLUDE_DIRS}
${CMAKE_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../..
${CMAKE_CURRENT_BINARY_DIR}
${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLUT_INCLUDE_DIR}
)
acg_add_library ( ${TYPENAME} SHARED ${sources} ${headers} )
add_dependencies( ${TYPENAME} OpenMeshCore OpenMeshTools ACG OpenFlipperPluginLib)
target_link_libraries (${TYPENAME}
${OPENMESH_LIBRARIES}
ACG
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${GLUT_LIBRARIES}
PluginLib
)
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
/**
* \file Plane.hh
* This File contains all required includes for using Planes
*/
#ifndef PLANE_INCLUDE_HH
#define PLANE_INCLUDE_HH
//== INCLUDES =================================================================
/** \def DATA_PLANE
* Use this macro to reference Plane objects
*/
#define DATA_PLANE typeId("Plane")
#include <ObjectTypes/Plane/PlaneObject.hh>
#include <ObjectTypes/Plane/PluginFunctionsPlane.hh>
#include <ObjectTypes/Plane/PlaneTypes.hh>
//=============================================================================
#endif // PLANE_INCLUDE_HH defined
//=============================================================================
This diff is collapsed.
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $Author$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// CLASS PointNode
//
//=============================================================================
#ifndef PLANENODE_HH
#define PLANENODE_HH
//== INCLUDES =================================================================
#include <ObjectTypes/Plane/PlaneType.hh>
#include <ACG/Scenegraph/BaseNode.hh>
#include <ACG/Scenegraph/DrawModes.hh>
#include <ACG/Math/Matrix4x4T.hh>
#include <OpenFlipper/common/GlobalDefines.hh>
#include <ACG/GL/VertexDeclaration.hh>
#include <ACG/GL/IRenderer.hh>
#include <ACG/GL/GLPrimitives.hh>
//== NAMESPACES ===============================================================
//== CLASS DEFINITION =========================================================
class DLLEXPORT PlaneNode : public ACG::SceneGraph::BaseNode
{
public:
/** \brief Construct a plane rendering node
*
* @param _parent The parent node in the scenegraph
* @param _name The name of the new node (visible in the scenegraph dialogs)
* @param _plane A pointer to an existing plane
*/
PlaneNode(Plane& _plane, BaseNode *_parent = 0, std::string _name = "<PlaneNode>");
/// destructor
~PlaneNode();
/// static name of this class
ACG_CLASSNAME(PlaneNode);
/// return available draw modes
ACG::SceneGraph::DrawModes::DrawMode availableDrawModes() const;
/// update bounding box
void boundingBox(ACG::Vec3d & _bbMin, ACG::Vec3d & _bbMax);
/// draw Plane
void draw(ACG::GLState & _state, const ACG::SceneGraph::DrawModes::DrawMode & _drawMode);
/// draw Plane for object picking
void pick(ACG::GLState & _state, ACG::SceneGraph::PickTarget _target);
/// get center position of the plane
ACG::Vec3d position();
/// get current normal
ACG::Vec3d normal();
/// local x direction (multiplied with width)
ACG::Vec3d xDirection();
/// local y direction (multiplied with height)
ACG::Vec3d yDirection();
/// Get the currently rendered plane
Plane& getPlane();
/// Set a new plane for rendering
void setPlane(Plane plane);
/** \brief Add the objects to the given renderer
*
* @param _renderer The renderer which will be used. Add your geometry into this class
* @param _state The current GL State when this object is called
* @param _drawMode The active draw mode
* @param _mat Current material
*/
void getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::SceneGraph::DrawModes::DrawMode& _drawMode , const ACG::SceneGraph::Material* _mat);
/// updates the plane before the next render call
void update();
private:
void drawPlane(ACG::GLState & _state);
void drawManipulator(ACG::GLState & _state);
void drawPlanePick(ACG::GLState & _state);
void drawManipulatorPick(ACG::GLState & _state);
/// create and update VBO
void updateVBO();
void addSphereAt(ACG::Vec3d _pos, ACG::IRenderer* _renderer, ACG::GLState& _state, ACG::RenderObject* _ro);
Plane& plane_;
/// VBO used to render the plane
unsigned int vbo_;
bool vboNeedsUpdate_;
ACG::VertexDeclaration vertexDecl_;
ACG::GLSphere* sphere_;
};
//=============================================================================
#endif // ACG_PLANENODE_HH defined
//=============================================================================
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// Plane Object
//
//=============================================================================
#define PLANEOBJECT_C
//== INCLUDES =================================================================
#include <OpenFlipper/common/Types.hh>
#include "Plane.hh"
//== DEFINES ==================================================================
//== TYPEDEFS =================================================================
//== CLASS DEFINITION =========================================================
/** Constructor for Plane Objects. This object class gets a Separator Node giving
* the root node to which it should be connected. The plane is generated internally
* and all nodes for visualization will be added below the scenegraph node.\n
* You dont need to create an object of this type manually. Use
* the functions from LoadSaveInterface ( addEmpty() )
*/
PlaneObject::PlaneObject( ) :
BaseObjectData( ),
planeNode_(NULL)
{
setDataType(DATA_PLANE);
init();
}
//=============================================================================
/**
* Copy Constructor - generates a copy of the given object
*/
PlaneObject::PlaneObject(const PlaneObject & _object) :
BaseObjectData(_object)
{
init( &_object.plane_ );
setName( name() );
}
/** Destructor for Plane Objects. The destructor deletes the Line and all
* Scenegraph nodes associated with the Plane or the object.
*/
PlaneObject::~PlaneObject()
{
// Delete the data attached to this object ( this will remove all perObject data)
// Not the best way to do it but it will work.
// This is only necessary if people use references to the plane below and
// they do something with the plane in the destructor of their
// perObjectData.
deleteData();
// No need to delete the scenegraph Nodes as this will be managed by baseplugin
planeNode_ = NULL;
}
/** Cleanup Function for Plane Objects. Deletes the contents of the whole object and
* calls PlaneObject::init afterwards.
*/
void PlaneObject::cleanup() {
BaseObjectData::cleanup();
planeNode_ = NULL;
setDataType(DATA_PLANE);
setTypeIcon(DATA_PLANE,"PlaneType.png");
init();
}
/**
* Generate a copy
*/
BaseObject* PlaneObject::copy() {
PlaneObject* object = new PlaneObject(*this);
return dynamic_cast< BaseObject* >(object);
}
/** This function initializes the plane object. It creates the scenegraph nodes.
*/
void PlaneObject::init(const Plane* _plane) {
if ( materialNode() == NULL) {
std::cerr << "Error when creating Plane Object! materialNode is NULL!" << std::endl;
return;
}
planeNode_ = new PlaneNode( plane_, materialNode() , "NEW PlaneNode" );
if (_plane){
plane_ = *_plane;
} else {
plane_.setPlane( ACG::Vec3d(0.0, 0.0, 0.0), ACG::Vec3d(0.0, 1.0, 0.0) );
plane_.setSize( 5.0, 5.0 );
}
materialNode()->set_point_size(3.0);
}
// ===============================================================================
// Name/Path Handling
// ===============================================================================
/** Set the name of an object. All Scenegraph nodes are renamed too. It also calls
* BaseObjectData::setName.
*/
void PlaneObject::setName( QString _name ) {
BaseObjectData::setName(_name);
std::string nodename = std::string("PlaneNode for Plane " + _name.toUtf8() );
planeNode_->name( nodename );
}
// ===============================================================================
// Visualization
// ===============================================================================
PlaneNode* PlaneObject::planeNode() {
return planeNode_;
}
// ===============================================================================
// Object information
// ===============================================================================
/** Returns a string containing all information about the current object. This also
* includes the information provided by BaseObjectData::getObjectinfo
*
* @return String containing the object information
*/
QString PlaneObject::getObjectinfo() {
QString output;
output += "========================================================================\n";
output += BaseObjectData::getObjectinfo();
if ( dataType( DATA_PLANE ) )
output += "Object Contains Plane : ";
ACG::Vec3d pos = planeNode_->position();
ACG::Vec3d nor = planeNode_->normal();
output += " Position ( " + QString::number(pos[0]) + ", " + QString::number(pos[1]) + ", " + QString::number(pos[2]) + ")";
output += " Normal ( " + QString::number(nor[0]) + ", " + QString::number(nor[1]) + ", " + QString::number(nor[2]) + ")";
output += "========================================================================\n";
return output;
}
// ===============================================================================
// Content
// ===============================================================================
void PlaneObject::update(UpdateType _type) {
if (planeNode_)
planeNode_->update();
}
// ===============================================================================
// Data
// ===============================================================================
Plane& PlaneObject::plane() {
return plane_;
}
void PlaneObject::plane(Plane _plane) {
plane_ = _plane;
}
// ===============================================================================
// Picking
// ===============================================================================
/** Given an node index from PluginFunctions::scenegraphPick this function can be used to
* check if the planeNode of the object has been picked.
*
* @param _node_idx Index of the picked plane node
* @return bool if the planeNode of this object is the picking target.
*/
bool PlaneObject::picked( uint _node_idx ) {
return ( _node_idx == planeNode_->id() );
}
void PlaneObject::enablePicking( bool _enable ) {
planeNode_->enablePicking( _enable );
}
bool PlaneObject::pickingEnabled() {
return planeNode_->pickingEnabled();
}
//=============================================================================
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (c) 2001-2015, RWTH-Aachen University *
* Department of Computer Graphics and Multimedia *
* All rights reserved. *
* www.openflipper.org *
* *
*---------------------------------------------------------------------------*
* This file is part of OpenFlipper. *
*---------------------------------------------------------------------------*
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions *
* are met: *
* *
* 1. Redistributions of source code must retain the above copyright notice, *
* this list of conditions and the following disclaimer. *
* *
* 2. Redistributions in binary form must reproduce the above copyright *
* notice, this list of conditions and the following disclaimer in the *
* documentation and/or other materials provided with the distribution. *
* *
* 3. Neither the name of the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
//=============================================================================
//
// Types
//
//=============================================================================
/**
* \file PlaneObject.hh
* This File contains the Plane Object
*/
#ifndef PLANEOBJECT_HH
#define PLANEOBJECT_HH
//== INCLUDES =================================================================
#include <OpenFlipper/common/BaseObjectData.hh>
#include <OpenFlipper/common/GlobalDefines.hh>
#include "PlaneTypes.hh"
//== TYPEDEFS =================================================================
// //== CLASS DEFINITION =========================================================
class DLLEXPORT PlaneObject : public BaseObjectData {
friend class TypePlanePlugin;
public:
/// constructor
PlaneObject();
/** \brief copy constructor
*
* Create a copy of this object
*/
PlaneObject(const PlaneObject& _object);
/// destructor
virtual ~PlaneObject();
/// Reset current object, including all related nodes.
virtual void cleanup();
/** return a full copy of this object ( All scenegraph nodes will be created )
* but the object will not be a part of the object tree.
*/
BaseObject* copy();
protected:
/// Initialize current object, including all related nodes.
virtual void init(const Plane* _plane = 0);
//===========================================================================
/** @name Name and Path handling
* @{ */
//===========================================================================
public:
/// Set the name of the Object
void setName( QString _name );
//===========================================================================
/** @name Data
* @{ */
//===========================================================================
public:
Plane& plane();