Some cleanup / reorganization of code

This commit is contained in:
Tats
2014-06-10 22:27:12 -04:00
parent 66dc735861
commit aa39752b98
2 changed files with 31 additions and 41 deletions
+26 -32
View File
@@ -63,34 +63,6 @@ QWidget* Mapper::getPropertiesEditor()
return _propertyBrowser;
}
TextureMapper::TextureMapper(std::tr1::shared_ptr<TextureMapping> mapping)
: Mapper(mapping)
{
// Assign members pointers.
textureMapping = std::tr1::static_pointer_cast<TextureMapping>(_mapping);
Q_CHECK_PTR(textureMapping);
texture = std::tr1::static_pointer_cast<Texture>(textureMapping->getPaint());
Q_CHECK_PTR(texture);
inputShape = std::tr1::static_pointer_cast<Shape>(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<Texture>(textureMapping->getPaint());
Q_CHECK_PTR(texture);
}
void Mapper::setValue(QtProperty* property, const QVariant& value)
{
std::map<QtProperty*, std::pair<Shape*, int> >::iterator it = _propertyToVertex.find(property);
@@ -249,6 +221,28 @@ void EllipseColorMapper::drawControls(QPainter* painter)
Util::drawControlsEllipse(painter, *outputEllipse);
}
TextureMapper::TextureMapper(std::tr1::shared_ptr<TextureMapping> mapping)
: Mapper(mapping)
{
// Assign members pointers.
textureMapping = std::tr1::static_pointer_cast<TextureMapping>(_mapping);
Q_CHECK_PTR(textureMapping);
texture = std::tr1::static_pointer_cast<Texture>(textureMapping->getPaint());
Q_CHECK_PTR(texture);
inputShape = std::tr1::static_pointer_cast<Shape>(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<Texture>(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);
+5 -9
View File
@@ -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);