Commit b1301203 authored by Jan Möbius's avatar Jan Möbius

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2435 383ad7c9-94d9-4d36-a494-682f7c89f535
parents
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Config
#==============================================================================
SUBDIRS = $(call find-subdirs)
PACKAGES := qt4 glut glew opengl x11 math ACG2 openmesh2
PROJ_LIBS =
MODULES := moc4 cxx
#== SYSTEM PART -- DON'T TOUCH ==============================================
include $(ACGMAKE)/Rules
#==============================================================================
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision$
// $Author$
// $Date$
//
//=============================================================================
#include "DataControlPlugin.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
void DataControlPlugin::slotContextMenuTarget( ) {
QVariant contextObject = targetAction_->data();
int objectId = contextObject.toInt();
if ( objectId == -1)
return;
BaseObjectData* object;
if ( ! PluginFunctions::get_object(objectId,object) )
return;
object->target( targetAction_->isChecked() );
emit activeObjectChanged();
emit updated_objects(objectId);
}
void DataControlPlugin::slotContextMenuHide( ) {
QVariant contextObject = targetAction_->data();
int objectId = contextObject.toInt();
if ( objectId == -1)
return;
BaseObjectData* object;
if ( ! PluginFunctions::get_object(objectId,object) )
return;
object->hide();
emit update_view();
emit updated_objects(objectId);
}
void DataControlPlugin::slotContextMenuSource( ) {
QVariant contextObject = sourceAction_->data();
int objectId = contextObject.toInt();
if ( objectId == -1)
return;
BaseObjectData* object;
if ( ! PluginFunctions::get_object(objectId,object) )
return;
object->source( sourceAction_->isChecked() );
emit updated_objects(objectId);
}
void DataControlPlugin::slotUpdateContextMenu( int _objectId) {
if ( _objectId == -1)
return;
BaseObjectData* object;
if ( ! PluginFunctions::get_object(_objectId,object) )
return;
sourceAction_->setText( "Source" );
sourceAction_->setChecked( object->source() );
targetAction_->setText( "Target" );
targetAction_->setChecked( object->target() );
}
This diff is collapsed.
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision$
// $Author$
// $Date$
//
//=============================================================================
#ifndef COLORPLUGIN_HH
#define COLORPLUGIN_HH
#include <QObject>
#include <QMenuBar>
#include "DataControlPlugin.hh"
#include <OpenFlipper/BasePlugin/BaseInterface.hh>
#include <OpenFlipper/BasePlugin/ToolboxInterface.hh>
#include <OpenFlipper/BasePlugin/GlobalAccessInterface.hh>
#include <OpenFlipper/BasePlugin/KeyInterface.hh>
#include <OpenFlipper/BasePlugin/LoggingInterface.hh>
#include <OpenFlipper/BasePlugin/ContextMenuInterface.hh>
#include <OpenFlipper/BasePlugin/ScriptInterface.hh>
#include <OpenFlipper/BasePlugin/INIInterface.hh>
#include <ACG/QtWidgets/QtExaminerViewer.hh>
#include <OpenFlipper/common/Types.hh>
//#include "QCheckBoxDelegate.hh"
#include "TreeModel.hh"
/** Plugin for controlling the Object data structures (Show,hide Object, Target, Source selection
*/
class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, GlobalAccessInterface, KeyInterface , LoggingInterface, INIInterface, ContextMenuInterface, ScriptInterface
{
Q_OBJECT
Q_INTERFACES(BaseInterface)
Q_INTERFACES(ToolboxInterface)
Q_INTERFACES(GlobalAccessInterface)
Q_INTERFACES(KeyInterface)
Q_INTERFACES(LoggingInterface)
Q_INTERFACES(INIInterface)
Q_INTERFACES(ContextMenuInterface)
Q_INTERFACES(ScriptInterface)
signals:
/// Force Examiner widget to update their views
void update_view();
/// Emit this Signal, if object list has changed (e.g. Source or Target changed)
void updated_objects(int);
void activeObjectChanged();
void log(Logtype _type, QString _message);
void log(QString _message);
void addContextMenu(QMenu* _menu );
void addContextMenu(QMenu* _menu ,DataType _objectType , ContextMenuType _type );
private slots :
/// Updates the table widget
void slotObjectUpdated( int _identifier );
void slotActiveObjectChanged();
void slotKeyEvent( QKeyEvent* _event );
void loadIniFileOptions( INIFile& _ini );
void saveIniFileOptions( INIFile& _ini );
void pluginsInitialized();
public :
~DataControlPlugin() {};
/** Initialize the toolbar (create a widget in the right side toolbox)\n
* Creates Table and buttons */
bool initializeToolbox(QWidget*& _widget);
/// Sets examiner Widget (dummy here, using update_view signal here)
void set_examiner(ACG::QtWidgets::QtExaminerViewer* /* _examiner_widget */ ) { };
/// Name of the Plugin
QString name(){ return (QString("DataControl")); };
/// Description of the Plugin
QString description() { return (QString("Manages Data Objects")); };
/// User selected plugins Toolbox
void toolboxActivated( bool /* _activated */ ) { };
/// Update the visualization of the active objects
void update_active( );
private :
/// Widget for Toolbox
QWidget* tool_;
/// Layout for Toolbox
QGridLayout* MeshDialogLayout_;
/// Table containing Mesh information and status
QTableWidget* objectList_;
/// Flag set to true if meshlist is updated, preventing signal for list udate to be called
bool locked;
/// The Treemodel organizing the data
TreeModel* model_;
///Tree view
QTreeView* view_;
/// Pointer to the header to the view widget
QHeaderView * viewHeader_;
/// Delegate for boolean values
//QCheckBoxDelegate* checkboxDelegate_;
ACG::QtWidgets::QtExaminerViewer* examiner_widget_;
private slots:
/// This slot is called when the mesh selection changed in the table
void slotCellClicked(int _row, int _col);
/// Vertical header of the list has been clicked
void verticalHeaderClicked( int _row );
void verticalCountClicked( int id , int old , int newc );
//===========================================================================
/** @name Slots which are called if data changed
* @{ */
//===========================================================================
/// Gets called when the data in the table has changed
void slotDataChanged ( const QModelIndex & topLeft, const QModelIndex & bottomRight );
/// called when an object is removed from the view
void slotRowsRemoved ( const QModelIndex & _parent, int _start, int _end );
/** @} */
//===========================================================================
/** @name Popup Menu related
* @{ */
//===========================================================================
private slots:
/// Display a custom context window for the TreeView
void slotCustomContextMenuRequested ( const QPoint & _pos );
/// Called by the popup menu to remove an object/group
void slotPopupRemove( );
/// Called by the popup menu to ungroup items
void slotUngroup ( );
/// Called by the popup menu to group items
void slotGroup ( );
///Called by the popup menu to rename items
void slotRename ( );
private :
/// Index where a popup has been opened
QModelIndex popupIndex_;
private slots:
/// Display a custom context window for the TreeViews header
void slotHeaderCustomContextMenuRequested ( const QPoint & _pos );
private:
/// Defines the section of the Popup
int headerPopupType_;
/** @} */
//===========================================================================
/** @name GL Area Context Menu related slots
* @{ */
//===========================================================================
private slots:
/// Hide an object
void slotContextMenuHide( );
/// Target Selection
void slotContextMenuTarget( );
/// Source Selection
void slotContextMenuSource( );
/// Update the context Menus for the given id
void slotUpdateContextMenu( int _objectId);
private :
QAction* targetAction_;
QAction* sourceAction_;
/** @} */
//===========================================================================
/** @name Scripting functions
* @{ */
//===========================================================================
public slots:
/// Get the Objects name from the id
QString getObjectName( int objectId );
/// Get the id of an object by its name
int getObject( QString _name );
/// Hide the given Object
void hideObject( int objectId );
/// Show the given Object
void showObject( int objectId );
/// Makes all available objects target
void setAllTarget();
/// Makes all available objects source
void setAllSource();
/// Unselect all objects
void clearAllTarget();
/// remove source selection from all objects
void clearAllSource();
/// Shows all objects
void showAll();
/// Hides all objects
void hideAll();
/** @} */
};
#endif //COLORPLUGIN_HH
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision$
// $Author$
// $Date$
//
//=============================================================================
#include "DataControlPlugin.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
int DataControlPlugin::getObject( QString _name ) {
BaseObject* object = PluginFunctions::objectRoot()->childExists(_name);
if ( object == 0)
return -1;
return object->id();
}
QString DataControlPlugin::getObjectName( int objectId ) {
BaseObjectData* object;
if ( ! PluginFunctions::get_object(objectId,object) ) {
emit log(LOGERR,"getObjectName : unable to get object" );
return QString("Unknown Object");
} else
return object->name() ;
}
void DataControlPlugin::hideObject( int objectId ) {
BaseObjectData* object;
if ( ! PluginFunctions::get_object(objectId,object) )
return;
if ( object == 0)
return;
object->hide();
}
void DataControlPlugin::showObject( int objectId ) {
BaseObjectData* object;
if ( ! PluginFunctions::get_object(objectId,object) )
return;
if ( object == 0)
return;
object->show();
}
This diff is collapsed.
//=============================================================================
//
// OpenFlipper
// Copyright (C) 2008 by Computer Graphics Group, RWTH Aachen
// www.openflipper.org
//
//-----------------------------------------------------------------------------
//
// License
//
// OpenFlipper is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenFlipper is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenFlipper. If not, see <http://www.gnu.org/licenses/>.
//
//-----------------------------------------------------------------------------
//
// $Revision$
// $Author$
// $Date$
//
//=============================================================================
#include "DataControlPlugin.hh"
#include <OpenFlipper/BasePlugin/PluginFunctions.hh>
#include <OpenFlipper/common/GlobalOptions.hh>
#include <QInputDialog>
void DataControlPlugin::slotPopupRemove ( ) {
QItemSelectionModel* selection = view_->selectionModel();
// Get all selected rows
QModelIndexList indexList = selection->selectedRows ( 0 );
int selectedRows = indexList.size();
for ( int i = 0 ; i < indexList.size() ; ++i) {
BaseObject* deleteItem = model_->getItem( indexList[i] );
// Skip the root item
if ( model_->isRoot( deleteItem ) )
continue;
// remove the whole subtree below this item
deleteItem->deleteSubtree();
// remove the item itself from the parent
deleteItem->parent()->removeChild(deleteItem);
// delete it
delete deleteItem;
}
emit update_view();
emit updated_objects(-1);
}
void DataControlPlugin::slotUngroup ( ) {
QItemSelectionModel* selection = view_->selectionModel();
// Get all selected rows
QModelIndexList indexList = selection->selectedRows ( 0 );
int selectedRows = indexList.size();
//remove complete group if selected item was a group
BaseObject* group = model_->getItem( indexList[0]);
for (int i=0; i < group->childCount(); i++){
group->child(i)->setParent(group->parent());
group->parent()->appendChild( group->child(i) );
}
group->parent()->removeChild(group);
delete group;
emit updated_objects(-1);
}
void DataControlPlugin::slotGroup ( ) {
QItemSelectionModel* selection = view_->selectionModel();
// Get all selected rows
QModelIndexList indexList = selection->selectedRows ( 0 );
int selectedRows = indexList.size();
//check if all objects have the same parent
//abort if the parents differ
BaseObject* parent = (model_->getItem( indexList[0]))->parent();
for ( int i = 1 ; i < indexList.size() ; ++i) {
BaseObject* item = model_->getItem( indexList[i] );
if (parent != item->parent()){
emit log("Cannot group Objects with different parents");
return;
}
}
//create new group
if (parent == 0)
parent = PluginFunctions::objectRoot();
GroupObject* groupItem = new GroupObject( "newGroup", dynamic_cast< GroupObject* >(parent));
groupItem->setName("newGroup " + QString::number(groupItem->id()));
parent->appendChild( dynamic_cast< BaseObject* >( groupItem ) );
groupItem->setParent( parent );
//append new children to group
for ( int i = 0 ; i < indexList.size() ; ++i) {
BaseObject* item = model_->getItem( indexList[i] );
item->parent()->removeChild(item);
item->setParent( dynamic_cast< BaseObject* >( groupItem ) );
groupItem->appendChild(item);
}
emit updated_objects(-1);
}
void DataControlPlugin::slotCustomContextMenuRequested ( const QPoint & _pos ) {
popupIndex_ = view_->indexAt(_pos);
BaseObject* item = model_->getItem(popupIndex_);
QItemSelectionModel* selection = view_->selectionModel();
// Get all selected rows
QModelIndexList indexList = selection->selectedRows ( 0 );
int selectedRows = indexList.size();
QMenu menu(0);
QAction* action;
QIcon icon;
if ( selectedRows > 1 ) {
menu.addAction("Group",this,SLOT ( slotGroup() ));
menu.addSeparator();
menu.addAction("Remove",this,SLOT ( slotPopupRemove() ));
}else
// check if the item is a group item
if ( item->isGroup() ) {
menu.addAction("Ungroup",this,SLOT ( slotUngroup() ));
menu.addSeparator();
action = menu.addAction("Rename",this,SLOT ( slotRename() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-rename.png");
action->setIcon(icon);
menu.addSeparator();
action = menu.addAction("Remove",this,SLOT ( slotPopupRemove() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"user-trash.png");
action->setIcon(icon);
} else {
action = menu.addAction("Rename",this,SLOT ( slotRename() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"edit-rename.png");
action->setIcon(icon);
menu.addSeparator();
action = menu.addAction("Remove",this,SLOT ( slotPopupRemove() ));
icon.addFile(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"user-trash.png");
action->setIcon(icon);
}