Linux multi-monitor fullscreen support
[ryzomcore.git] / studio / src / plugins / object_viewer / graphics_viewport.cpp
blob0cec0be1046d94c3c6871b92e5265a371917807b
1 /*
2 Object Viewer Qt
3 Copyright (C) 2010 Dzmitry Kamiahin <dnk-88@tut.by>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "stdpch.h"
21 #include "graphics_viewport.h"
22 #include "../core/Nel3DWidget/nel3d_widget.h"
24 // STL includes
26 // Qt includes
27 #include <QtGui/QAction>
28 #include <QtGui/QResizeEvent>
29 #include <QtGui/QColorDialog>
30 #include <QtGui/QFileDialog>
32 // NeL includes
33 #include <nel/misc/rgba.h>
35 #include <nel/misc/event_server.h>
36 #include <nel/misc/events.h>
38 #include <nel/3d/u_driver.h>
39 #include <nel/3d/driver_user.h>
41 // Project includes
42 #include "modules.h"
44 using namespace std;
45 using namespace NL3D;
47 namespace NLQT
50 CGraphicsViewport::CGraphicsViewport(QObject *parent)
51 : QObject(parent)
53 w = new Nel3DWidget();
54 connect( w, SIGNAL( resize( int, int ) ), this, SLOT( onResize( int, int ) ) );
57 CGraphicsViewport::~CGraphicsViewport()
59 disconnect( w, SIGNAL( resize( int, int ) ), this, SLOT( onResize( int, int ) ) );
60 delete w;
61 w = NULL;
64 void CGraphicsViewport::init()
66 //H_AUTO2
67 nldebug("CGraphicsViewport::init");
69 w->init();
70 Modules::objView().init( w->getDriver() );
71 Modules::psEdit().init();
72 Modules::veget().init();
74 w->setMouseTracking(true);
75 w->setFocusPolicy(Qt::StrongFocus);
78 void CGraphicsViewport::release()
80 //H_AUTO2
81 nldebug("CGraphicsViewport::release");
83 Modules::veget().release();
84 Modules::psEdit().release();
85 Modules::objView().release();
89 QAction *CGraphicsViewport::createSaveScreenshotAction(QObject *parent)
91 QAction *action = new QAction(parent);
92 connect(action, SIGNAL(triggered()), this, SLOT(saveScreenshot()));
93 return action;
96 QAction *CGraphicsViewport::createSetBackgroundColor(QObject *parent)
98 QAction *action = new QAction(parent);
99 connect(action, SIGNAL(triggered()), this, SLOT(setBackgroundColor()));
100 return action;
103 QWidget* CGraphicsViewport::widget()
105 return w;
108 void CGraphicsViewport::saveScreenshot()
110 Modules::objView().saveScreenshot("screenshot", false, true, false);
113 void CGraphicsViewport::setBackgroundColor()
115 QColor color = QColorDialog::getColor(QColor(Modules::objView().getBackgroundColor().R,
116 Modules::objView().getBackgroundColor().G,
117 Modules::objView().getBackgroundColor().B));
118 if (color.isValid())
119 Modules::objView().setBackgroundColor(NLMISC::CRGBA(color.red(), color.green(), color.blue()));
122 void CGraphicsViewport::onResize( int width, int height )
124 if (Modules::objView().getDriver())
125 Modules::objView().setSizeViewport( width, height );
128 } /* namespace NLQT */