diff --git a/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt b/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt index 44c0b21bc..56d425655 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt +++ b/code/nel/tools/3d/object_viewer_qt/src/CMakeLists.txt @@ -13,7 +13,7 @@ SET(OBJECT_VIEWER_HDR main_window.h graphics_viewport.h animation_dialog.h emitter_page.h attrib_widget.h located_bindable_page.h located_page.h particle_force_page.h particle_light_page.h particle_zone_page.h particle_sound_page.h basic_edit_widget.h direction_widget.h color_edit_widget.h particle_property_dialog.h - ps_mover_page.h graphics_info_widget.h value_blender_dialog.h value_gradient_dialog.h + ps_mover_page.h value_blender_dialog.h value_gradient_dialog.h value_from_emitter_dialog.h curve_dialog.h bin_op_dialog.h hoverpoints.h mesh_widget.h morph_mesh_dialog.h constraint_mesh_widget.h tail_particle_widget.h auto_lod_dialog.h particle_texture_widget.h particle_texture_anim_widget.h diff --git a/code/nel/tools/3d/object_viewer_qt/src/basic_edit_form.ui b/code/nel/tools/3d/object_viewer_qt/src/basic_edit_form.ui index 287adaf53..95eb744ff 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/basic_edit_form.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/basic_edit_form.ui @@ -45,7 +45,7 @@ - + 0 @@ -110,14 +110,6 @@ - - - NLQT::CGraphicsInfoWidget - QWidget -
graphics_info_widget.h
- 1 -
-
diff --git a/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.cpp index b256bf38f..b3816a034 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.cpp @@ -21,6 +21,7 @@ #include "basic_edit_widget.h" // Qt includes +#include // NeL includes #include "nel/misc/matrix.h" @@ -143,6 +144,7 @@ CBasicEditWidget::CBasicEditWidget(QWidget *parent) _Wrapper(NULL) { _ui.setupUi(this); + _ui.graphicsWidget->installEventFilter(this); connect(_ui.psiSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateGraphics())); connect(_ui.thetaSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateGraphics())); @@ -199,4 +201,16 @@ void CBasicEditWidget::updateGraphics() repaint(); } +bool CBasicEditWidget::eventFilter(QObject *object, QEvent *event) +{ + if( event->type() == QEvent::Paint ) + { + QPainter painter(_ui.graphicsWidget); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setBrush(QBrush(Qt::white)); + painter.setPen(QPen(Qt::black, 2, Qt::SolidLine)); + painter.drawRoundedRect(QRect(3, 3, _ui.graphicsWidget->width() - 6, _ui.graphicsWidget->height() - 6), 3.0, 3.0); + } + return QWidget::eventFilter(object, event); +} } /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.h b/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.h index 0ddbe6b72..0269ce3c8 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/basic_edit_widget.h @@ -48,7 +48,8 @@ public: private Q_SLOTS: void updateGraphics(); -private: +private: + bool eventFilter(QObject *object, QEvent *event); // wrapper to the datas IPSWrapper *_Wrapper ; diff --git a/code/nel/tools/3d/object_viewer_qt/src/color_edit_form.ui b/code/nel/tools/3d/object_viewer_qt/src/color_edit_form.ui index 5ab22dac6..4a7e39f96 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/color_edit_form.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/color_edit_form.ui @@ -71,7 +71,7 @@ - + 0 @@ -128,14 +128,6 @@ - - - NLQT::CGraphicsInfoWidget - QWidget -
graphics_info_widget.h
- 1 -
-
diff --git a/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp index 2582e7171..a32732133 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.cpp @@ -23,6 +23,7 @@ // Qt includes #include #include +#include // Nel includes #include @@ -37,6 +38,8 @@ CColorEditWidget::CColorEditWidget(QWidget *parent) { _ui.setupUi(this); + _ui.graphicsWidget->installEventFilter(this); + connect(_ui.rSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setRed(int))); connect(_ui.gSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setGreen(int))); connect(_ui.bSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setBlue(int))); @@ -65,6 +68,8 @@ void CColorEditWidget::setColor(const NLMISC::CRGBA &color, bool emit) _emit = true; if (emit) Q_EMIT colorChanged(color); + + _ui.graphicsWidget->repaint(); } void CColorEditWidget::setColor(const QColor &color, bool emit) @@ -75,28 +80,17 @@ void CColorEditWidget::setColor(const QColor &color, bool emit) void CColorEditWidget::updateUi() { if (_Wrapper == NULL) return; - _ui.rSpinBox->setValue(_Wrapper->get().R); - _ui.gSpinBox->setValue(_Wrapper->get().G); - _ui.bSpinBox->setValue(_Wrapper->get().B); - _ui.aSpinBox->setValue(_Wrapper->get().A); - _ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - _ui.aSpinBox->value())); + setColor(_Wrapper->get()); } void CColorEditWidget::setRed(int r) { - _ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - _ui.aSpinBox->value())); - if (_emit) Q_EMIT colorChanged(NLMISC::CRGBA(r, _ui.gSpinBox->value(), _ui.bSpinBox->value(), _ui.aSpinBox->value())); + _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) return; @@ -112,17 +106,12 @@ void CColorEditWidget::setRed(int r) void CColorEditWidget::setGreen(int g) { - _ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - _ui.aSpinBox->value())); - if (_emit) Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), g, _ui.bSpinBox->value(), _ui.aSpinBox->value())); - + _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) return; NLMISC::CRGBA color = _Wrapper->get(); @@ -136,17 +125,12 @@ void CColorEditWidget::setGreen(int g) void CColorEditWidget::setBlue(int b) { - _ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - _ui.aSpinBox->value())); - if (_emit) Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), _ui.gSpinBox->value(), b, _ui.aSpinBox->value())); - + _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) return; NLMISC::CRGBA color = _Wrapper->get(); @@ -160,16 +144,12 @@ void CColorEditWidget::setBlue(int b) void CColorEditWidget::setAlpha(int a) { - _ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(), - _ui.gSpinBox->value(), - _ui.bSpinBox->value(), - a)); - if (_emit) Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(), _ui.gSpinBox->value(), _ui.bSpinBox->value(), a)); + _ui.graphicsWidget->repaint(); if (_Wrapper == NULL) return; @@ -193,4 +173,22 @@ void CColorEditWidget::browseColor() setColor(color); } +bool CColorEditWidget::eventFilter(QObject *object, QEvent *event) +{ + if( event->type() == QEvent::Paint ) + { + _color = QColor(_ui.rSpinBox->value(), + _ui.gSpinBox->value(), + _ui.bSpinBox->value(), + _ui.aSpinBox->value()); + + QPainter painter(_ui.graphicsWidget); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setBrush(QBrush(_color)); + painter.setPen(QPen(Qt::black, 2, Qt::SolidLine)); + painter.drawRoundedRect(QRect(3, 3, _ui.graphicsWidget->width() - 6, _ui.graphicsWidget->height() - 6), 3.0, 3.0); + } + return QWidget::eventFilter(object, event); +} + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.h b/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.h index 65bc34684..17a7327bc 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/color_edit_widget.h @@ -88,9 +88,11 @@ private Q_SLOTS: private: + bool eventFilter(QObject *object, QEvent *event); // wrapper to the datas IPSWrapperRGBA *_Wrapper; + QColor _color; bool _emit; Ui::CColorEditWidget _ui; diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_form.ui b/code/nel/tools/3d/object_viewer_qt/src/direction_form.ui index 586298682..46de722ab 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/direction_form.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/direction_form.ui @@ -120,7 +120,7 @@ - + 0 @@ -142,7 +142,7 @@ - + 0 @@ -178,14 +178,6 @@ - - - NLQT::CGraphicsInfoWidget - QWidget -
graphics_info_widget.h
- 1 -
-
diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp index e25c52d87..65ae44140 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.cpp @@ -22,22 +22,25 @@ // Qt includes #include +#include +#include // NeL includes #include namespace NLQT { +const int directionSize = 35; CDirectionWidget::CDirectionWidget(QWidget *parent) : QWidget(parent), _globalName("") { _ui.setupUi(this); - _ui.xzWidget->setMode(Mode::Direction); - _ui.yzWidget->setMode(Mode::Direction); - _ui.xzWidget->setText("XZ"); - _ui.yzWidget->setText("YZ"); + _ui.xzWidget->installEventFilter(this); + _ui.yzWidget->installEventFilter(this); + _ui.xzWidget->setObjectName("XZ"); + _ui.yzWidget->setObjectName("YZ"); _ui.globalPushButton->hide(); connect(_ui.globalPushButton ,SIGNAL(clicked()), this, SLOT(setGlobalDirection())); @@ -48,9 +51,6 @@ CDirectionWidget::CDirectionWidget(QWidget *parent) connect(_ui.decVecJPushButton ,SIGNAL(clicked()), this, SLOT(decVecJ())); connect(_ui.decVecKPushButton ,SIGNAL(clicked()), this, SLOT(decVecK())); - connect(_ui.xzWidget, SIGNAL(applyNewVector(float,float)), this, SLOT(setNewVecXZ(float,float))); - connect(_ui.yzWidget, SIGNAL(applyNewVector(float,float)), this, SLOT(setNewVecYZ(float,float))); - // Set default value +K setValue(NLMISC::CVector::K); } @@ -68,8 +68,6 @@ void CDirectionWidget::enabledGlobalVariable(bool enabled) void CDirectionWidget::setValue(const NLMISC::CVector &value, bool emit) { _value = value; - _ui.xzWidget->setVector(_value.x, _value.z); - _ui.yzWidget->setVector(_value.y, _value.z); _ui.xzWidget->repaint(); _ui.yzWidget->repaint(); @@ -184,4 +182,47 @@ void CDirectionWidget::setNewVecYZ(float x, float y) setValue(v); } +bool CDirectionWidget::eventFilter(QObject *object, QEvent *event) +{ + QWidget *widget = qobject_cast(object); + switch (event->type()) + { + case QEvent::Paint: + { + float x; + if (widget->objectName() == "XZ") + x = _value.x; + else + x = _value.y; + QPainter painter(widget); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setBrush(QBrush(Qt::white)); + painter.setPen(QPen(Qt::black, 2, Qt::SolidLine)); + painter.drawRoundedRect(QRect(3, 3, widget->width() - 6, widget->height() - 6), 3.0, 3.0); + painter.setPen(QPen(Qt::gray, 1, Qt::SolidLine)); + painter.drawLine(widget->width() / 2, 4, widget->width() / 2, widget->height() - 4); + painter.drawLine(4, widget->height() / 2, widget->width() - 4, widget->height() / 2); + painter.drawText( 10, 15, widget->objectName()); + painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); + painter.drawLine(widget->width() / 2, widget->height() / 2, + int((widget->width() / 2) + x * 0.9f * directionSize), int((widget->height() / 2) - _value.z * 0.9f * directionSize)); + break; + } + case QEvent::MouseButtonDblClick: + { + QMouseEvent *mouseEvent = (QMouseEvent *) event; + float vx = (mouseEvent->x() - (widget->width() / 2)) / 0.9f; + float vy = ((widget->height() / 2) - mouseEvent->y()) / 0.9f; + + if (widget->objectName() == "XZ") + setNewVecXZ(vx, vy); + else + setNewVecYZ(vx, vy); + + break; + } + } + return QWidget::eventFilter(object, event); +} + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h index 9902b9fea..1be8e3d0f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/direction_widget.h @@ -67,6 +67,8 @@ private Q_SLOTS: void setNewVecYZ(float x, float y); private: + bool eventFilter(QObject *object, QEvent *event); + NLMISC::CVector _value; QString _globalName; diff --git a/code/nel/tools/3d/object_viewer_qt/src/graphics_info_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/graphics_info_widget.cpp deleted file mode 100644 index 84ace73c3..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/graphics_info_widget.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#include "stdpch.h" -#include "graphics_info_widget.h" - -// Qt includes -#include -#include -#include - -// STL includes - -namespace NLQT -{ - -const int directionSize = 35; - -CGraphicsInfoWidget::CGraphicsInfoWidget(QWidget *parent) - : QWidget(parent) -{ - _color = Qt::white; - _mode = Mode::Color; - _x = 0.0; - _y = 0.0; - _text = ""; - _braceMode = false; -} - -CGraphicsInfoWidget::~CGraphicsInfoWidget() -{ -} - -void CGraphicsInfoWidget::setMode(int mode) -{ - _mode = mode; -} - -void CGraphicsInfoWidget::setColor(const QColor &color) -{ - _color = color; - repaint(); -} - -void CGraphicsInfoWidget::setVector(float x, float y) -{ - _mode = Mode::Direction; - _x = x; - _y = y; - repaint(); -} - -void CGraphicsInfoWidget::setText(const QString &text) -{ - _text = text; -} - -void CGraphicsInfoWidget::setRibbonShape(const std::vector &verts, bool braceMode) -{ - _mode = Mode::RibbonShape; - _braceMode = braceMode; - _verts = verts; - repaint(); -} - -void CGraphicsInfoWidget::paintEvent(QPaintEvent *event) -{ - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setBrush(QBrush(_color)); - painter.setPen(QPen(Qt::black, 2, Qt::SolidLine)); - painter.drawRoundedRect(QRect(3, 3, width() - 6, height() - 6), 3.0, 3.0); - if (_mode == Mode::Direction) - { - painter.setPen(QPen(Qt::gray, 1, Qt::SolidLine)); - painter.drawLine(width() / 2, 4, width() / 2, height() - 4); - painter.drawLine(4, height() / 2, width() - 4, height() / 2); - painter.drawText( 10, 15, _text); - - painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); - painter.drawLine(width() / 2, height() / 2, - int((width() / 2) + _x * 0.9f * directionSize), int((height() / 2) - _y * 0.9f * directionSize)); - } - if (_mode == Mode::PlaneBasic) - { - } - if (_mode == Mode::RibbonShape) - { - painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); - painter.scale(0.86, 0.86); - painter.translate(6, 6); - if (_braceMode) - { - for(uint k = 0; k < _verts.size() / 2; ++k) - { - painter.drawLine(int((width() / 2.0) * (1 + _verts[2 * k].x)), - int((height() / 2.0) * (1 - _verts[2 * k].y)), - int((width() / 2.0) * (1 + _verts[2 * k + 1].x)), - int((height() / 2.0) * (1 - _verts[2 * k + 1].y))); - } - } - else - { - for(uint k = 1; k < _verts.size(); ++k) - { - painter.drawLine(int((width() / 2.0) * (1 + _verts[k - 1].x)), - int((height() / 2.0) * (1 - _verts[k - 1].y)), - int((width() / 2.0) * (1 + _verts[ k].x)), - int((height() / 2.0) * (1 - _verts[k].y))); - } - painter.drawLine(int((width() / 2.0) * (1 + _verts[0].x)), - int((height() / 2.0) * (1 - _verts[0].y)), - int((width() / 2.0) * (1 + _verts[_verts.size() - 1].x)), - int((height() / 2.0) * (1 - _verts[_verts.size() - 1].y))); - } - } -} - -void CGraphicsInfoWidget::mouseDoubleClickEvent(QMouseEvent *event) -{ - float vx = (event->x() - (width() / 2)) / 0.9f; - float vy = ((height() / 2) - event->y()) / 0.9f; - - Q_EMIT applyNewVector(vx, vy); -} - -} /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/graphics_info_widget.h b/code/nel/tools/3d/object_viewer_qt/src/graphics_info_widget.h deleted file mode 100644 index 35eaa207b..000000000 --- a/code/nel/tools/3d/object_viewer_qt/src/graphics_info_widget.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - Object Viewer Qt - Copyright (C) 2010 Dzmitry Kamiahin - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -*/ - -#ifndef GRAPHICS_INFO_WIDGET_H -#define GRAPHICS_INFO_WIDGET_H - -// Qt includes -#include - -// STL includes - -// NeL includes -#include - -// Project includes - -namespace NLQT -{ - -struct Mode -{ - enum List - { - Color = 0, - Direction, - PlaneBasic, - RibbonShape - }; -}; - -class CGraphicsInfoWidget: public QWidget -{ - Q_OBJECT - -public: - CGraphicsInfoWidget(QWidget *parent = 0); - ~CGraphicsInfoWidget(); - - void setMode(int mode); - void setColor(const QColor &color); - void setVector(float x, float y); - void setText(const QString &text); - void setRibbonShape(const std::vector &verts, bool braceMode); - -Q_SIGNALS: - void applyNewVector(float x, float y); - -protected: - virtual void paintEvent(QPaintEvent *event); - virtual void mouseDoubleClickEvent(QMouseEvent *event); - - int _mode; - QColor _color; - float _x; - float _y; - QString _text; - std::vector _verts; - bool _braceMode; - -}; /* class CGraphicsInfoWidget */ - -} /* namespace NLQT */ - -#endif // GRAPHICS_INFO_WIDGET_H diff --git a/code/nel/tools/3d/object_viewer_qt/src/tail_form.ui b/code/nel/tools/3d/object_viewer_qt/src/tail_form.ui index 811b6e01f..37258da82 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/tail_form.ui +++ b/code/nel/tools/3d/object_viewer_qt/src/tail_form.ui @@ -43,7 +43,7 @@ - + 72 @@ -114,14 +114,6 @@ - - - NLQT::CGraphicsInfoWidget - QWidget -
graphics_info_widget.h
- 1 -
-
diff --git a/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.cpp index 4072e3746..d08b991be 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.cpp @@ -23,17 +23,18 @@ // NeL includes #include "nel/3d/ps_particle.h" -// Projects includes +// Qt includes +#include namespace NLQT { CTailParticleWidget::CTailParticleWidget(QWidget *parent) - : QWidget(parent) + : QWidget(parent), _Node(NULL), _TailParticle(NULL) { _ui.setupUi(this); + _ui.graphicsWidget->installEventFilter(this); - _ui.pathWidget->setMode(Mode::RibbonShape); connect(_ui.tailFadingCheckBox, SIGNAL(toggled(bool)), this, SLOT(setTailFading(bool))); connect(_ui.ribbonOrientationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRibbonOrientation(int))); connect(_ui.tailShapeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setTailShape(int))); @@ -53,23 +54,19 @@ void CTailParticleWidget::setCurrentTailParticle(CWorkspaceNode *ownerNode, NL3D if (!dynamic_cast(_TailParticle)) { - _ui.pathWidget->hide(); + _ui.graphicsWidget->hide(); _ui.ribbonOrientationComboBox->hide(); _ui.tailShapeComboBox->hide(); } else { - _ui.pathWidget->show(); + _ui.graphicsWidget->show(); _ui.ribbonOrientationComboBox->show(); _ui.tailShapeComboBox->show(); NL3D::CPSRibbon *r = dynamic_cast(_TailParticle); _ui.ribbonOrientationComboBox->setCurrentIndex(r->getOrientation()); - // Update graphics widget - std::vector verts; - verts.resize(r->getNbVerticesInShape()); - r->getShape(&verts[0]); - _ui.pathWidget->setRibbonShape(verts, r->getBraceMode()); + _ui.graphicsWidget->repaint(); } } @@ -114,11 +111,7 @@ void CTailParticleWidget::setTailShape(int index) break; } - // Update graphics widget - std::vector verts; - verts.resize(r->getNbVerticesInShape() ); - r->getShape(&verts[0]); - _ui.pathWidget->setRibbonShape(verts, r->getBraceMode()); + _ui.graphicsWidget->repaint(); } void CTailParticleWidget::setRibbonOrientation(int index) @@ -132,4 +125,52 @@ void CTailParticleWidget::setRibbonOrientation(int index) } } +bool CTailParticleWidget::eventFilter(QObject *object, QEvent *event) +{ + if( event->type() == QEvent::Paint ) + { + QPainter painter(_ui.graphicsWidget); + painter.setRenderHint(QPainter::Antialiasing, true); + painter.setBrush(QBrush(Qt::white)); + painter.setPen(QPen(Qt::black, 2, Qt::SolidLine)); + painter.drawRoundedRect(QRect(3, 3, _ui.graphicsWidget->width() - 6, _ui.graphicsWidget->height() - 6), 3.0, 3.0); + + painter.setPen(QPen(Qt::red, 2, Qt::SolidLine)); + painter.scale(0.86, 0.86); + painter.translate(6, 6); + NL3D::CPSRibbon *r = dynamic_cast(_TailParticle); + if (r) + { + std::vector verts; + verts.resize(r->getNbVerticesInShape() ); + r->getShape(&verts[0]); + if (r->getBraceMode()) + { + for(uint k = 0; k < verts.size() / 2; ++k) + { + painter.drawLine(int((_ui.graphicsWidget->width() / 2.0) * (1 + verts[2 * k].x)), + int((_ui.graphicsWidget->height() / 2.0) * (1 - verts[2 * k].y)), + int((_ui.graphicsWidget->width() / 2.0) * (1 + verts[2 * k + 1].x)), + int((_ui.graphicsWidget->height() / 2.0) * (1 - verts[2 * k + 1].y))); + } + } + else + { + for(uint k = 1; k < verts.size(); ++k) + { + painter.drawLine(int((_ui.graphicsWidget->width() / 2.0) * (1 + verts[k - 1].x)), + int((_ui.graphicsWidget->height() / 2.0) * (1 - verts[k - 1].y)), + int((_ui.graphicsWidget->width() / 2.0) * (1 + verts[ k].x)), + int((_ui.graphicsWidget->height() / 2.0) * (1 - verts[k].y))); + } + painter.drawLine(int((_ui.graphicsWidget->width() / 2.0) * (1 + verts[0].x)), + int((_ui.graphicsWidget->height() / 2.0) * (1 - verts[0].y)), + int((_ui.graphicsWidget->width() / 2.0) * (1 + verts[verts.size() - 1].x)), + int((_ui.graphicsWidget->height() / 2.0) * (1 - verts[verts.size() - 1].y))); + } + } + } + return QWidget::eventFilter(object, event); +} + } /* namespace NLQT */ \ No newline at end of file diff --git a/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.h b/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.h index 2fecb2160..c4d01fa9d 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.h +++ b/code/nel/tools/3d/object_viewer_qt/src/tail_particle_widget.h @@ -55,6 +55,8 @@ private Q_SLOTS: void setRibbonOrientation(int index); private: + bool eventFilter(QObject *object, QEvent *event); + CWorkspaceNode *_Node; NL3D::CPSTailParticle *_TailParticle;