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

Made datacontrol scriptable and added printObjectInfoToLog function to show all objects

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@12677 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0e334963
......@@ -82,6 +82,9 @@ void DataControlPlugin::pluginsInitialized() {
//set the slot descriptions
setDescriptions();
if ( ! OpenFlipper::Options::gui())
return;
QMenu* contextMenu = new QMenu("Object");
//Target Objects
......@@ -137,63 +140,66 @@ void DataControlPlugin::pluginsInitialized() {
void DataControlPlugin::initializePlugin()
{
locked = false;
tool_ = new DatacontrolToolboxWidget();
connect( tool_ , SIGNAL( keyEvent( QKeyEvent* ) ),
this , SLOT(slotKeyEvent ( QKeyEvent* ) ));
QSize size(300, 300);
tool_->resize(size);
if ( ! OpenFlipper::Options::gui())
return;
locked = false;
tool_ = new DatacontrolToolboxWidget();
connect( tool_ , SIGNAL( keyEvent( QKeyEvent* ) ),
this , SLOT(slotKeyEvent ( QKeyEvent* ) ));
QSize size(300, 300);
tool_->resize(size);
model_ = new TreeModel( );
view_ = tool_->treeView;
tool_->treeView->setModel(model_);
model_ = new TreeModel( );
view_->QTreeView::resizeColumnToContents(1);
view_->QTreeView::resizeColumnToContents(2);
view_->QTreeView::resizeColumnToContents(3);
view_ = tool_->treeView;
tool_->treeView->setModel(model_);
connect( model_,SIGNAL(dataChangedInside(int,int,const QVariant&) ),
this, SLOT( slotDataChanged(int,int,const QVariant&)) );
view_->QTreeView::resizeColumnToContents(1);
view_->QTreeView::resizeColumnToContents(2);
view_->QTreeView::resizeColumnToContents(3);
connect( model_,SIGNAL( moveBaseObject(int,int) ),
this, SLOT( slotMoveBaseObject(int,int) ) );
connect( view_,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
this,SLOT(slotCustomContextMenuRequested ( const QPoint & ) ));
connect( model_,SIGNAL(dataChangedInside(int,int,const QVariant&) ),
this, SLOT( slotDataChanged(int,int,const QVariant&)) );
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 ( ) ));
connect( model_,SIGNAL( moveBaseObject(int,int) ),
this, SLOT( slotMoveBaseObject(int,int) ) );
connect( view_,SIGNAL(customContextMenuRequested ( const QPoint & ) ),
this,SLOT(slotCustomContextMenuRequested ( const QPoint & ) ));
viewHeader_ = tool_->treeView->header();
viewHeader_->setContextMenuPolicy(Qt::CustomContextMenu);
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 ( ) ));
// connect the slot for the context menu
connect( viewHeader_, SIGNAL(customContextMenuRequested ( const QPoint & ) ),
this, SLOT(slotHeaderCustomContextMenuRequested ( const QPoint & ) ));
toolIcon_ = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-toolbox.png");
viewHeader_ = tool_->treeView->header();
viewHeader_->setContextMenuPolicy(Qt::CustomContextMenu);
emit addToolbox("Data Control", tool_, toolIcon_);
// connect the slot for the context menu
connect( viewHeader_, SIGNAL(customContextMenuRequested ( const QPoint & ) ),
this, SLOT(slotHeaderCustomContextMenuRequested ( const QPoint & ) ));
onlyDown_ = 0;
onlyUp_ = 0;
toolIcon_ = new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-toolbox.png");
QIcon icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-boundingBox.png");
tool_->boundingBoxBtn->setIcon( icon );
icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-hide-object.png");
tool_->visibleDataBtn->setIcon( icon );
emit addToolbox("Data Control", tool_, toolIcon_);
onlyDown_ = 0;
onlyUp_ = 0;
QIcon icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-boundingBox.png");
tool_->boundingBoxBtn->setIcon( icon );
icon = QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"datacontrol-hide-object.png");
tool_->visibleDataBtn->setIcon( icon );
//hide additional boxes
tool_->visibleDataBtn->setChecked(false);
tool_->boundingBoxBtn->setChecked(false);
//hide additional boxes
tool_->visibleDataBtn->setChecked(false);
tool_->boundingBoxBtn->setChecked(false);
}
......@@ -205,6 +211,9 @@ void DataControlPlugin::initializePlugin()
void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
{
if ( ! OpenFlipper::Options::gui())
return;
BaseObjectData* obj = 0;
if ( PluginFunctions::getObject( _identifier, obj) )
......@@ -253,6 +262,9 @@ void DataControlPlugin::slotObjectSelectionChanged( int _identifier )
*/
void DataControlPlugin::slotVisibilityChanged( int _identifier ){
if ( ! OpenFlipper::Options::gui())
return;
// if onlyUp_ > 0 --> _identifier is a group and the selection
// does not have to be applied
if (onlyUp_ == 0){
......@@ -303,6 +315,10 @@ void DataControlPlugin::slotVisibilityChanged( int _identifier ){
* @param _identifier id of an object
*/
void DataControlPlugin::slotObjectPropertiesChanged( int _identifier ){
if ( ! OpenFlipper::Options::gui())
return;
model_->objectChanged( _identifier );
}
......@@ -326,6 +342,9 @@ void DataControlPlugin::slotObjectUpdated( int /*_identifier*/ , const UpdateTyp
*/
void DataControlPlugin::fileOpened(int _id){
if ( ! OpenFlipper::Options::gui())
return;
BaseObject* obj = 0;
if ( PluginFunctions::getObject(_id, obj) )
......@@ -353,6 +372,10 @@ void DataControlPlugin::addedEmptyObject(int _id){
* @param _id id of the object
*/
void DataControlPlugin::objectDeleted(int _id){
if ( ! OpenFlipper::Options::gui())
return;
model_->objectDeleted(_id);
}
......@@ -480,7 +503,7 @@ void DataControlPlugin::slotShowLightSources( int _state ) {
*/
void DataControlPlugin::loadIniFileOptionsLast( INIFile& _ini ) {
if ( _ini.section_exists( "BoundingBox" ) )
if ( _ini.section_exists( "BoundingBox" ) && OpenFlipper::Options::gui() )
{
bool value;
if (_ini.get_entry(value, "BoundingBox","notSelected"))
......@@ -632,11 +655,14 @@ 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 ());
if ( OpenFlipper::Options::gui() ) {
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 ());
}
}
......
......@@ -123,6 +123,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
void addedEmptyObject(int _id);
void objectDeleted(int _id);
// Tell system that this plugin runs without ui
void noguiSupported( ) {} ;
public :
/// Destructor
~DataControlPlugin() {};
......@@ -357,6 +360,9 @@ class DataControlPlugin : public QObject, BaseInterface, ToolboxInterface, KeyIn
/// Get all source objects of given type
IdList getSourceObjects(DataType _type);
/// Print information about all open objects to the console
void printObjectInfoToLog();
/** @} */
public slots:
......
......@@ -109,6 +109,10 @@ void DataControlPlugin::setDescriptions(){
emit setSlotDescription("hideAll()",tr("Hide all objects"),
QStringList(), QStringList());
emit setSlotDescription("printObjectInfoToLog()",tr("Print info about all objects to log"),
QStringList(), QStringList());
}
......@@ -174,6 +178,9 @@ QString DataControlPlugin::getObjectName( int objectId ) {
*/
void DataControlPlugin::hideObject( int objectId ) {
if ( ! OpenFlipper::Options::gui())
return;
BaseObjectData* object;
if ( PluginFunctions::getObject(objectId,object) ){
object->hide();
......@@ -258,6 +265,9 @@ void DataControlPlugin::objectDelete( int objectId ) {
*/
void DataControlPlugin::showObject( int objectId ) {
if ( ! OpenFlipper::Options::gui())
return;
BaseObjectData* object;
if ( PluginFunctions::getObject(objectId,object) ){
object->show();
......@@ -434,6 +444,9 @@ void DataControlPlugin::clearAllSource() {
*/
void DataControlPlugin::hideAll() {
if ( ! OpenFlipper::Options::gui())
return;
DataType type = DATA_ALL;
//try to find dataType restriction if called by contextMenu
......@@ -457,6 +470,9 @@ void DataControlPlugin::hideAll() {
*/
void DataControlPlugin::showAll() {
if ( ! OpenFlipper::Options::gui())
return;
DataType type = DATA_ALL;
//try to find dataType restriction if called by contextMenu
......@@ -501,5 +517,14 @@ IdList DataControlPlugin::getSourceObjects(DataType _type) {
return list;
}
//******************************************************************************
/** \brief Prints information about all open objects to the Log
*
*/
void DataControlPlugin::printObjectInfoToLog() {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS); o_it != PluginFunctions::objectsEnd(); ++o_it)
emit log(LOGINFO, tr("Object \"%1\" with ID %2 of type %3 ").arg(o_it->name()).arg(o_it->id()).arg(o_it->dataType().name()));
}
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