Commit 184d40f7 authored by Isaak Lim's avatar Isaak Lim

added a slot to visualize a property on an object (thanks to Alexander Dielen)

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@21187 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 842f6e47
......@@ -128,7 +128,7 @@ void MultiObjectPropertyModel::visualize(QModelIndexList selectedIndices, QWidge
const QString name = selectedIndices[i].data().toString();
// skip this property if it does not exist
const QModelIndex idx = model->indexFromPropName(name);
const QModelIndex idx = model->indexFromFancyPropName(name);
if (!idx.isValid()) continue;
// insert items into lists
......@@ -160,7 +160,7 @@ void MultiObjectPropertyModel::removeProperty(QModelIndexList selectedIndices)
const QString name = selectedIndices[i].data().toString();
// skip this property if it does not exist
const QModelIndex idx = model->indexFromPropName(name);
const QModelIndex idx = model->indexFromFancyPropName(name);
if (!idx.isValid()) continue;
// insert item into list
......@@ -193,7 +193,7 @@ void MultiObjectPropertyModel::duplicateProperty(QModelIndexList selectedIndices
const QString name = selectedIndices[i].data().toString();
// skip this property if it does not exist
const QModelIndex idx = model->indexFromPropName(name);
const QModelIndex idx = model->indexFromFancyPropName(name);
if (!idx.isValid()) continue;
// insert item into list
......@@ -266,7 +266,7 @@ void MultiObjectPropertyModel::clear(QModelIndexList selectedIndices)
const QString name = selectedIndices[i].data().toString();
// skip this property if it does not exist
const QModelIndex idx = model->indexFromPropName(name);
const QModelIndex idx = model->indexFromFancyPropName(name);
if (!idx.isValid()) continue;
// insert item into list
......
/*===========================================================================*\
* *
* 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: 21166 $ *
* $LastChangedBy: lim $ *
* $Date: 2015-09-02 17:43:30 +0200 (Wed, 02 Sep 2015) $ *
* *
\*===========================================================================*/
#include "PropertyModel.hh"
QModelIndex PropertyModel::indexFromFancyPropName(const QString& propName) const
{
for (int i = 0; i < rowCount(); ++i)
{
const QModelIndex idx = index(i, 0);
const QString name = idx.data().toString();
if (name == propName) return idx;
}
return QModelIndex();
}
QModelIndex PropertyModel::indexFromPlainPropName(const QString& propName) const
{
for (int i = 0; i < rowCount(); ++i)
{
const QModelIndex idx = index(i, 0);
const std::string name = getPropertyInfo(idx).propName();
if (name == propName.toStdString()) return idx;
}
return QModelIndex();
}
......@@ -101,19 +101,14 @@ public:
/// Connects the PropertyVisualizer log signals with the log slot.
virtual void connectLogs(PropertyVisualizer* propViz) = 0;
/// Returns the property info for the property with the given index.
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const = 0;
/// Returns the index of the property with the given name.
QModelIndex indexFromPropName(const QString& propName) const
{
for (int i = 0; i < rowCount(); ++i) {
const QModelIndex idx = index(i, 0);
const QString name = idx.data().toString();
if (name == propName) return idx;
}
return QModelIndex();
}
/// Returns the property info for the property with the given index.
virtual PropertyInfo getPropertyInfo(const QModelIndex index) const = 0;
/// Returns the index of the property with the given name.
QModelIndex indexFromFancyPropName(const QString& propName) const;
/// Returns the index of the property with the given name.
QModelIndex indexFromPlainPropName(const QString& propName) const;
};
#endif /* PROPERTY_MODEL_H */
......@@ -134,6 +134,31 @@ void PropertyVisPlugin::pluginsInitialized()
//-----------------------------------------------------------------------------
void PropertyVisPlugin::slotVisualizeProperty( int _id, const QString& _propname )
{
PropertyModel* model = PropertyModelFactory::Instance().getModel(_id);
if (model != 0)
{
model->gatherProperties();
QModelIndex idx = model->indexFromPlainPropName(_propname);
if (idx.isValid())
{
QModelIndexList list;
list.append(idx);
model->visualize(list);
emit updateView();
emit updatedObject( _id, UPDATE_COLOR );
}
}
}
//-----------------------------------------------------------------------------
void PropertyVisPlugin::slotPickModeChanged( const std::string& _mode)
{
if (propertyModel_ != 0)
......
......@@ -113,6 +113,8 @@ signals:
//PickingInterface
void addHiddenPickMode( const std::string& _mode );
public slots:
void slotVisualizeProperty( int _id, const QString& _propname );
private slots:
......
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