Changed: #1193 eventFilter is used instead of the CGraphicsInfoWidget
This commit is contained in:
parent
50babb19ab
commit
9bc57cd810
15 changed files with 162 additions and 316 deletions
|
@ -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
|
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
|
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
|
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
|
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
|
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
|
auto_lod_dialog.h particle_texture_widget.h particle_texture_anim_widget.h
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3" rowspan="3">
|
<item row="0" column="3" rowspan="3">
|
||||||
<widget class="NLQT::CGraphicsInfoWidget" name="graphicsWidget" native="true">
|
<widget class="QWidget" name="graphicsWidget" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -110,14 +110,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>NLQT::CGraphicsInfoWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>graphics_info_widget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "basic_edit_widget.h"
|
#include "basic_edit_widget.h"
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include "nel/misc/matrix.h"
|
#include "nel/misc/matrix.h"
|
||||||
|
@ -143,6 +144,7 @@ CBasicEditWidget::CBasicEditWidget(QWidget *parent)
|
||||||
_Wrapper(NULL)
|
_Wrapper(NULL)
|
||||||
{
|
{
|
||||||
_ui.setupUi(this);
|
_ui.setupUi(this);
|
||||||
|
_ui.graphicsWidget->installEventFilter(this);
|
||||||
|
|
||||||
connect(_ui.psiSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateGraphics()));
|
connect(_ui.psiSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateGraphics()));
|
||||||
connect(_ui.thetaSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateGraphics()));
|
connect(_ui.thetaSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateGraphics()));
|
||||||
|
@ -199,4 +201,16 @@ void CBasicEditWidget::updateGraphics()
|
||||||
repaint();
|
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 */
|
} /* namespace NLQT */
|
|
@ -48,7 +48,8 @@ public:
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updateGraphics();
|
void updateGraphics();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
// wrapper to the datas
|
// wrapper to the datas
|
||||||
IPSWrapper<NL3D::CPlaneBasis> *_Wrapper ;
|
IPSWrapper<NL3D::CPlaneBasis> *_Wrapper ;
|
||||||
|
|
|
@ -71,7 +71,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2" rowspan="3">
|
<item row="1" column="2" rowspan="3">
|
||||||
<widget class="NLQT::CGraphicsInfoWidget" name="graphicsWidget" native="true">
|
<widget class="QWidget" name="graphicsWidget" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -128,14 +128,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>NLQT::CGraphicsInfoWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>graphics_info_widget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QColorDialog>
|
#include <QtGui/QColorDialog>
|
||||||
#include <QtGui/QColor>
|
#include <QtGui/QColor>
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
|
||||||
// Nel includes
|
// Nel includes
|
||||||
#include <nel/misc/rgba.h>
|
#include <nel/misc/rgba.h>
|
||||||
|
@ -37,6 +38,8 @@ CColorEditWidget::CColorEditWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
_ui.setupUi(this);
|
_ui.setupUi(this);
|
||||||
|
|
||||||
|
_ui.graphicsWidget->installEventFilter(this);
|
||||||
|
|
||||||
connect(_ui.rSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setRed(int)));
|
connect(_ui.rSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setRed(int)));
|
||||||
connect(_ui.gSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setGreen(int)));
|
connect(_ui.gSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setGreen(int)));
|
||||||
connect(_ui.bSpinBox, SIGNAL(valueChanged(int)), this, SLOT(setBlue(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;
|
_emit = true;
|
||||||
if (emit)
|
if (emit)
|
||||||
Q_EMIT colorChanged(color);
|
Q_EMIT colorChanged(color);
|
||||||
|
|
||||||
|
_ui.graphicsWidget->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CColorEditWidget::setColor(const QColor &color, bool emit)
|
void CColorEditWidget::setColor(const QColor &color, bool emit)
|
||||||
|
@ -75,28 +80,17 @@ void CColorEditWidget::setColor(const QColor &color, bool emit)
|
||||||
void CColorEditWidget::updateUi()
|
void CColorEditWidget::updateUi()
|
||||||
{
|
{
|
||||||
if (_Wrapper == NULL) return;
|
if (_Wrapper == NULL) return;
|
||||||
_ui.rSpinBox->setValue(_Wrapper->get().R);
|
setColor(_Wrapper->get());
|
||||||
_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()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CColorEditWidget::setRed(int r)
|
void CColorEditWidget::setRed(int r)
|
||||||
{
|
{
|
||||||
_ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(),
|
|
||||||
_ui.gSpinBox->value(),
|
|
||||||
_ui.bSpinBox->value(),
|
|
||||||
_ui.aSpinBox->value()));
|
|
||||||
|
|
||||||
if (_emit)
|
if (_emit)
|
||||||
Q_EMIT colorChanged(NLMISC::CRGBA(r, _ui.gSpinBox->value(),
|
Q_EMIT colorChanged(NLMISC::CRGBA(r, _ui.gSpinBox->value(),
|
||||||
_ui.bSpinBox->value(),
|
_ui.bSpinBox->value(),
|
||||||
_ui.aSpinBox->value()));
|
_ui.aSpinBox->value()));
|
||||||
|
|
||||||
|
_ui.graphicsWidget->repaint();
|
||||||
if (_Wrapper == NULL)
|
if (_Wrapper == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -112,17 +106,12 @@ void CColorEditWidget::setRed(int r)
|
||||||
|
|
||||||
void CColorEditWidget::setGreen(int g)
|
void CColorEditWidget::setGreen(int g)
|
||||||
{
|
{
|
||||||
_ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(),
|
|
||||||
_ui.gSpinBox->value(),
|
|
||||||
_ui.bSpinBox->value(),
|
|
||||||
_ui.aSpinBox->value()));
|
|
||||||
|
|
||||||
if (_emit)
|
if (_emit)
|
||||||
Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(),
|
Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(),
|
||||||
g,
|
g,
|
||||||
_ui.bSpinBox->value(),
|
_ui.bSpinBox->value(),
|
||||||
_ui.aSpinBox->value()));
|
_ui.aSpinBox->value()));
|
||||||
|
_ui.graphicsWidget->repaint();
|
||||||
if (_Wrapper == NULL) return;
|
if (_Wrapper == NULL) return;
|
||||||
|
|
||||||
NLMISC::CRGBA color = _Wrapper->get();
|
NLMISC::CRGBA color = _Wrapper->get();
|
||||||
|
@ -136,17 +125,12 @@ void CColorEditWidget::setGreen(int g)
|
||||||
|
|
||||||
void CColorEditWidget::setBlue(int b)
|
void CColorEditWidget::setBlue(int b)
|
||||||
{
|
{
|
||||||
_ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(),
|
|
||||||
_ui.gSpinBox->value(),
|
|
||||||
_ui.bSpinBox->value(),
|
|
||||||
_ui.aSpinBox->value()));
|
|
||||||
|
|
||||||
if (_emit)
|
if (_emit)
|
||||||
Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(),
|
Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(),
|
||||||
_ui.gSpinBox->value(),
|
_ui.gSpinBox->value(),
|
||||||
b,
|
b,
|
||||||
_ui.aSpinBox->value()));
|
_ui.aSpinBox->value()));
|
||||||
|
_ui.graphicsWidget->repaint();
|
||||||
if (_Wrapper == NULL) return;
|
if (_Wrapper == NULL) return;
|
||||||
|
|
||||||
NLMISC::CRGBA color = _Wrapper->get();
|
NLMISC::CRGBA color = _Wrapper->get();
|
||||||
|
@ -160,16 +144,12 @@ void CColorEditWidget::setBlue(int b)
|
||||||
|
|
||||||
void CColorEditWidget::setAlpha(int a)
|
void CColorEditWidget::setAlpha(int a)
|
||||||
{
|
{
|
||||||
_ui.graphicsWidget->setColor(QColor(_ui.rSpinBox->value(),
|
|
||||||
_ui.gSpinBox->value(),
|
|
||||||
_ui.bSpinBox->value(),
|
|
||||||
a));
|
|
||||||
|
|
||||||
if (_emit)
|
if (_emit)
|
||||||
Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(),
|
Q_EMIT colorChanged(NLMISC::CRGBA(_ui.rSpinBox->value(),
|
||||||
_ui.gSpinBox->value(),
|
_ui.gSpinBox->value(),
|
||||||
_ui.bSpinBox->value(),
|
_ui.bSpinBox->value(),
|
||||||
a));
|
a));
|
||||||
|
_ui.graphicsWidget->repaint();
|
||||||
|
|
||||||
if (_Wrapper == NULL) return;
|
if (_Wrapper == NULL) return;
|
||||||
|
|
||||||
|
@ -193,4 +173,22 @@ void CColorEditWidget::browseColor()
|
||||||
setColor(color);
|
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 */
|
} /* namespace NLQT */
|
|
@ -88,9 +88,11 @@ private Q_SLOTS:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
// wrapper to the datas
|
// wrapper to the datas
|
||||||
IPSWrapperRGBA *_Wrapper;
|
IPSWrapperRGBA *_Wrapper;
|
||||||
|
|
||||||
|
QColor _color;
|
||||||
bool _emit;
|
bool _emit;
|
||||||
|
|
||||||
Ui::CColorEditWidget _ui;
|
Ui::CColorEditWidget _ui;
|
||||||
|
|
|
@ -120,7 +120,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="NLQT::CGraphicsInfoWidget" name="xzWidget" native="true">
|
<widget class="QWidget" name="xzWidget" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -142,7 +142,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<widget class="NLQT::CGraphicsInfoWidget" name="yzWidget" native="true">
|
<widget class="QWidget" name="yzWidget" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
|
@ -178,14 +178,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>NLQT::CGraphicsInfoWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>graphics_info_widget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -22,22 +22,25 @@
|
||||||
|
|
||||||
// Qt includes
|
// Qt includes
|
||||||
#include <QtGui/QInputDialog>
|
#include <QtGui/QInputDialog>
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
#include <QtGui/QMouseEvent>
|
||||||
|
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include <nel/misc/vector.h>
|
#include <nel/misc/vector.h>
|
||||||
|
|
||||||
namespace NLQT
|
namespace NLQT
|
||||||
{
|
{
|
||||||
|
const int directionSize = 35;
|
||||||
|
|
||||||
CDirectionWidget::CDirectionWidget(QWidget *parent)
|
CDirectionWidget::CDirectionWidget(QWidget *parent)
|
||||||
: QWidget(parent), _globalName("")
|
: QWidget(parent), _globalName("")
|
||||||
{
|
{
|
||||||
_ui.setupUi(this);
|
_ui.setupUi(this);
|
||||||
|
|
||||||
_ui.xzWidget->setMode(Mode::Direction);
|
_ui.xzWidget->installEventFilter(this);
|
||||||
_ui.yzWidget->setMode(Mode::Direction);
|
_ui.yzWidget->installEventFilter(this);
|
||||||
_ui.xzWidget->setText("XZ");
|
_ui.xzWidget->setObjectName("XZ");
|
||||||
_ui.yzWidget->setText("YZ");
|
_ui.yzWidget->setObjectName("YZ");
|
||||||
_ui.globalPushButton->hide();
|
_ui.globalPushButton->hide();
|
||||||
|
|
||||||
connect(_ui.globalPushButton ,SIGNAL(clicked()), this, SLOT(setGlobalDirection()));
|
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.decVecJPushButton ,SIGNAL(clicked()), this, SLOT(decVecJ()));
|
||||||
connect(_ui.decVecKPushButton ,SIGNAL(clicked()), this, SLOT(decVecK()));
|
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
|
// Set default value +K
|
||||||
setValue(NLMISC::CVector::K);
|
setValue(NLMISC::CVector::K);
|
||||||
}
|
}
|
||||||
|
@ -68,8 +68,6 @@ void CDirectionWidget::enabledGlobalVariable(bool enabled)
|
||||||
void CDirectionWidget::setValue(const NLMISC::CVector &value, bool emit)
|
void CDirectionWidget::setValue(const NLMISC::CVector &value, bool emit)
|
||||||
{
|
{
|
||||||
_value = value;
|
_value = value;
|
||||||
_ui.xzWidget->setVector(_value.x, _value.z);
|
|
||||||
_ui.yzWidget->setVector(_value.y, _value.z);
|
|
||||||
_ui.xzWidget->repaint();
|
_ui.xzWidget->repaint();
|
||||||
_ui.yzWidget->repaint();
|
_ui.yzWidget->repaint();
|
||||||
|
|
||||||
|
@ -184,4 +182,47 @@ void CDirectionWidget::setNewVecYZ(float x, float y)
|
||||||
setValue(v);
|
setValue(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CDirectionWidget::eventFilter(QObject *object, QEvent *event)
|
||||||
|
{
|
||||||
|
QWidget *widget = qobject_cast<QWidget *>(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 */
|
} /* namespace NLQT */
|
|
@ -67,6 +67,8 @@ private Q_SLOTS:
|
||||||
void setNewVecYZ(float x, float y);
|
void setNewVecYZ(float x, float y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
NLMISC::CVector _value;
|
NLMISC::CVector _value;
|
||||||
QString _globalName;
|
QString _globalName;
|
||||||
|
|
||||||
|
|
|
@ -1,143 +0,0 @@
|
||||||
/*
|
|
||||||
Object Viewer Qt
|
|
||||||
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stdpch.h"
|
|
||||||
#include "graphics_info_widget.h"
|
|
||||||
|
|
||||||
// Qt includes
|
|
||||||
#include <QtGui/QPainter>
|
|
||||||
#include <QtGui/QColor>
|
|
||||||
#include <QtGui/QMouseEvent>
|
|
||||||
|
|
||||||
// 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<NLMISC::CVector> &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 */
|
|
|
@ -1,80 +0,0 @@
|
||||||
/*
|
|
||||||
Object Viewer Qt
|
|
||||||
Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
|
|
||||||
|
|
||||||
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 <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef GRAPHICS_INFO_WIDGET_H
|
|
||||||
#define GRAPHICS_INFO_WIDGET_H
|
|
||||||
|
|
||||||
// Qt includes
|
|
||||||
#include <QtGui/QWidget>
|
|
||||||
|
|
||||||
// STL includes
|
|
||||||
|
|
||||||
// NeL includes
|
|
||||||
#include <nel/misc/vector.h>
|
|
||||||
|
|
||||||
// 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<NLMISC::CVector> &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<NLMISC::CVector> _verts;
|
|
||||||
bool _braceMode;
|
|
||||||
|
|
||||||
}; /* class CGraphicsInfoWidget */
|
|
||||||
|
|
||||||
} /* namespace NLQT */
|
|
||||||
|
|
||||||
#endif // GRAPHICS_INFO_WIDGET_H
|
|
|
@ -43,7 +43,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" rowspan="3">
|
<item row="0" column="1" rowspan="3">
|
||||||
<widget class="NLQT::CGraphicsInfoWidget" name="pathWidget" native="true">
|
<widget class="QWidget" name="graphicsWidget" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>72</width>
|
<width>72</width>
|
||||||
|
@ -114,14 +114,6 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
|
||||||
<customwidget>
|
|
||||||
<class>NLQT::CGraphicsInfoWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header>graphics_info_widget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -23,17 +23,18 @@
|
||||||
// NeL includes
|
// NeL includes
|
||||||
#include "nel/3d/ps_particle.h"
|
#include "nel/3d/ps_particle.h"
|
||||||
|
|
||||||
// Projects includes
|
// Qt includes
|
||||||
|
#include <QtGui/QPainter>
|
||||||
|
|
||||||
namespace NLQT
|
namespace NLQT
|
||||||
{
|
{
|
||||||
|
|
||||||
CTailParticleWidget::CTailParticleWidget(QWidget *parent)
|
CTailParticleWidget::CTailParticleWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent), _Node(NULL), _TailParticle(NULL)
|
||||||
{
|
{
|
||||||
_ui.setupUi(this);
|
_ui.setupUi(this);
|
||||||
|
_ui.graphicsWidget->installEventFilter(this);
|
||||||
|
|
||||||
_ui.pathWidget->setMode(Mode::RibbonShape);
|
|
||||||
connect(_ui.tailFadingCheckBox, SIGNAL(toggled(bool)), this, SLOT(setTailFading(bool)));
|
connect(_ui.tailFadingCheckBox, SIGNAL(toggled(bool)), this, SLOT(setTailFading(bool)));
|
||||||
connect(_ui.ribbonOrientationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRibbonOrientation(int)));
|
connect(_ui.ribbonOrientationComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRibbonOrientation(int)));
|
||||||
connect(_ui.tailShapeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setTailShape(int)));
|
connect(_ui.tailShapeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setTailShape(int)));
|
||||||
|
@ -53,23 +54,19 @@ void CTailParticleWidget::setCurrentTailParticle(CWorkspaceNode *ownerNode, NL3D
|
||||||
|
|
||||||
if (!dynamic_cast<NL3D::CPSRibbon *>(_TailParticle))
|
if (!dynamic_cast<NL3D::CPSRibbon *>(_TailParticle))
|
||||||
{
|
{
|
||||||
_ui.pathWidget->hide();
|
_ui.graphicsWidget->hide();
|
||||||
_ui.ribbonOrientationComboBox->hide();
|
_ui.ribbonOrientationComboBox->hide();
|
||||||
_ui.tailShapeComboBox->hide();
|
_ui.tailShapeComboBox->hide();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_ui.pathWidget->show();
|
_ui.graphicsWidget->show();
|
||||||
_ui.ribbonOrientationComboBox->show();
|
_ui.ribbonOrientationComboBox->show();
|
||||||
_ui.tailShapeComboBox->show();
|
_ui.tailShapeComboBox->show();
|
||||||
NL3D::CPSRibbon *r = dynamic_cast<NL3D::CPSRibbon *>(_TailParticle);
|
NL3D::CPSRibbon *r = dynamic_cast<NL3D::CPSRibbon *>(_TailParticle);
|
||||||
_ui.ribbonOrientationComboBox->setCurrentIndex(r->getOrientation());
|
_ui.ribbonOrientationComboBox->setCurrentIndex(r->getOrientation());
|
||||||
|
|
||||||
// Update graphics widget
|
_ui.graphicsWidget->repaint();
|
||||||
std::vector<NLMISC::CVector> verts;
|
|
||||||
verts.resize(r->getNbVerticesInShape());
|
|
||||||
r->getShape(&verts[0]);
|
|
||||||
_ui.pathWidget->setRibbonShape(verts, r->getBraceMode());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,11 +111,7 @@ void CTailParticleWidget::setTailShape(int index)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update graphics widget
|
_ui.graphicsWidget->repaint();
|
||||||
std::vector<NLMISC::CVector> verts;
|
|
||||||
verts.resize(r->getNbVerticesInShape() );
|
|
||||||
r->getShape(&verts[0]);
|
|
||||||
_ui.pathWidget->setRibbonShape(verts, r->getBraceMode());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTailParticleWidget::setRibbonOrientation(int index)
|
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<NL3D::CPSRibbon *>(_TailParticle);
|
||||||
|
if (r)
|
||||||
|
{
|
||||||
|
std::vector<NLMISC::CVector> 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 */
|
} /* namespace NLQT */
|
|
@ -55,6 +55,8 @@ private Q_SLOTS:
|
||||||
void setRibbonOrientation(int index);
|
void setRibbonOrientation(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool eventFilter(QObject *object, QEvent *event);
|
||||||
|
|
||||||
CWorkspaceNode *_Node;
|
CWorkspaceNode *_Node;
|
||||||
|
|
||||||
NL3D::CPSTailParticle *_TailParticle;
|
NL3D::CPSTailParticle *_TailParticle;
|
||||||
|
|
Loading…
Reference in a new issue