xoreos  0.0.5
modelwidget.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/error.h"
26 #include "src/common/ustring.h"
27 
30 
32 
34 
35 namespace Engines {
36 
37 namespace NWN {
38 
40  const Common::UString &model) : NWNWidgetWithCaption(gui, tag) {
41 
42  if (!(_model = loadModelGUI(model)))
43  throw Common::Exception("Can't load model \"%s\" for widget \"%s\"",
44  model.c_str(), tag.c_str());
45 
46  _model->setTag(tag);
47 }
48 
51 }
52 
54  if (isVisible())
55  return;
56 
57  if (!isInvisible())
58  _model->show();
59 
61 }
62 
64  if (!isVisible())
65  return;
66 
67  _model->hide();
69 }
70 
71 void ModelWidget::setPosition(float x, float y, float z) {
73 
74  getPosition(x, y, z);
75  _model->setPosition(x, y, z);
76 }
77 
78 float ModelWidget::getWidth() const {
79  return _model->getWidth();
80 }
81 
82 float ModelWidget::getHeight() const {
83  return _model->getHeight();
84 }
85 
87  Widget::setTag(tag);
88 
89  _model->setTag(tag);
90 }
91 
93  return _model->getNode(nodeName);
94 }
95 
96 } // End of namespace NWN
97 
98 } // End of namespace Engines
float getHeight() const
Get the height of the model&#39;s bounding box.
Definition: model.cpp:166
void setTag(const Common::UString &tag)
Set the widget&#39;s tag.
Definition: modelwidget.cpp:86
virtual void setTag(const Common::UString &tag)
Set the widget&#39;s tag.
Definition: widget.cpp:49
A class holding an UTF-8 string.
Definition: ustring.h:48
float getHeight() const
Get the widget&#39;s height.
Definition: modelwidget.cpp:82
float getWidth() const
Get the width of the model&#39;s bounding box.
Definition: model.cpp:162
void hide()
Hide the object.
Definition: model.cpp:116
virtual void getPosition(float &x, float &y, float &z) const
Get the widget&#39;s position.
Definition: widget.cpp:140
bool isVisible() const
Is the widget visible?
Definition: widget.cpp:59
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
void hide()
Hide the widget.
Definition: modelwidget.cpp:63
A GUI.
Definition: gui.h:43
bool isInvisible() const
Is the widget invisible (never visible)?
Definition: widget.cpp:67
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
A NWN model widget.
void freeModel(Graphics::Aurora::Model *&model)
Definition: model.cpp:82
void show()
Show the widget.
Definition: modelwidget.cpp:53
A node within a 3D model.
A 3D model of an object.
StackException Exception
Definition: error.h:59
Graphics::Aurora::Model * _model
Definition: modelwidget.h:64
void setPosition(float x, float y, float z)
Set the current position of the model.
Definition: model.cpp:250
Unicode string handling.
void show()
Show the object.
Definition: model.cpp:111
Graphics::Aurora::ModelNode * getNode(const Common::UString &nodeName) const
Definition: modelwidget.cpp:92
void setPosition(float x, float y, float z)
Set the widget&#39;s position.
Definition: modelwidget.cpp:71
void setTag(const Common::UString &tag)
Set the object&#39;s tag.
Definition: renderable.cpp:102
float getWidth() const
Get the widget&#39;s width.
Definition: modelwidget.cpp:78
Graphics::Aurora::Model * loadModelGUI(const Common::UString &resref)
Definition: model.cpp:65
A NWN widget with a text caption.
ModelNode * getNode(const Common::UString &node)
Get the specified node, from the current state.
Definition: model.cpp:379
ModelWidget(::Engines::GUI &gui, const Common::UString &tag, const Common::UString &model)
Definition: modelwidget.cpp:39
Generic Aurora engines model functions.