mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-21 08:28:44 +00:00
merge from default
--HG-- branch : gsoc2011-kerozcak
This commit is contained in:
commit
424218b5ce
3 changed files with 164 additions and 39 deletions
|
@ -6,13 +6,13 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>361</width>
|
<width>206</width>
|
||||||
<height>555</height>
|
<height>555</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>200</width>
|
||||||
<height>83</height>
|
<height>83</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
@ -33,21 +33,21 @@
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>2</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tileTab">
|
<widget class="QWidget" name="tileTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Paint Tiles</string>
|
<string>Tiles</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="colorTab">
|
<widget class="QWidget" name="colorTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Paint Colors</string>
|
<string>Colors</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="displaceTab">
|
<widget class="QWidget" name="displaceTab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
<string>Paint Displacement</string>
|
<string>Displacement</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -1,9 +1,18 @@
|
||||||
#include "zone_painter_main_window.h"
|
#include "zone_painter_main_window.h"
|
||||||
#include "ui_zone_painter_main_window.h"
|
#include "ui_zone_painter_main_window.h"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QSignalMapper>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QColorDialog>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
#include "qnel_widget.h"
|
#include "qnel_widget.h"
|
||||||
#include "painter_dock_widget.h"
|
#include "painter_dock_widget.h"
|
||||||
#include <QtGui/QMenu>
|
|
||||||
|
#include "../core/icore.h"
|
||||||
|
#include "../core/imenu_manager.h"
|
||||||
|
#include "../core/core_constants.h"
|
||||||
|
|
||||||
ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) :
|
ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
|
@ -13,6 +22,9 @@ ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) :
|
||||||
m_nelWidget = new NLQT::QNLWidget(this);
|
m_nelWidget = new NLQT::QNLWidget(this);
|
||||||
setCentralWidget(m_nelWidget);
|
setCentralWidget(m_nelWidget);
|
||||||
|
|
||||||
|
// Load the settings.
|
||||||
|
loadConfig();
|
||||||
|
|
||||||
// Set up dock widget(s) and toolbar.
|
// Set up dock widget(s) and toolbar.
|
||||||
m_painterDockWidget = new PainterDockWidget(this);
|
m_painterDockWidget = new PainterDockWidget(this);
|
||||||
addDockWidget(Qt::RightDockWidgetArea, m_painterDockWidget);
|
addDockWidget(Qt::RightDockWidgetArea, m_painterDockWidget);
|
||||||
|
@ -24,34 +36,127 @@ ZonePainterMainWindow::ZonePainterMainWindow(QWidget *parent) :
|
||||||
ui->painterToolBar->addAction(_toolModeMenu->menuAction());
|
ui->painterToolBar->addAction(_toolModeMenu->menuAction());
|
||||||
//connect(_renderModeMenu->menuAction(), SIGNAL(triggered()), this, SLOT(setRenderMode()));
|
//connect(_renderModeMenu->menuAction(), SIGNAL(triggered()), this, SLOT(setRenderMode()));
|
||||||
|
|
||||||
//QSignalMapper *modeMapper = new QSignalMapper(this);
|
QSignalMapper *modeMapper = new QSignalMapper(this);
|
||||||
|
|
||||||
_toolPaintModeAction = _toolModeMenu->addAction(tr("Paint Mode"));
|
_toolPaintModeAction = _toolModeMenu->addAction(tr("Paint Mode"));
|
||||||
_toolPaintModeAction->setIcon(QIcon(":/painterTools/images/draw-brush.png"));
|
_toolPaintModeAction->setIcon(QIcon(":/painterTools/images/draw-brush.png"));
|
||||||
_toolPaintModeAction->setStatusTip(tr("Set paint mode"));
|
_toolPaintModeAction->setStatusTip(tr("Set paint mode"));
|
||||||
//connect(_pointRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
connect(_toolPaintModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
||||||
//modeMapper->setMapping(_pointRenderModeAction, 0);
|
modeMapper->setMapping(_toolPaintModeAction, 0);
|
||||||
|
|
||||||
_toolFillModeAction = _toolModeMenu->addAction(tr("Fill Mode"));
|
_toolFillModeAction = _toolModeMenu->addAction(tr("Fill Mode"));
|
||||||
_toolFillModeAction->setStatusTip(tr("Set fill mode"));
|
_toolFillModeAction->setStatusTip(tr("Set fill mode"));
|
||||||
_toolFillModeAction->setIcon(QIcon(":/painterTools/images/color-fill.png"));
|
_toolFillModeAction->setIcon(QIcon(":/painterTools/images/color-fill.png"));
|
||||||
//connect(_lineRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
connect(_toolFillModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
||||||
//modeMapper->setMapping(_lineRenderModeAction, 1);
|
modeMapper->setMapping(_toolFillModeAction, 1);
|
||||||
|
|
||||||
_toolSelectModeAction = _toolModeMenu->addAction(tr("Select mode"));
|
_toolSelectModeAction = _toolModeMenu->addAction(tr("Select mode"));
|
||||||
_toolSelectModeAction->setIcon(QIcon(":/painterTools/images/go-jump-4.png"));
|
_toolSelectModeAction->setIcon(QIcon(":/painterTools/images/go-jump-4.png"));
|
||||||
_toolSelectModeAction->setStatusTip(tr("Set select mode"));
|
_toolSelectModeAction->setStatusTip(tr("Set select mode"));
|
||||||
//connect(_fillRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
connect(_toolSelectModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
||||||
//modeMapper->setMapping(_fillRenderModeAction, 2);
|
modeMapper->setMapping(_toolSelectModeAction, 2);
|
||||||
|
|
||||||
_toolPickModeAction = _toolModeMenu->addAction(tr("Pick mode"));
|
_toolPickModeAction = _toolModeMenu->addAction(tr("Pick mode"));
|
||||||
_toolPickModeAction->setIcon(QIcon(":/painterTools/images/color-picker-black.png"));
|
_toolPickModeAction->setIcon(QIcon(":/painterTools/images/color-picker-black.png"));
|
||||||
_toolPickModeAction->setStatusTip(tr("Set color picking mode"));
|
_toolPickModeAction->setStatusTip(tr("Set color picking mode"));
|
||||||
//connect(_fillRenderModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
connect(_toolPickModeAction, SIGNAL(triggered()), modeMapper, SLOT(map()));
|
||||||
//modeMapper->setMapping(_fillRenderModeAction, 2);
|
modeMapper->setMapping(_toolPickModeAction, 2);
|
||||||
|
|
||||||
//connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(setRenderMode(int)));
|
connect(modeMapper, SIGNAL(mapped(int)), this, SLOT(setToolMode(int)));
|
||||||
|
|
||||||
|
m_statusBarTimer = new QTimer(this);
|
||||||
|
connect(m_statusBarTimer, SIGNAL(timeout()), this, SLOT(updateStatusBar()));
|
||||||
|
m_statusInfo = new QLabel(this);
|
||||||
|
m_statusInfo->hide();
|
||||||
|
|
||||||
|
// Set Background Color Toolbar
|
||||||
|
|
||||||
|
|
||||||
|
connect(ui->actionBackground_Dlg, SIGNAL(triggered()), this, SLOT(setBackgroundColor()));
|
||||||
|
|
||||||
|
|
||||||
|
Core::ICore::instance()->mainWindow()->statusBar()->addPermanentWidget(m_statusInfo);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::showEvent(QShowEvent *showEvent)
|
||||||
|
{
|
||||||
|
QMainWindow::showEvent(showEvent);
|
||||||
|
m_statusBarTimer->start(1000);
|
||||||
|
m_statusInfo->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::hideEvent(QHideEvent *hideEvent)
|
||||||
|
{
|
||||||
|
m_statusBarTimer->stop();
|
||||||
|
m_statusInfo->hide();
|
||||||
|
QMainWindow::hideEvent(hideEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::updateStatusBar()
|
||||||
|
{
|
||||||
|
m_statusInfo->setText(QString("Tool Mode: Paint Mode"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::setToolMode(int value)
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
//Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
//Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::setToolMode()
|
||||||
|
{
|
||||||
|
//switch (Modules::objView().getDriver()->getPolygonMode())
|
||||||
|
//{
|
||||||
|
//case NL3D::UDriver::Filled:
|
||||||
|
// Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Line);
|
||||||
|
// break;
|
||||||
|
//case NL3D::UDriver::Line:
|
||||||
|
// Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Point);
|
||||||
|
// break;
|
||||||
|
//case NL3D::UDriver::Point:
|
||||||
|
// Modules::objView().getDriver()->setPolygonMode (NL3D::UDriver::Filled);
|
||||||
|
// break;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::setBackgroundColor() {
|
||||||
|
QColor color = QColorDialog::getColor(QColor(m_nelWidget->backgroundColor().R,
|
||||||
|
m_nelWidget->backgroundColor().G,
|
||||||
|
m_nelWidget->backgroundColor().B));
|
||||||
|
if (color.isValid())
|
||||||
|
m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::loadConfig() {
|
||||||
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
settings->beginGroup("ZonePainter");
|
||||||
|
|
||||||
|
QColor color;
|
||||||
|
color = settings->value("BackgroundColor", QColor(80, 80, 80)).value<QColor>();
|
||||||
|
m_nelWidget->setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue(), color.alpha()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZonePainterMainWindow::saveConfig() {
|
||||||
|
QSettings *settings = Core::ICore::instance()->settings();
|
||||||
|
settings->beginGroup("ZonePainter" );
|
||||||
|
|
||||||
|
QColor color(m_nelWidget->backgroundColor().R, m_nelWidget->backgroundColor().G, m_nelWidget->backgroundColor().B, m_nelWidget->backgroundColor().A);
|
||||||
|
settings->setValue("BackgroundColor", color);
|
||||||
|
|
||||||
|
settings->endGroup();
|
||||||
|
settings->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
ZonePainterMainWindow::~ZonePainterMainWindow()
|
ZonePainterMainWindow::~ZonePainterMainWindow()
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
#define ZONE_PAINTER_MAIN_WINDOW_H
|
#define ZONE_PAINTER_MAIN_WINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
namespace NLQT {
|
namespace NLQT {
|
||||||
class QNLWidget;
|
class QNLWidget;
|
||||||
|
@ -21,16 +24,33 @@ public:
|
||||||
explicit ZonePainterMainWindow(QWidget *parent = 0);
|
explicit ZonePainterMainWindow(QWidget *parent = 0);
|
||||||
~ZonePainterMainWindow();
|
~ZonePainterMainWindow();
|
||||||
|
|
||||||
|
void loadConfig();
|
||||||
|
void saveConfig();
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void setToolMode(int value);
|
||||||
|
void setToolMode();
|
||||||
|
void updateStatusBar();
|
||||||
|
void setBackgroundColor();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void showEvent(QShowEvent *showEvent);
|
||||||
|
virtual void hideEvent(QHideEvent *hideEvent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ZonePainterMainWindow *ui;
|
Ui::ZonePainterMainWindow *ui;
|
||||||
NLQT::QNLWidget *m_nelWidget;
|
NLQT::QNLWidget *m_nelWidget;
|
||||||
PainterDockWidget *m_painterDockWidget;
|
PainterDockWidget *m_painterDockWidget;
|
||||||
|
QTimer *m_statusBarTimer;
|
||||||
|
QLabel *m_statusInfo;
|
||||||
|
|
||||||
QAction *_toolPaintModeAction;
|
QAction *_toolPaintModeAction;
|
||||||
QAction *_toolFillModeAction;
|
QAction *_toolFillModeAction;
|
||||||
QAction *_toolSelectModeAction;
|
QAction *_toolSelectModeAction;
|
||||||
QAction *_toolPickModeAction;
|
QAction *_toolPickModeAction;
|
||||||
QMenu *_toolModeMenu;
|
QMenu *_toolModeMenu;
|
||||||
|
|
||||||
|
//QAction *m_setBackColorAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ZONE_PAINTER_MAIN_WINDOW_H
|
#endif // ZONE_PAINTER_MAIN_WINDOW_H
|
||||||
|
|
Loading…
Reference in a new issue