Skip to content
Snippets Groups Projects
Commit bcdf8551 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 6a0516c0
Branches
No related tags found
No related merge requests found
......@@ -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
*
*/
......@@ -111,28 +117,17 @@ bool DataControlPlugin::initializeToolbox(QWidget*& _widget)
_widget = tool_;
QSize size(300, 300);
tool_->resize(size);
MeshDialogLayout_ = new QGridLayout( tool_);
model_ = new TreeModel( );
view_ = new QTreeView(0);
view_->setModel(model_);
view_ = tool_->treeView;
view_->setMinimumHeight(400);
tool_->treeView->setModel(model_);
view_->QTreeView::resizeColumnToContents(1);
view_->QTreeView::resizeColumnToContents(2);
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&) ),
this, SLOT( slotDataChanged(int,int,const QVariant&)) );
......@@ -143,10 +138,15 @@ bool DataControlPlugin::initializeToolbox(QWidget*& _widget)
connect( view_,SIGNAL(customContextMenuRequested ( 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);
// connect the slot for the context menu
......@@ -169,6 +169,8 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
if ( PluginFunctions::getObject( _identifier, obj) ){
updateBoundingBox (obj);
if ( obj->target() ) {
obj->materialNode()->disable_blending();
OpenMesh::Vec4f base_color = obj->materialNode()->base_color();
......@@ -213,7 +215,7 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
//******************************************************************************
/** \brief Update the model if the visibility of an object changed
*
*
* @param _identifier id of an object
*/
void DataControlPlugin::slotVisibilityChanged( int _identifier ){
......@@ -230,13 +232,18 @@ void DataControlPlugin::slotVisibilityChanged( int _identifier ){
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
*
*
* @param _identifier id of an object
*/
void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){
......@@ -247,7 +254,7 @@ void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){
//******************************************************************************
/** \brief Update the model if an object was deleted
*
*
* @param _identifier id of an object
*/
void DataControlPlugin::slotObjectUpdated( int _identifier ){
......@@ -258,7 +265,7 @@ void DataControlPlugin::slotObjectUpdated( int _identifier ){
//******************************************************************************
/** \brief Update the model if a file has been opened
*
*
* @param _id id of an object
*/
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
*
*
* @param _id id of an object
*/
void DataControlPlugin::addedEmptyObject(int _id){
......@@ -283,7 +290,7 @@ void DataControlPlugin::addedEmptyObject(int _id){
//******************************************************************************
/** \brief an object was deleted. delete it internally
*
*
* @param _id id of the object
*/
void DataControlPlugin::objectDeleted(int _id){
......@@ -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
*
*
* @param _id id of the object
* @param _parentId id of the new parent
*/
......@@ -410,6 +417,18 @@ void DataControlPlugin::slotMoveBaseObject(int _id, int _newParentId){
* @param _ini an ini file
*/
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" ) )
return;
......@@ -501,6 +520,7 @@ void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) {
* @param _ini an ini file
*/
void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) {
if ( !_ini.section_exists( "Groups" ) )
_ini.add_section("Groups");
......@@ -562,13 +582,20 @@ void DataControlPlugin::saveIniFileOptions( INIFile& _ini ) {
// Write the primary group names to the file
_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
*
*
* @param _obj object to start with
*/
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
*
*
* @param _obj object to start with
*/
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 );
......@@ -100,6 +100,7 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
// INIInterface
void loadIniFileOptionsLast( INIFile& _ini );
void saveIniFileOptions( INIFile& _ini );
void saveOnExit(INIFile& _ini );
// LoadSaveInterface
void fileOpened(int _id);
......@@ -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
* @{ */
......
......@@ -5,6 +5,7 @@
DatacontrolToolboxWidget::DatacontrolToolboxWidget(QWidget* _parent)
: QWidget(_parent)
{
setupUi(this);
}
......
#include "ui_toolbox.hh"
#include <QtGui>
class DatacontrolToolboxWidget : public QWidget
class DatacontrolToolboxWidget : public QWidget, public Ui::dctoolbox
{
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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment