diff --git a/Mapper.cpp b/Mapper.cpp index 34e833e..0d33a38 100644 --- a/Mapper.cpp +++ b/Mapper.cpp @@ -63,34 +63,6 @@ QWidget* Mapper::getPropertiesEditor() return _propertyBrowser; } -TextureMapper::TextureMapper(std::tr1::shared_ptr mapping) - : Mapper(mapping) -{ - // Assign members pointers. - textureMapping = std::tr1::static_pointer_cast(_mapping); - Q_CHECK_PTR(textureMapping); - - texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); - Q_CHECK_PTR(texture); - - inputShape = std::tr1::static_pointer_cast(textureMapping->getInputShape()); - Q_CHECK_PTR(inputShape); - - // Input shape. - _inputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), - QObject::tr("Input shape")); - - _buildShapeProperty(_inputItem, textureMapping->getInputShape().get()); - _topItem->insertSubProperty(_inputItem, 0); // insert before output item -} - -void TextureMapper::updatePaint() -{ - texture.reset(); - texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); - Q_CHECK_PTR(texture); -} - void Mapper::setValue(QtProperty* property, const QVariant& value) { std::map >::iterator it = _propertyToVertex.find(property); @@ -249,6 +221,28 @@ void EllipseColorMapper::drawControls(QPainter* painter) Util::drawControlsEllipse(painter, *outputEllipse); } + +TextureMapper::TextureMapper(std::tr1::shared_ptr mapping) + : Mapper(mapping) +{ + // Assign members pointers. + textureMapping = std::tr1::static_pointer_cast(_mapping); + Q_CHECK_PTR(textureMapping); + + texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); + Q_CHECK_PTR(texture); + + inputShape = std::tr1::static_pointer_cast(textureMapping->getInputShape()); + Q_CHECK_PTR(inputShape); + + // Input shape. + _inputItem = _variantManager->addProperty(QtVariantPropertyManager::groupTypeId(), + QObject::tr("Input shape")); + + _buildShapeProperty(_inputItem, textureMapping->getInputShape().get()); + _topItem->insertSubProperty(_inputItem, 0); // insert before output item +} + void TextureMapper::draw(QPainter* painter) { // Prepare drawing. @@ -308,7 +302,11 @@ void TextureMapper::updateShape(Shape* shape) } +void TextureMapper::updatePaint() { + texture.reset(); + texture = std::tr1::static_pointer_cast(textureMapping->getPaint()); + Q_CHECK_PTR(texture); } void TextureMapper::_preDraw(QPainter* painter) @@ -338,13 +336,9 @@ void TextureMapper::_preDraw(QPainter* painter) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); -void TextureMapper::drawControls(QPainter* painter) -{ - } void TextureMapper::_postDraw(QPainter* painter) -void TextureMapper::drawInputControls(QPainter* painter) { glDisable(GL_TEXTURE_2D); diff --git a/Mapper.h b/Mapper.h index 5ad8c08..9f9f5f0 100644 --- a/Mapper.h +++ b/Mapper.h @@ -87,18 +87,14 @@ public: public slots: virtual void setValue(QtProperty* property, const QVariant& value); - virtual void updateShape(Shape* shape) - { - Q_UNUSED(shape); - } - virtual void updatePaint() - { - } + virtual void updateShape(Shape* shape) { Q_UNUSED(shape); } + virtual void updatePaint() {} signals: void valueChanged(); protected: + Mapping::ptr _mapping; QtAbstractPropertyBrowser* _propertyBrowser; QtVariantEditorFactory* _variantFactory; QtVariantPropertyManager* _variantManager; @@ -192,8 +188,8 @@ public: virtual void draw(QPainter* painter); virtual void drawInput(QPainter* painter); - virtual void drawControls(QPainter* painter); - virtual void drawInputControls(QPainter* painter); + virtual void drawControls(QPainter* painter) = 0; + virtual void drawInputControls(QPainter* painter) = 0; public slots: virtual void updateShape(Shape* shape);