Commit b1a3537f authored by Jan Möbius's avatar Jan Möbius
Browse files

Dennis: Datacontrol selection as bounding box

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@6120 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d5a3a898
...@@ -55,6 +55,12 @@ ...@@ -55,6 +55,12 @@
//****************************************************************************** //******************************************************************************
const ACG::Vec4f base_color (0.0,0.0,0.5,1.0);
const ACG::Vec4f source_color (0.5,0.0,0.0,1.0);
const ACG::Vec4f target_color (0.0,0.5,0.2,1.0);
//******************************************************************************
/** \brief Plugin initialization /** \brief Plugin initialization
* *
*/ */
...@@ -111,28 +117,17 @@ bool DataControlPlugin::initializeToolbox(QWidget*& _widget) ...@@ -111,28 +117,17 @@ bool DataControlPlugin::initializeToolbox(QWidget*& _widget)
_widget = tool_; _widget = tool_;
QSize size(300, 300); QSize size(300, 300);
tool_->resize(size); tool_->resize(size);
MeshDialogLayout_ = new QGridLayout( tool_);
model_ = new TreeModel( ); model_ = new TreeModel( );
view_ = new QTreeView(0); view_ = tool_->treeView;
view_->setModel(model_);
view_->setMinimumHeight(400); tool_->treeView->setModel(model_);
view_->QTreeView::resizeColumnToContents(1); view_->QTreeView::resizeColumnToContents(1);
view_->QTreeView::resizeColumnToContents(2); view_->QTreeView::resizeColumnToContents(2);
view_->QTreeView::resizeColumnToContents(3); view_->QTreeView::resizeColumnToContents(3);
view_->setContextMenuPolicy(Qt::CustomContextMenu);
view_->setDragEnabled(true);
view_->setAcceptDrops(true);
view_->setDropIndicatorShown(true);
view_->setSelectionBehavior(QAbstractItemView::SelectRows);
view_->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect( model_,SIGNAL(dataChangedInside(int,int,const QVariant&) ), connect( model_,SIGNAL(dataChangedInside(int,int,const QVariant&) ),
this, SLOT( slotDataChanged(int,int,const QVariant&)) ); this, SLOT( slotDataChanged(int,int,const QVariant&)) );
...@@ -143,10 +138,15 @@ bool DataControlPlugin::initializeToolbox(QWidget*& _widget) ...@@ -143,10 +138,15 @@ bool DataControlPlugin::initializeToolbox(QWidget*& _widget)
connect( view_,SIGNAL(customContextMenuRequested ( const QPoint & ) ), connect( view_,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
this,SLOT(slotCustomContextMenuRequested ( const QPoint & ) )); this,SLOT(slotCustomContextMenuRequested ( const QPoint & ) ));
connect( tool_->notSelected, SIGNAL(stateChanged ( int ) ),
this, SLOT (slotBoundingBoxChange ( ) ));
connect( tool_->sourceSelected, SIGNAL(stateChanged ( int ) ),
this, SLOT (slotBoundingBoxChange ( ) ));
connect( tool_->targetSelected, SIGNAL(stateChanged ( int ) ),
this, SLOT (slotBoundingBoxChange ( ) ));
MeshDialogLayout_->addWidget( view_ , 0,0 );
viewHeader_ = view_->header(); viewHeader_ = tool_->treeView->header();
viewHeader_->setContextMenuPolicy(Qt::CustomContextMenu); viewHeader_->setContextMenuPolicy(Qt::CustomContextMenu);
// connect the slot for the context menu // connect the slot for the context menu
...@@ -169,6 +169,8 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier ) ...@@ -169,6 +169,8 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
if ( PluginFunctions::getObject( _identifier, obj) ){ if ( PluginFunctions::getObject( _identifier, obj) ){
updateBoundingBox (obj);
if ( obj->target() ) { if ( obj->target() ) {
obj->materialNode()->disable_blending(); obj->materialNode()->disable_blending();
OpenMesh::Vec4f base_color = obj->materialNode()->base_color(); OpenMesh::Vec4f base_color = obj->materialNode()->base_color();
...@@ -213,7 +215,7 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier ) ...@@ -213,7 +215,7 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
//****************************************************************************** //******************************************************************************
/** \brief Update the model if the visibility of an object changed /** \brief Update the model if the visibility of an object changed
* *
* @param _identifier id of an object * @param _identifier id of an object
*/ */
void DataControlPlugin::slotVisibilityChanged( int _identifier ){ void DataControlPlugin::slotVisibilityChanged( int _identifier ){
...@@ -230,13 +232,18 @@ void DataControlPlugin::slotVisibilityChanged( int _identifier ){ ...@@ -230,13 +232,18 @@ void DataControlPlugin::slotVisibilityChanged( int _identifier ){
propagateDownwards(obj, 1); // 1 = visibilty propagateDownwards(obj, 1); // 1 = visibilty
} }
BaseObjectData* object = 0;
if ( PluginFunctions::getObject( _identifier, object) )
updateBoundingBox (object);
} }
//****************************************************************************** //******************************************************************************
/** \brief Update the model if properties of an object changed /** \brief Update the model if properties of an object changed
* *
* @param _identifier id of an object * @param _identifier id of an object
*/ */
void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){ void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){
...@@ -247,7 +254,7 @@ void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){ ...@@ -247,7 +254,7 @@ void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){
//****************************************************************************** //******************************************************************************
/** \brief Update the model if an object was deleted /** \brief Update the model if an object was deleted
* *
* @param _identifier id of an object * @param _identifier id of an object
*/ */
void DataControlPlugin::slotObjectUpdated( int _identifier ){ void DataControlPlugin::slotObjectUpdated( int _identifier ){
...@@ -258,7 +265,7 @@ void DataControlPlugin::slotObjectUpdated( int _identifier ){ ...@@ -258,7 +265,7 @@ void DataControlPlugin::slotObjectUpdated( int _identifier ){
//****************************************************************************** //******************************************************************************
/** \brief Update the model if a file has been opened /** \brief Update the model if a file has been opened
* *
* @param _id id of an object * @param _id id of an object
*/ */
void DataControlPlugin::fileOpened(int _id){ void DataControlPlugin::fileOpened(int _id){
...@@ -273,7 +280,7 @@ void DataControlPlugin::fileOpened(int _id){ ...@@ -273,7 +280,7 @@ void DataControlPlugin::fileOpened(int _id){
//****************************************************************************** //******************************************************************************
/** \brief Update the model if an empty object has been added /** \brief Update the model if an empty object has been added
* *
* @param _id id of an object * @param _id id of an object
*/ */
void DataControlPlugin::addedEmptyObject(int _id){ void DataControlPlugin::addedEmptyObject(int _id){
...@@ -283,7 +290,7 @@ void DataControlPlugin::addedEmptyObject(int _id){ ...@@ -283,7 +290,7 @@ void DataControlPlugin::addedEmptyObject(int _id){
//****************************************************************************** //******************************************************************************
/** \brief an object was deleted. delete it internally /** \brief an object was deleted. delete it internally
* *
* @param _id id of the object * @param _id id of the object
*/ */
void DataControlPlugin::objectDeleted(int _id){ void DataControlPlugin::objectDeleted(int _id){
...@@ -369,7 +376,7 @@ void DataControlPlugin::slotDataChanged ( int _id, int _column, const QVariant& ...@@ -369,7 +376,7 @@ void DataControlPlugin::slotDataChanged ( int _id, int _column, const QVariant&
//****************************************************************************** //******************************************************************************
/** \brief Gets called when an object was moved via drag n drop /** \brief Gets called when an object was moved via drag n drop
* *
* @param _id id of the object * @param _id id of the object
* @param _parentId id of the new parent * @param _parentId id of the new parent
*/ */
...@@ -410,6 +417,18 @@ void DataControlPlugin::slotMoveBaseObject(int _id, int _newParentId){ ...@@ -410,6 +417,18 @@ void DataControlPlugin::slotMoveBaseObject(int _id, int _newParentId){
* @param _ini an ini file * @param _ini an ini file
*/ */
void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) { void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) {
if ( _ini.section_exists( "BoundingBox" ) )
{
bool value;
if (_ini.get_entry(value, "BoundingBox","notSelected"))
tool_->notSelected->setChecked (value);
if (_ini.get_entry(value, "BoundingBox","sourceSelected"))
tool_->sourceSelected->setChecked (value);
if (_ini.get_entry(value, "BoundingBox","targetSelected"))
tool_->targetSelected->setChecked (value);
}
if ( !_ini.section_exists( "Groups" ) ) if ( !_ini.section_exists( "Groups" ) )
return; return;
...@@ -501,6 +520,7 @@ void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) { ...@@ -501,6 +520,7 @@ void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) {
* @param _ini an ini file * @param _ini an ini file
*/ */
void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) { void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) {
if ( !_ini.section_exists( "Groups" ) ) if ( !_ini.section_exists( "Groups" ) )
_ini.add_section("Groups"); _ini.add_section("Groups");
...@@ -562,13 +582,20 @@ void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) { ...@@ -562,13 +582,20 @@ void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) {
// Write the primary group names to the file // Write the primary group names to the file
_ini.add_entry("Groups","rootGroup",rootGroup); _ini.add_entry("Groups","rootGroup",rootGroup);
if ( !_ini.section_exists( "BoundingBox" ) )
_ini.add_section("BoundingBox");
_ini.add_entry("BoundingBox","notSelected",tool_->notSelected->isChecked ());
_ini.add_entry("BoundingBox","sourceSelected",tool_->sourceSelected->isChecked ());
_ini.add_entry("BoundingBox","targetSelected",tool_->targetSelected->isChecked ());
} }
//****************************************************************************** //******************************************************************************
/** \brief Recursively update a column up to the root of the tree /** \brief Recursively update a column up to the root of the tree
* *
* @param _obj object to start with * @param _obj object to start with
*/ */
void DataControlPlugin::propagateUpwards(BaseObject* _obj, int _column ){ void DataControlPlugin::propagateUpwards(BaseObject* _obj, int _column ){
...@@ -625,7 +652,7 @@ void DataControlPlugin::propagateUpwards(BaseObject* _obj, int _column ){ ...@@ -625,7 +652,7 @@ void DataControlPlugin::propagateUpwards(BaseObject* _obj, int _column ){
//****************************************************************************** //******************************************************************************
/** \brief Recursively update a column up to the root of the tree /** \brief Recursively update a column up to the root of the tree
* *
* @param _obj object to start with * @param _obj object to start with
*/ */
void DataControlPlugin::propagateDownwards(BaseObject* _obj, int _column ){ void DataControlPlugin::propagateDownwards(BaseObject* _obj, int _column ){
...@@ -673,6 +700,57 @@ void DataControlPlugin::propagateDownwards(BaseObject* _obj, int _column ){ ...@@ -673,6 +700,57 @@ void DataControlPlugin::propagateDownwards(BaseObject* _obj, int _column ){
} }
} }
//******************************************************************************
/** \brief Bounding box visibility selection changed
*/
void DataControlPlugin::slotBoundingBoxChange( )
{
for (PluginFunctions::ObjectIterator o_it; o_it != PluginFunctions::objectsEnd(); ++o_it) {
updateBoundingBox (o_it);
}
emit updateView();
}
//******************************************************************************
/** \brief Update state of bounding box node
*
* @param _obj object
*/
void DataControlPlugin::updateBoundingBox(BaseObjectData* _obj)
{
if (tool_->notSelected->isChecked () ||
(_obj->source () && tool_->sourceSelected->isChecked ()) ||
(_obj->target () && tool_->targetSelected->isChecked ()))
{
_obj->boundingBoxNode()->set_status( ACG::SceneGraph::BaseNode::Active );
ACG::Vec4f color = base_color;
if (_obj->source () && tool_->sourceSelected->isChecked ())
color += source_color;
if (_obj->target () && tool_->targetSelected->isChecked ())
color += target_color;
_obj->boundingBoxNode()->set_base_color (color);
}
else
_obj->boundingBoxNode()->set_status( ACG::SceneGraph::TranslationManipulatorNode::HideNode );
}
//******************************************************************************
/** \brief Save settings before application is closed
*
* @param _ini reference to ini file
*/
void DataControlPlugin::saveOnExit(INIFile& _ini){
}
Q_EXPORT_PLUGIN2( datacontrolplugin , DataControlPlugin ); Q_EXPORT_PLUGIN2( datacontrolplugin , DataControlPlugin );
...@@ -100,6 +100,7 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn ...@@ -100,6 +100,7 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
// INIInterface // INIInterface
void loadIniFileOptionsLast( INIFile& _ini ); void loadIniFileOptionsLast( INIFile& _ini );
void saveIniFileOptions( INIFile& _ini ); void saveIniFileOptions( INIFile& _ini );
void saveOnExit(INIFile& _ini );
// LoadSaveInterface // LoadSaveInterface
void fileOpened(int _id); void fileOpened(int _id);
...@@ -233,6 +234,23 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn ...@@ -233,6 +234,23 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
/** @} */ /** @} */
//===========================================================================
/** @name Bounding box related slots/functions
* @{ */
//===========================================================================
private slots:
/// Bounding box selection changed
void slotBoundingBoxChange( );
private:
/// Updates bounding box
void updateBoundingBox(BaseObjectData* _obj);
/** @} */
//=========================================================================== //===========================================================================
/** @name Scripting functions /** @name Scripting functions
* @{ */ * @{ */
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
DatacontrolToolboxWidget::DatacontrolToolboxWidget(QWidget* _parent) DatacontrolToolboxWidget::DatacontrolToolboxWidget(QWidget* _parent)
: QWidget(_parent) : QWidget(_parent)
{ {
setupUi(this);
} }
......
#include "ui_toolbox.hh"
#include <QtGui> #include <QtGui>
class DatacontrolToolboxWidget : public QWidget class DatacontrolToolboxWidget : public QWidget, public Ui::dctoolbox
{ {
Q_OBJECT Q_OBJECT
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>dctoolbox</class>
<widget class="QWidget" name="dctoolbox">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>333</width>
<height>448</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTreeView" name="treeView">
<property name="minimumSize">
<size>
<width>0</width>
<height>250</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="dragEnabled">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Object Bounding Box</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="notSelected">
<property name="text">
<string>Not selected</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="sourceSelected">
<property name="text">
<string>Source</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="targetSelected">
<property name="text">
<string>Target</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Supports Markdown
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