diff --git a/GUI/coregui/Views/Components/SampleDesigner/LayerView.cpp b/GUI/coregui/Views/Components/SampleDesigner/LayerView.cpp index d1f1687f4e5a06e6bb670beaac10b3739ac17fee..3f3ce71ca5cb105d76701074b1e1e8ff9bbd7521 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/LayerView.cpp +++ b/GUI/coregui/Views/Components/SampleDesigner/LayerView.cpp @@ -31,6 +31,8 @@ LayerView::LayerView(QGraphicsItem *parent) setFlag(QGraphicsItem::ItemSendsGeometryChanges); setAcceptDrops(false); + m_materialProperty.setName("XXXXX"); + addPort(" ", NodeEditorPort::Input, NodeEditorPort::ParticleFactory); } diff --git a/GUI/coregui/Views/Components/SampleDesigner/LayerView.h b/GUI/coregui/Views/Components/SampleDesigner/LayerView.h index 6cb40edbb0ece995495f623446d96dbc3442a538..e4e8e9947b1c7a42b456cc5b6a1a055e407fc188 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/LayerView.h +++ b/GUI/coregui/Views/Components/SampleDesigner/LayerView.h @@ -3,7 +3,7 @@ #include "ISampleView.h" #include "DesignerHelper.h" - +#include "MaterialBrowser.h" //! graphics representation of Layer class LayerView : public ISampleRectView @@ -11,6 +11,7 @@ class LayerView : public ISampleRectView Q_OBJECT Q_PROPERTY(QString name READ getName WRITE setName ) Q_PROPERTY(double thickness READ getThickness WRITE setThickness ) + Q_PROPERTY(MaterialProperty material READ getMaterialProperty WRITE setMaterialProperty ) public: LayerView(QGraphicsItem *parent = 0); @@ -22,11 +23,13 @@ public: QString getName() const { return m_name; } double getThickness() const { return m_thickness; } QColor getColor() const { return m_color; } + MaterialProperty getMaterialProperty() const { return m_materialProperty; } public slots: void setName(const QString &name); void setThickness(double thickness); void setColor(const QColor &color); + void setMaterialProperty(const MaterialProperty &materialProperty); signals: void LayerMoved(); @@ -45,6 +48,7 @@ private: qreal m_fixed_xpos; bool m_fixed; double m_thickness; + MaterialProperty m_materialProperty; }; @@ -73,6 +77,10 @@ inline void LayerView::setColor(const QColor &color) } } +inline void LayerView::setMaterialProperty(const MaterialProperty &materialProperty) +{ + m_materialProperty = materialProperty; +} #endif // LAYERVIEW_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.cpp b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.cpp index 7b05bc43648dcaaf263a147ef7c34e5654b47d5b..d6e40c58854724463d71ca2a7462bbd17f0843b3 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.cpp +++ b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.cpp @@ -38,13 +38,21 @@ MaterialBrowser *MaterialBrowser::instance() // create new MaterialBrowserView or raise old one if exists -void MaterialBrowser::BrowserViewCall() +void MaterialBrowser::BrowserViewCall(bool isModal) { std::cout << "MaterialBrowser::BrowserViewCall()" << std::endl; if( !m_browserView ) { std::cout << " MaterialBrowser::BrowserViewCall() " << m_parent << std::endl; + m_browserModel->resetSelection(); m_browserView = new MaterialBrowserView(m_browserModel, m_parent); +// NonModal, +// WindowModal, +// ApplicationModal + connect( m_browserView, SIGNAL(WindowClosed()), this, SLOT(BrowserViewOnCloseEvent()) ); + //m_browserView->setWindowModality(Qt::ApplicationModal); + m_browserView->setModal(isModal); + m_browserView->show(); } else { m_browserView->raise(); } @@ -58,3 +66,12 @@ void MaterialBrowser::BrowserViewOnCloseEvent() delete m_browserView; m_browserView = 0; } + + +MaterialProperty MaterialBrowser::this_getSelectedMaterialProperty() +{ + std::cout << "MaterialBrowser::this_getMaterialProperty()-> " << std::endl; + BrowserViewCall(true); + Q_ASSERT(m_browserModel->hasSelection()); + return m_browserModel->getSelectedMaterialProperty(); +} diff --git a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.h b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.h index 4602774d91699ebed79f72c1ba49998354590693..3029cd43f6bd8c8f030f2a54b121c6a3b2f5faa9 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.h +++ b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowser.h @@ -2,13 +2,41 @@ #define MATERIALBROWSER_H #include <QObject> +#include <QColor> +#include <QIcon> +#include <QPixmap> class QWidget; class MaterialBrowserView; class MaterialBrowserModel; -//! main class to access materials +//! The MaterialProperty defines material property (name,color) to be used +//! in LayerView, FormFactorView together with SamplePropertyEditor +class MaterialProperty +{ +public: + MaterialProperty() : m_name("Undefined"), m_color(Qt::red){} + virtual ~MaterialProperty(){} + QString getName() const { return m_name; } + QColor getColor() const { return m_color; } + QPixmap getPixmap() const { + QPixmap pixmap(10,10); + pixmap.fill(getColor()); + return pixmap; + } + void setName(const QString &name) { m_name = name; } + void setColor(const QColor &color) { m_color = color; } +private: + QString m_name; + QColor m_color; +}; + +Q_DECLARE_METATYPE(MaterialProperty) + + +//! The MaterialBrowser is the main class to create, edit and access materials. +//! MaterialBrowser is created/deleted in SampleView, used by others via instance() method. class MaterialBrowser : public QObject { Q_OBJECT @@ -18,14 +46,18 @@ public: static MaterialBrowser *instance(); + static MaterialProperty getMaterialProperty() { return instance()->this_getSelectedMaterialProperty(); } + public slots: //! create new MaterialBrowserView or raise old one if exists - void BrowserViewCall(); + void BrowserViewCall(bool isModal = false); //! delete MaterialBrowserView if it was closed by the user void BrowserViewOnCloseEvent(); private: + MaterialProperty this_getSelectedMaterialProperty(); + QWidget *m_parent; static MaterialBrowser *m_instance; MaterialBrowserView *m_browserView; diff --git a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp index c7f6b40f1e8079bdfe714efb2b4011b246440dfd..a62243747588dc4f094df945c4eb28c03d7e169a 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp +++ b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.cpp @@ -11,6 +11,7 @@ MaterialBrowserModel::MaterialBrowserModel(QObject *parent) : QAbstractTableModel(parent) + , m_selected_row(-1) { UpdateMaterials(); } @@ -30,7 +31,7 @@ void MaterialBrowserModel::UpdateMaterials() const IMaterial *m = (*it).second; if(m_mat_color.contains(m)) continue; std::cout << " MaterialBrowserModel::UpdateMaterials() -> getting new material " << m->getName() << std::endl; - m_mat_color[m] = getMaterialColor( QString(m->getName().c_str()) ); + m_mat_color[m] = suggestMaterialColor( QString(m->getName().c_str()) ); m_nrow_mat.append(m); } emit layoutChanged(); @@ -99,7 +100,12 @@ QVariant MaterialBrowserModel::data(const QModelIndex &index, int role) const } } else if (role == Qt::DecorationRole && index.column() == 0) { return m_mat_color[mat]; + } else if (role == Qt::CheckStateRole && index.column() == 0) { + if(index.row() == m_selected_row) return Qt::Checked; + return Qt::Unchecked; } + + return QVariant(); } @@ -198,6 +204,14 @@ bool MaterialBrowserModel::setData(const QModelIndex & index, const QVariant & v break; } return true; + } else if(role == Qt::CheckStateRole) { + if(m_selected_row == index.row()) { + resetSelection(); + } else { + m_selected_row = index.row(); + emit layoutChanged(); + } + return true; } return true; } @@ -228,11 +242,11 @@ double MaterialBrowserModel::evaluateDoubleValue(const QVariant &variant, bool & Qt::ItemFlags MaterialBrowserModel::flags(const QModelIndex & /*index*/) const { - return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled ; + return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable ; } -QColor MaterialBrowserModel::getMaterialColor(const QString &name) +QColor MaterialBrowserModel::suggestMaterialColor(const QString &name) { if(name == QStringLiteral("Air") ) { return QColor(176, 226, 255); @@ -244,3 +258,16 @@ QColor MaterialBrowserModel::getMaterialColor(const QString &name) return DesignerHelper::getRandomColor(); } + +MaterialProperty MaterialBrowserModel::getSelectedMaterialProperty() +{ + if( !hasSelection() ) { + return MaterialProperty(); + } else { + const IMaterial *mat = m_nrow_mat.at(m_selected_row); + MaterialProperty p; + p.setName(QString(mat->getName().c_str())); + p.setColor(m_mat_color[mat]); + return p; + } +} diff --git a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.h b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.h index 0caa7011f21dd00bc35a20b82a83f3ecb11e1d67..1821f3031bb83f16f065278633aa61ab8d7580e7 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.h +++ b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserModel.h @@ -5,6 +5,7 @@ #include <QAbstractTableModel> #include <QMap> #include <QVector> +#include "MaterialBrowser.h" class IMaterial; @@ -30,6 +31,10 @@ public: bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole); Qt::ItemFlags flags(const QModelIndex & index) const; + void resetSelection() { m_selected_row = -1; } + bool hasSelection() { return (m_selected_row >= 0 ? true : false); } + MaterialProperty getSelectedMaterialProperty(); + public slots: void UpdateMaterials(); void RemoveMaterials(const QModelIndexList &index_list); @@ -38,12 +43,13 @@ signals: void SetDataMessage(const QString &message); private: - QColor getMaterialColor(const QString &name); + QColor suggestMaterialColor(const QString &name); double getDoubleValue(const QVariant &variant, bool &status); double evaluateDoubleValue(const QVariant &variant, bool &status); QMap<const IMaterial *, QColor> m_mat_color; QVector<const IMaterial *> m_nrow_mat; + int m_selected_row; }; #endif // MATERIALBROWSERMODEL_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.cpp b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.cpp index 3aee18a47c55b52ba8093de9b426761a583c5533..fb3540d61c2d10a7b618de7c222b7265a78c5437 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.cpp +++ b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.cpp @@ -13,9 +13,10 @@ #include <QtGlobal> #include <QApplication> #include <QAction> +#include <QPushButton> #include <iostream> -int MaterialBrowserView::m_nmaterial = 0; +int MaterialBrowserView::m_IndexOfUnnamed = 0; MaterialBrowserView::MaterialBrowserView(MaterialBrowserModel *tableModel, QWidget *parent) : QDialog(parent) @@ -29,12 +30,13 @@ MaterialBrowserView::MaterialBrowserView(MaterialBrowserModel *tableModel, QWidg setMinimumSize(128, 128); resize(512, 256); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + //setStyleSheet("background-color:white;"); m_tableView = new MyTableView(this); std::cout << "XXX " << m_tableModel << std::endl; m_tableView->setModel( m_tableModel ); m_tableView->horizontalHeader()->setStretchLastSection(true); - m_tableView->horizontalHeader()->resizeSection(0, 120); + m_tableView->horizontalHeader()->resizeSection(0, 140); m_toolBar = new QToolBar(this); m_toolBar->setFixedHeight(28); @@ -51,12 +53,24 @@ MaterialBrowserView::MaterialBrowserView(MaterialBrowserModel *tableModel, QWidg layout->setSpacing(0); layout->addWidget(m_toolBar); layout->addWidget(m_tableView); + + QPushButton *closeButton = new QPushButton(tr("Close")); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + + QHBoxLayout *buttonsLayout = new QHBoxLayout; + buttonsLayout->addStretch(1); + buttonsLayout->addWidget(closeButton); + buttonsLayout->setMargin(0); + buttonsLayout->setSpacing(0); + layout->addLayout(buttonsLayout); + layout->addWidget(m_statusBar); + setLayout(layout); SetupActions(); - show(); +// show(); } @@ -66,6 +80,18 @@ MaterialBrowserView::~MaterialBrowserView() } +bool MaterialBrowserView::close() +{ + std::cout << "MaterialBrowserView::close() ->" << std::endl; + Q_ASSERT(m_tableModel); + if( !m_tableModel->hasSelection() && isModal() ) { + showMessage("Please select material with checkbox"); + return false; + } + return QDialog::close(); +} + + void MaterialBrowserView::showMessage(const QString &message) { m_statusBar->showMessage(message, 4000); @@ -86,13 +112,13 @@ void MaterialBrowserView::SetupActions() void MaterialBrowserView::addMaterial() { - QString name = QString("unnamed%1").arg(m_nmaterial); + QString name = QString("unnamed%1").arg(m_IndexOfUnnamed); std::cout << "MaterialBrowserView::addMaterial() -> " << name.toStdString() << std::endl; MaterialManager::instance().getHomogeneousMaterial(name.toStdString(), 1.0, 0.0); m_tableModel->UpdateMaterials(); m_tableView->scrollToBottom(); - m_nmaterial++; + m_IndexOfUnnamed++; } diff --git a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.h b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.h index 4b8397df799383af206d15bdaa4a3a95ba33dba1..dab2d81fadfbe790d1ad140c424443c41223f848 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.h +++ b/GUI/coregui/Views/Components/SampleDesigner/MaterialBrowserView.h @@ -28,7 +28,7 @@ public: int sizeHintForColumn(int column) const { int result = QTableView::sizeHintForColumn(column); - if(column == 0) result *= 1.2; + if(column == 0) result *= 1.4; return result; } @@ -49,6 +49,7 @@ public slots: void addMaterial(); void removeMaterial(); void showMessage(const QString &message); + bool close(); protected: void closeEvent(QCloseEvent *event); @@ -59,7 +60,7 @@ private: MaterialBrowserModel *m_tableModel; QStatusBar *m_statusBar; QToolBar *m_toolBar; - static int m_nmaterial; + static int m_IndexOfUnnamed; }; #endif // MATERIALBROWSERVIEW_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/NodeEditor.h b/GUI/coregui/Views/Components/SampleDesigner/NodeEditor.h index 151567987485622467d0e398a518e1964dd8166a..a50db65b6f3d51517044704934bc03feabd1f0b3 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/NodeEditor.h +++ b/GUI/coregui/Views/Components/SampleDesigner/NodeEditor.h @@ -7,7 +7,6 @@ * Copyright (c) 2012, STANISLAW ADASZEWSKI */ - #include <QObject> class QGraphicsScene; @@ -15,6 +14,9 @@ class NodeEditorConnection; class QGraphicsItem; class QPointF; +//! The NodeEditor class implement for QGraphicsScene an editable schematic +//! of the dependency graph, displaying nodes and the connections between their +//! attributes class NodeEditor : public QObject { Q_OBJECT diff --git a/GUI/coregui/Views/Components/SampleDesigner/ObjectPropertyManager.cpp b/GUI/coregui/Views/Components/SampleDesigner/ObjectPropertyManager.cpp deleted file mode 100644 index 49c7394bac869d6c3d057361babaa7bb9ffdc9db..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/Components/SampleDesigner/ObjectPropertyManager.cpp +++ /dev/null @@ -1,230 +0,0 @@ -#include "ObjectPropertyManager.h" - - -template <class Value, class PrivateData> -static Value getData(const QMap<const QtProperty *, PrivateData> &propertyMap, - Value PrivateData::*data, - const QtProperty *property, const Value &defaultValue = Value()) -{ - typedef QMap<const QtProperty *, PrivateData> PropertyToData; - typedef typename PropertyToData::const_iterator PropertyToDataConstIterator; - const PropertyToDataConstIterator it = propertyMap.constFind(property); - if (it == propertyMap.constEnd()) - return defaultValue; - return it.value().*data; -} - - -template <class Value, class PrivateData> -static Value getValue(const QMap<const QtProperty *, PrivateData> &propertyMap, - const QtProperty *property, const Value &defaultValue = Value()) -{ - return getData<Value>(propertyMap, &PrivateData::val, property, defaultValue); -} - -class ObjectComplexPropertyManagerPrivate -{ - ObjectComplexPropertyManager *q_ptr; - Q_DECLARE_PUBLIC(ObjectComplexPropertyManager) -public: - - struct Data - { - Data() : decimals(2) {} - //QPointF val; - complex_t val; - int decimals; - }; - - void slotDoubleChanged(QtProperty *property, double value); - void slotPropertyDestroyed(QtProperty *property); - - typedef QMap<const QtProperty *, Data> PropertyValueMap; - PropertyValueMap m_values; - - QtDoublePropertyManager *m_doublePropertyManager; - - QMap<const QtProperty *, QtProperty *> m_propertyToX; - QMap<const QtProperty *, QtProperty *> m_propertyToY; - - QMap<const QtProperty *, QtProperty *> m_xToProperty; - QMap<const QtProperty *, QtProperty *> m_yToProperty; -}; - -void ObjectComplexPropertyManagerPrivate::slotDoubleChanged(QtProperty *property, double value) -{ - if (QtProperty *prop = m_xToProperty.value(property, 0)) { -// QPointF p = m_values[prop].val; -// p.setX(value); - complex_t p = m_values[prop].val; - p.real() = value; - q_ptr->setValue(prop, p); - } else if (QtProperty *prop = m_yToProperty.value(property, 0)) { -// QPointF p = m_values[prop].val; -// p.setY(value); - complex_t p = m_values[prop].val; - p.imag() = value; - q_ptr->setValue(prop, p); - } -} - -void ObjectComplexPropertyManagerPrivate::slotPropertyDestroyed(QtProperty *property) -{ - if (QtProperty *pointProp = m_xToProperty.value(property, 0)) { - m_propertyToX[pointProp] = 0; - m_xToProperty.remove(property); - } else if (QtProperty *pointProp = m_yToProperty.value(property, 0)) { - m_propertyToY[pointProp] = 0; - m_yToProperty.remove(property); - } -} - - -// Creates a manager with the given parent. -ObjectComplexPropertyManager::ObjectComplexPropertyManager(QObject *parent) - : QtAbstractPropertyManager(parent) -{ - d_ptr = new ObjectComplexPropertyManagerPrivate; - d_ptr->q_ptr = this; - - d_ptr->m_doublePropertyManager = new QtDoublePropertyManager(this); - connect(d_ptr->m_doublePropertyManager, SIGNAL(valueChanged(QtProperty *, double)), - this, SLOT(slotDoubleChanged(QtProperty *, double))); - connect(d_ptr->m_doublePropertyManager, SIGNAL(propertyDestroyed(QtProperty *)), - this, SLOT(slotPropertyDestroyed(QtProperty *))); -} - -//Destroys this manager, and all the properties it has created. -ObjectComplexPropertyManager::~ObjectComplexPropertyManager() -{ - clear(); - delete d_ptr; -} - -// Returns the manager that creates the nested x and y subproperties. -QtDoublePropertyManager *ObjectComplexPropertyManager::subDoublePropertyManager() const -{ - return d_ptr->m_doublePropertyManager; -} - -// Returns the given property's value. -//QPointF ObjectComplexPropertyManager::value(const QtProperty *property) const -complex_t ObjectComplexPropertyManager::value(const QtProperty *property) const -{ -// return getValue<QPointF>(d_ptr->m_values, property); - return getValue<complex_t>(d_ptr->m_values, property); -} - -// Returns the given property's precision, in decimals. -int ObjectComplexPropertyManager::decimals(const QtProperty *property) const -{ - return getData<int>(d_ptr->m_values, &ObjectComplexPropertyManagerPrivate::Data::decimals, property, 0); -} - - -QString ObjectComplexPropertyManager::valueText(const QtProperty *property) const -{ - const ObjectComplexPropertyManagerPrivate::PropertyValueMap::const_iterator it = d_ptr->m_values.constFind(property); - if (it == d_ptr->m_values.constEnd()) - return QString(); -// const QPointF v = it.value().val; - const complex_t v = it.value().val; - - const int dec = it.value().decimals; -// return QString(tr("(%1, %2)").arg(QString::number(v.x(), 'f', dec)) -// .arg(QString::number(v.y(), 'f', dec))); - return QString(tr("(%1, %2)").arg(QString::number(v.real(), 'f', dec)) - .arg(QString::number(v.imag(), 'f', dec))); -} - -// Sets the value of the given property to value. Nested -// properties are updated automatically. -//void ObjectComplexPropertyManager::setValue(QtProperty *property, const QPointF &val) -void ObjectComplexPropertyManager::setValue(QtProperty *property, const complex_t &val) -{ - const ObjectComplexPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - if (it.value().val == val) - return; - - it.value().val = val; -// d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], val.x()); -// d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], val.y()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToX[property], val.real()); - d_ptr->m_doublePropertyManager->setValue(d_ptr->m_propertyToY[property], val.imag()); - - emit propertyChanged(property); - emit valueChanged(property, val); -} - -// Sets the precision of the given \a property to \a prec. -void ObjectComplexPropertyManager::setDecimals(QtProperty *property, int prec) -{ - const ObjectComplexPropertyManagerPrivate::PropertyValueMap::iterator it = d_ptr->m_values.find(property); - if (it == d_ptr->m_values.end()) - return; - - ObjectComplexPropertyManagerPrivate::Data data = it.value(); - - if (prec > 13) - prec = 13; - else if (prec < 0) - prec = 0; - - if (data.decimals == prec) - return; - - data.decimals = prec; - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToX[property], prec); - d_ptr->m_doublePropertyManager->setDecimals(d_ptr->m_propertyToY[property], prec); - - it.value() = data; - - emit decimalsChanged(property, data.decimals); -} - -void ObjectComplexPropertyManager::initializeProperty(QtProperty *property) -{ - d_ptr->m_values[property] = ObjectComplexPropertyManagerPrivate::Data(); - - QtProperty *xProp = d_ptr->m_doublePropertyManager->addProperty(); - xProp->setPropertyName(tr("X")); - d_ptr->m_doublePropertyManager->setDecimals(xProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(xProp, 0); - d_ptr->m_propertyToX[property] = xProp; - d_ptr->m_xToProperty[xProp] = property; - property->addSubProperty(xProp); - - QtProperty *yProp = d_ptr->m_doublePropertyManager->addProperty(); - yProp->setPropertyName(tr("Y")); - d_ptr->m_doublePropertyManager->setDecimals(yProp, decimals(property)); - d_ptr->m_doublePropertyManager->setValue(yProp, 0); - d_ptr->m_propertyToY[property] = yProp; - d_ptr->m_yToProperty[yProp] = property; - property->addSubProperty(yProp); -} - -void ObjectComplexPropertyManager::uninitializeProperty(QtProperty *property) -{ - QtProperty *xProp = d_ptr->m_propertyToX[property]; - if (xProp) { - d_ptr->m_xToProperty.remove(xProp); - delete xProp; - } - d_ptr->m_propertyToX.remove(property); - - QtProperty *yProp = d_ptr->m_propertyToY[property]; - if (yProp) { - d_ptr->m_yToProperty.remove(yProp); - delete yProp; - } - d_ptr->m_propertyToY.remove(property); - - d_ptr->m_values.remove(property); -} - - -#include "moc_ObjectPropertyManager.cpp" -//#include "ObjectPropertyManager.moc" diff --git a/GUI/coregui/Views/Components/SampleDesigner/ObjectPropertyManager.h b/GUI/coregui/Views/Components/SampleDesigner/ObjectPropertyManager.h deleted file mode 100644 index 43ac19bbee5dba22c2f87319401a8ceb573cf64f..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/Components/SampleDesigner/ObjectPropertyManager.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef OBJECTPROPERTYMANAGER_H -#define OBJECTPROPERTYMANAGER_H - -//! collection of classes extending QtPropertyBrowser functionality - -#include <QtAbstractPropertyManager> -#include <QtDoublePropertyManager> -#include "Types.h" - -class ObjectComplexPropertyManagerPrivate; - -//! The ObjectComplexPropertyManager provides and manages complex_t property. -class QT_QTPROPERTYBROWSER_EXPORT ObjectComplexPropertyManager : public QtAbstractPropertyManager -{ - Q_OBJECT -public: - ObjectComplexPropertyManager(QObject *parent = 0); - ~ObjectComplexPropertyManager(); - - QtDoublePropertyManager *subDoublePropertyManager() const; - - //QPointF value(const QtProperty *property) const; - complex_t value(const QtProperty *property) const; - int decimals(const QtProperty *property) const; - -public Q_SLOTS: -// void setValue(QtProperty *property, const QPointF &val); - void setValue(QtProperty *property, const complex_t &val); - void setDecimals(QtProperty *property, int prec); -Q_SIGNALS: -// void valueChanged(QtProperty *property, const QPointF &val); - void valueChanged(QtProperty *property, const complex_t &val); - void decimalsChanged(QtProperty *property, int prec); -protected: - QString valueText(const QtProperty *property) const; - virtual void initializeProperty(QtProperty *property); - virtual void uninitializeProperty(QtProperty *property); -private: - ObjectComplexPropertyManagerPrivate *d_ptr; - Q_DECLARE_PRIVATE(ObjectComplexPropertyManager) - Q_DISABLE_COPY(ObjectComplexPropertyManager) - Q_PRIVATE_SLOT(d_func(), void slotDoubleChanged(QtProperty *, double)) - Q_PRIVATE_SLOT(d_func(), void slotPropertyDestroyed(QtProperty *)) -}; - -#endif // OBJECTPROPERTYMANAGER_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/ObjectVariantManager.cpp b/GUI/coregui/Views/Components/SampleDesigner/ObjectVariantManager.cpp deleted file mode 100644 index c0ae4fc76e8209b27b2c13cafc056d6fdb4d3cb6..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/Components/SampleDesigner/ObjectVariantManager.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "ObjectVariantManager.h" -//#include "DesignerHelper.h" - -#include "Types.h" -Q_DECLARE_METATYPE(complex_t) - -#include <iostream> - -ObjectVariantManager::ObjectVariantManager(QObject *parent) - : QtVariantPropertyManager(parent) -{ - -} - - -ObjectVariantManager::~ObjectVariantManager() -{ -} - - -int ObjectVariantManager::complexTypeId() -{ - return qMetaTypeId<complex_t>(); -} - - -bool ObjectVariantManager::isPropertyTypeSupported(int propertyType) const -{ - if (propertyType == complexTypeId()) - return true; - return QtVariantPropertyManager::isPropertyTypeSupported(propertyType); -} - - -QtVariantProperty *ObjectVariantManager::addProperty(int propertyType, const QString &name) -{ - if (propertyType == complexTypeId()) { - std::cout << "ObjectVariantManager::addProperty() -> " << std::endl; - //return 0; - } - return QtVariantPropertyManager::addProperty(propertyType, name); -} diff --git a/GUI/coregui/Views/Components/SampleDesigner/ObjectVariantManager.h b/GUI/coregui/Views/Components/SampleDesigner/ObjectVariantManager.h deleted file mode 100644 index 1cc0f076da0f44ff6a57f8d173ba928514f64d2c..0000000000000000000000000000000000000000 --- a/GUI/coregui/Views/Components/SampleDesigner/ObjectVariantManager.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef OBJECTVARIANTMANAGER_H -#define OBJECTVARIANTMANAGER_H - -//! collection of classes extending QtPropertyBrowser functionality - -#include <QtVariantPropertyManager> -class QObject; - -//! The ObjectVariantManager class provides and manages user defined QVariant based properties. -class ObjectVariantManager : public QtVariantPropertyManager -{ - Q_OBJECT -public: - ObjectVariantManager(QObject *parent = 0); - ~ObjectVariantManager(); - - static int complexTypeId(); - - virtual bool isPropertyTypeSupported(int propertyType) const; - virtual QtVariantProperty *addProperty(int propertyType, const QString &name = QString()); - -}; - - -#endif // OBJECTVARIANTMANAGER_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyBrowserUtils.cpp b/GUI/coregui/Views/Components/SampleDesigner/PropertyBrowserUtils.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4183274964c8e902c3d0c15cbab753a8131c43b4 --- /dev/null +++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyBrowserUtils.cpp @@ -0,0 +1,80 @@ +#include "PropertyBrowserUtils.h" + +#include <QHBoxLayout> +#include <QToolButton> +#include <QFileDialog> +#include <QFocusEvent> +#include <QPixmap> + +#include <iostream> + +MaterialPropertyEdit::MaterialPropertyEdit(QWidget *parent) + : QWidget(parent) +{ + std::cout << "FileEdit::FileEdit() -> XXX" << std::endl; + QHBoxLayout *layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); +// theLineEdit = new QLineEdit(this); +// theLineEdit->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred)); + + m_label = new QLabel(this); + // m_label->setPixmap(m_materialProperty.getPixmap()); + m_label->setText(m_materialProperty.getName()); + + + QToolButton *button = new QToolButton(this); + button->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred)); + button->setText(QLatin1String("...")); +// layout->addWidget(theLineEdit); + layout->addWidget(m_label); + layout->addWidget(button); +// setFocusProxy(theLineEdit); + setFocusPolicy(Qt::StrongFocus); + setAttribute(Qt::WA_InputMethodEnabled); +// connect(theLineEdit, SIGNAL(textEdited(const QString &)), +// this, SIGNAL(filePathChanged(const QString &))); + connect(button, SIGNAL(clicked()), + this, SLOT(buttonClicked())); +} + +void MaterialPropertyEdit::buttonClicked() +{ + std::cout << "MaterialPropertyEdit::buttonClicked() -> " << std::endl; + QString filePath = QFileDialog::getOpenFileName(this, tr("Choose a file"), theLineEdit->text(), theFilter); + if (filePath.isNull()) +// return; +// theLineEdit->setText(filePath); + m_label->setText(filePath); + //emit filePathChanged(filePath); + emit materialPropertyChanged(m_materialProperty); +} + +void MaterialPropertyEdit::focusInEvent(QFocusEvent *e) +{ + std::cout << "MaterialPropertyEdit::focusInEvent() -> " << std::endl; +// theLineEdit->event(e); +// if (e->reason() == Qt::TabFocusReason || e->reason() == Qt::BacktabFocusReason) { +// theLineEdit->selectAll(); +// } + QWidget::focusInEvent(e); +} + +void MaterialPropertyEdit::focusOutEvent(QFocusEvent *e) +{ + std::cout << "MaterialPropertyEdit::focusOutEvent() -> " << std::endl; +// theLineEdit->event(e); + QWidget::focusOutEvent(e); +} + +void MaterialPropertyEdit::keyPressEvent(QKeyEvent *e) +{ + std::cout << "MaterialPropertyEdit::keyPressEvent() -> " << std::endl; +// theLineEdit->event(e); +} + +void MaterialPropertyEdit::keyReleaseEvent(QKeyEvent *e) +{ + std::cout << "MaterialPropertyEdit::keyReleaseEvent() -> " << std::endl; +// theLineEdit->event(e); +} diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyBrowserUtils.h b/GUI/coregui/Views/Components/SampleDesigner/PropertyBrowserUtils.h new file mode 100644 index 0000000000000000000000000000000000000000..d27b3dbba2466bdab839fa5cedbf36174b664a9a --- /dev/null +++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyBrowserUtils.h @@ -0,0 +1,43 @@ +#ifndef PROPERTYBROWSERUTILS_H +#define PROPERTYBROWSERUTILS_H + +#include <QLineEdit> +#include <QLabel> +#include "MaterialBrowser.h" + +#include <QIcon> + +//! +class MaterialPropertyEdit : public QWidget +{ + Q_OBJECT +public: + MaterialPropertyEdit(QWidget *parent = 0); +// void setFilePath(const QString &filePath) { if (theLineEdit->text() != filePath) theLineEdit->setText(filePath); } +// QString filePath() const { return theLineEdit->text(); } +// void setFilter(const QString &filter) { theFilter = filter; } +// QString filter() const { return theFilter; } + + void setMaterialProperty(const MaterialProperty &materialProperty) { m_materialProperty = materialProperty; } + MaterialProperty getMaterialProperty() const {return m_materialProperty; } +signals: +// void filePathChanged(const QString &filePath); + void materialPropertyChanged(const MaterialProperty &material); +protected: + void focusInEvent(QFocusEvent *e); + void focusOutEvent(QFocusEvent *e); + void keyPressEvent(QKeyEvent *e); + void keyReleaseEvent(QKeyEvent *e); +private slots: + void buttonClicked(); +private: + QLineEdit *theLineEdit; + QString theFilter; + QLabel *m_label; + MaterialProperty m_materialProperty; +}; + + + + +#endif // PROPERTYBROWSERUTILS_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.cpp b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.cpp new file mode 100644 index 0000000000000000000000000000000000000000..0674092d4511d84b0a32b2b69fca9e1808ea50ed --- /dev/null +++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.cpp @@ -0,0 +1,132 @@ +#include "PropertyVariantFactory.h" +#include "PropertyVariantManager.h" +#include "PropertyBrowserUtils.h" +#include "MaterialBrowser.h" + +#include <iostream> + +PropertyVariantFactory::~PropertyVariantFactory() +{ + QList<MaterialPropertyEdit *> editors = theEditorToProperty.keys(); + QListIterator<MaterialPropertyEdit *> it(editors); + while (it.hasNext()) + delete it.next(); +} + +void PropertyVariantFactory::connectPropertyManager(QtVariantPropertyManager *manager) +{ + connect(manager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), + this, SLOT(slotPropertyChanged(QtProperty *, const QVariant &))); + connect(manager, SIGNAL(attributeChanged(QtProperty *, const QString &, const QVariant &)), + this, SLOT(slotPropertyAttributeChanged(QtProperty *, const QString &, const QVariant &))); + QtVariantEditorFactory::connectPropertyManager(manager); +} + +QWidget *PropertyVariantFactory::createEditor(QtVariantPropertyManager *manager, + QtProperty *property, QWidget *parent) +{ + if (manager->propertyType(property) == PropertyVariantManager::materialTypeId()) { + MaterialPropertyEdit *editor = new MaterialPropertyEdit(parent); +// editor->setFilePath(manager->value(property).toString()); +// editor->setFilter(manager->attributeValue(property, QLatin1String("filter")).toString()); + + QVariant var = manager->value(property); + MaterialProperty mat = var.value<MaterialProperty>(); + editor->setMaterialProperty(mat); + + theCreatedEditors[property].append(editor); + theEditorToProperty[editor] = property; + +// connect(editor, SIGNAL(filePathChanged(const QString &)), +// this, SLOT(slotSetValue(const QString &))); + connect(editor, SIGNAL(materialPropertyChanged(const MaterialProperty &)), + this, SLOT(slotSetValue(const MaterialProperty &))); + connect(editor, SIGNAL(destroyed(QObject *)), + this, SLOT(slotEditorDestroyed(QObject *))); + return editor; + } + return QtVariantEditorFactory::createEditor(manager, property, parent); +} + +void PropertyVariantFactory::disconnectPropertyManager(QtVariantPropertyManager *manager) +{ + disconnect(manager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), + this, SLOT(slotPropertyChanged(QtProperty *, const QVariant &))); + disconnect(manager, SIGNAL(attributeChanged(QtProperty *, const QString &, const QVariant &)), + this, SLOT(slotPropertyAttributeChanged(QtProperty *, const QString &, const QVariant &))); + QtVariantEditorFactory::disconnectPropertyManager(manager); +} + +void PropertyVariantFactory::slotPropertyChanged(QtProperty *property, + const QVariant &value) +{ + std::cout << "PropertyVariantFactory::slotPropertyChanged() ->" << std::endl; + if (!theCreatedEditors.contains(property)) + return; + + QList<MaterialPropertyEdit *> editors = theCreatedEditors[property]; + QListIterator<MaterialPropertyEdit *> itEditor(editors); +// while (itEditor.hasNext()) +// itEditor.next()->setFilePath(value.toString()); + while (itEditor.hasNext()) { + MaterialProperty mat = value.value<MaterialProperty>(); + itEditor.next()->setMaterialProperty(mat); + } +} + +void PropertyVariantFactory::slotPropertyAttributeChanged(QtProperty *property, + const QString &attribute, const QVariant &value) +{ + std::cout << "PropertyVariantFactory::slotPropertyAttributeChanged() ->" << std::endl; +// if (!theCreatedEditors.contains(property)) +// return; + +// if (attribute != QLatin1String("filter")) +// return; + +// QList<MaterialPropertyEdit *> editors = theCreatedEditors[property]; +// QListIterator<MaterialPropertyEdit *> itEditor(editors); +// while (itEditor.hasNext()) +// itEditor.next()->setFilter(value.toString()); +} + +void PropertyVariantFactory::slotSetValue(const MaterialProperty &value) +//void PropertyVariantFactory::slotSetValue(const QString &value) +{ + std::cout << "PropertyVariantFactory::slotSetValue() -> " << std::endl; + QObject *object = sender(); + QMap<MaterialPropertyEdit *, QtProperty *>::ConstIterator itEditor = + theEditorToProperty.constBegin(); + while (itEditor != theEditorToProperty.constEnd()) { + if (itEditor.key() == object) { + QtProperty *property = itEditor.value(); + QtVariantPropertyManager *manager = propertyManager(property); + if (!manager) + return; + QVariant var; + var.setValue(value); + manager->setValue(property, var); + return; + } + itEditor++; + } +} + +void PropertyVariantFactory::slotEditorDestroyed(QObject *object) +{ + QMap<MaterialPropertyEdit *, QtProperty *>::ConstIterator itEditor = + theEditorToProperty.constBegin(); + while (itEditor != theEditorToProperty.constEnd()) { + if (itEditor.key() == object) { + MaterialPropertyEdit *editor = itEditor.key(); + QtProperty *property = itEditor.value(); + theEditorToProperty.remove(editor); + theCreatedEditors[property].removeAll(editor); + if (theCreatedEditors[property].isEmpty()) + theCreatedEditors.remove(property); + return; + } + itEditor++; + } +} + diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.h b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.h new file mode 100644 index 0000000000000000000000000000000000000000..ba72da9ab7d3983ffdb6223d03e6b1c799044230 --- /dev/null +++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantFactory.h @@ -0,0 +1,38 @@ +#ifndef OBJECTVARIANTFACTORY_H +#define OBJECTVARIANTFACTORY_H + + + +#include <QtVariantEditorFactory> + +class MaterialPropertyEdit; +class MaterialProperty; + + +class PropertyVariantFactory : public QtVariantEditorFactory +{ + Q_OBJECT +public: + PropertyVariantFactory(QObject *parent = 0) + : QtVariantEditorFactory(parent) + { } + + virtual ~PropertyVariantFactory(); +protected: + virtual void connectPropertyManager(QtVariantPropertyManager *manager); + virtual QWidget *createEditor(QtVariantPropertyManager *manager, QtProperty *property, + QWidget *parent); + virtual void disconnectPropertyManager(QtVariantPropertyManager *manager); +private slots: + void slotPropertyChanged(QtProperty *property, const QVariant &value); + void slotPropertyAttributeChanged(QtProperty *property, const QString &attribute, const QVariant &value); + void slotSetValue(const MaterialProperty &value); +// void slotSetValue(const QString &value); + void slotEditorDestroyed(QObject *object); +private: + QMap<QtProperty *, QList<MaterialPropertyEdit *> > theCreatedEditors; + QMap<MaterialPropertyEdit *, QtProperty *> theEditorToProperty; +}; + + +#endif // OBJECTVARIANTFACTORY_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantManager.cpp b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantManager.cpp new file mode 100644 index 0000000000000000000000000000000000000000..69a80a216e4de2252b22f7c036754dca76c58647 --- /dev/null +++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantManager.cpp @@ -0,0 +1,165 @@ +#include "PropertyVariantManager.h" +//#include "DesignerHelper.h" +#include "MaterialBrowser.h" + +#include "Types.h" +Q_DECLARE_METATYPE(complex_t) + +#include <iostream> + +PropertyVariantManager::PropertyVariantManager(QObject *parent) + : QtVariantPropertyManager(parent) +{ + +} + + +PropertyVariantManager::~PropertyVariantManager() +{ +} + + +//int ObjectVariantManager::complexTypeId() +//{ +// return qMetaTypeId<complex_t>(); +//} + +int PropertyVariantManager::materialTypeId() +{ + return qMetaTypeId<MaterialProperty>(); +} + + +bool PropertyVariantManager::isPropertyTypeSupported(int propertyType) const +{ + if (propertyType == materialTypeId()) + return true; + return QtVariantPropertyManager::isPropertyTypeSupported(propertyType); +} + +int PropertyVariantManager::valueType(int propertyType) const +{ + if (propertyType == materialTypeId()) + return materialTypeId(); +// return QVariant::String; + return QtVariantPropertyManager::valueType(propertyType); +} + +QVariant PropertyVariantManager::value(const QtProperty *property) const +{ + if (theValues.contains(property)) { + QVariant v; + v.setValue(theValues[property]); + std::cout << "PropertyVariantManager::value() -> " << std::endl; + return v; + } + // return theValues[property].value; + return QtVariantPropertyManager::value(property); +} + +//QStringList ObjectVariantManager::attributes(int propertyType) const +//{ +// if (propertyType == materialTypeId()) { +// QStringList attr; +// attr << QLatin1String("filter"); +// return attr; +// } +// return QtVariantPropertyManager::attributes(propertyType); +//} + +//int ObjectVariantManager::attributeType(int propertyType, const QString &attribute) const +//{ +// if (propertyType == materialTypeId()) { +// if (attribute == QLatin1String("filter")) +// return QVariant::String; +// return 0; +// } +// return QtVariantPropertyManager::attributeType(propertyType, attribute); +//} + +//QVariant ObjectVariantManager::attributeValue(const QtProperty *property, const QString &attribute) const +//{ +// if (theValues.contains(property)) { +// if (attribute == QLatin1String("filter")) +// return theValues[property].filter; +// return QVariant(); +// } +// return QtVariantPropertyManager::attributeValue(property, attribute); +//} + +QString PropertyVariantManager::valueText(const QtProperty *property) const +{ + if (theValues.contains(property)) { + return theValues[property].getName(); + //return theValues[property].value; + } + return QtVariantPropertyManager::valueText(property); +} + + +QIcon PropertyVariantManager::valueIcon(const QtProperty *property) const +{ + if (theValues.contains(property)) { + return QIcon(theValues[property].getPixmap()); + } + return QtVariantPropertyManager::valueIcon(property); +} + + +void PropertyVariantManager::setValue(QtProperty *property, const QVariant &val) +{ + if (theValues.contains(property)) { +// if (val.type() != QVariant::String && !val.canConvert(QVariant::String)) +// return; +// QString str = qVariantValue<QString>(val); +// Data d = theValues[property]; +// if (d.value == str) +// return; +// d.value = str; +// theValues[property] = d; +// emit propertyChanged(property); +// emit valueChanged(property, str); +// return; + std::cout << "ObjectVariantManager::setValue() -> XXX" << std::endl; + + return; + } + QtVariantPropertyManager::setValue(property, val); +} + +//void ObjectVariantManager::setAttribute(QtProperty *property, +// const QString &attribute, const QVariant &val) +//{ +// if (theValues.contains(property)) { +// if (attribute == QLatin1String("filter")) { +// if (val.type() != QVariant::String && !val.canConvert(QVariant::String)) +// return; +// QString str = qVariantValue<QString>(val); +// Data d = theValues[property]; +// if (d.filter == str) +// return; +// d.filter = str; +// theValues[property] = d; +// emit attributeChanged(property, attribute, str); +// } +// return; +// } +// QtVariantPropertyManager::setAttribute(property, attribute, val); +//} + +void PropertyVariantManager::initializeProperty(QtProperty *property) +{ + if (propertyType(property) == materialTypeId()) { + std::cout << "ObjectVariantManager::initializeProperty() -> " << std::endl; + MaterialProperty m; + theValues[property] = m; + } + QtVariantPropertyManager::initializeProperty(property); +} + +void PropertyVariantManager::uninitializeProperty(QtProperty *property) +{ + theValues.remove(property); + QtVariantPropertyManager::uninitializeProperty(property); +} + diff --git a/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantManager.h b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantManager.h new file mode 100644 index 0000000000000000000000000000000000000000..09d841d87b480526833189c3419bf2f5c83d3a8f --- /dev/null +++ b/GUI/coregui/Views/Components/SampleDesigner/PropertyVariantManager.h @@ -0,0 +1,48 @@ +#ifndef OBJECTVARIANTMANAGER_H +#define OBJECTVARIANTMANAGER_H + +//! collection of classes extending QtPropertyBrowser functionality + +#include <QtVariantPropertyManager> +#include "MaterialBrowser.h" +class QObject; + +//! The ObjectVariantManager class provides and manages user defined QVariant based properties. +class PropertyVariantManager : public QtVariantPropertyManager +{ + Q_OBJECT +public: + PropertyVariantManager(QObject *parent = 0); + ~PropertyVariantManager(); + + virtual QVariant value(const QtProperty *property) const; + virtual int valueType(int propertyType) const; + virtual bool isPropertyTypeSupported(int propertyType) const; + +// virtual QStringList attributes(int propertyType) const; +// virtual int attributeType(int propertyType, const QString &attribute) const; +// virtual QVariant attributeValue(const QtProperty *property, const QString &attribute) const; + + static int materialTypeId(); + +public slots: + virtual void setValue(QtProperty *property, const QVariant &val); +// virtual void setAttribute(QtProperty *property, +// const QString &attribute, const QVariant &value); +protected: + virtual QString valueText(const QtProperty *property) const; + QIcon valueIcon(const QtProperty *property) const; + + virtual void initializeProperty(QtProperty *property); + virtual void uninitializeProperty(QtProperty *property); +private: +// struct Data { +// QString value; +// QString filter; +// }; +// QMap<const QtProperty *, Data> theValues; + QMap<const QtProperty *, MaterialProperty> theValues; +}; + + +#endif // OBJECTVARIANTMANAGER_H diff --git a/GUI/coregui/Views/Components/SampleDesigner/SampleDesigner.pri b/GUI/coregui/Views/Components/SampleDesigner/SampleDesigner.pri index 3d6b54b1ad454e2483dcd62247904237467f7eb5..2b60d2b5b4389a7285eba79c8c20f6fad500a96e 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/SampleDesigner.pri +++ b/GUI/coregui/Views/Components/SampleDesigner/SampleDesigner.pri @@ -26,8 +26,9 @@ SOURCES += \ Views/Components/SampleDesigner/MaterialBrowserModel.cpp \ Views/Components/SampleDesigner/MaterialBrowserView.cpp \ Views/Components/SampleDesigner/MaterialBrowser.cpp \ - Views/Components/SampleDesigner/ObjectPropertyManager.cpp \ - Views/Components/SampleDesigner/ObjectVariantManager.cpp + Views/Components/SampleDesigner/PropertyBrowserUtils.cpp \ + Views/Components/SampleDesigner/PropertyVariantManager.cpp \ + Views/Components/SampleDesigner/PropertyVariantFactory.cpp HEADERS += \ @@ -54,8 +55,9 @@ HEADERS += \ Views/Components/SampleDesigner/MaterialBrowserModel.h \ Views/Components/SampleDesigner/MaterialBrowserView.h \ Views/Components/SampleDesigner/MaterialBrowser.h \ - Views/Components/SampleDesigner/ObjectPropertyManager.h \ - Views/Components/SampleDesigner/ObjectVariantManager.h + Views/Components/SampleDesigner/PropertyBrowserUtils.h \ + Views/Components/SampleDesigner/PropertyVariantManager.h \ + Views/Components/SampleDesigner/PropertyVariantFactory.h RESOURCES += Views/Components/SampleDesigner/SampleDesigner.qrc diff --git a/GUI/coregui/Views/Components/SampleDesigner/SamplePropertyEditor.cpp b/GUI/coregui/Views/Components/SampleDesigner/SamplePropertyEditor.cpp index 80c67628192c8898067c2d58ef799d996177c3b1..49dac6564579380d59277ca2e589062daba2f36f 100644 --- a/GUI/coregui/Views/Components/SampleDesigner/SamplePropertyEditor.cpp +++ b/GUI/coregui/Views/Components/SampleDesigner/SamplePropertyEditor.cpp @@ -1,6 +1,6 @@ #include "SamplePropertyEditor.h" -//#include "VariantManager.h" -#include "ObjectVariantManager.h" +#include "PropertyVariantManager.h" +#include "PropertyVariantFactory.h" #include "qtvariantproperty.h" #include "qttreepropertybrowser.h" @@ -80,16 +80,19 @@ SamplePropertyEditor::SamplePropertyEditor(SampleDesignerInterface *sample_desig //m_readOnlyManager = new QtVariantPropertyManager(this); //m_readOnlyManager = new VariantManager(this); - m_readOnlyManager = new ObjectVariantManager(this); + m_readOnlyManager = new PropertyVariantManager(this); //m_manager = new QtVariantPropertyManager(this); //m_manager = new VariantManager(this); - m_manager = new ObjectVariantManager(this); + m_manager = new PropertyVariantManager(this); - QtVariantEditorFactory *factory = new QtVariantEditorFactory(this); +// QtVariantEditorFactory *factory = new QtVariantEditorFactory(this); +// m_browser->setFactoryForManager(m_manager, factory); + QtVariantEditorFactory *factory = new PropertyVariantFactory(); m_browser->setFactoryForManager(m_manager, factory); + connect(m_manager, SIGNAL(valueChanged(QtProperty *, const QVariant &)), this, SLOT(slotValueChanged(QtProperty *, const QVariant &)));