50 #include "TypeHexahedralMesh.hh"
54 TypeHexahedralMeshPlugin::TypeHexahedralMeshPlugin() :
56 translucency_factor_action_(0)
60 bool TypeHexahedralMeshPlugin::registerType() {
62 addDataType(
"HexahedralMesh", tr(
"Hexahedral Volume Mesh"));
63 setTypeIcon(
"HexahedralMesh",
"PolyVolMeshType.png");
69 void TypeHexahedralMeshPlugin::pluginsInitialized() {
71 if(OpenFlipper::Options::nogui())
return;
73 emit
registerKey(Qt::Key_F8, Qt::ShiftModifier,
"Set scaling of Hex shrinkage");
75 QMenu* menu =
new QMenu(
"Hexahedral Mesh Options");
78 QAction* act_scale_cells =
new QAction(tr(
"Scale cells (Shift-F8)"),
this);
79 act_scale_cells->setStatusTip(tr(
"Scale cells (Shift-F8)"));
80 connect(act_scale_cells, SIGNAL( triggered() ),
this, SLOT( slot_change_shrinkage() ));
81 menu->addAction(act_scale_cells);
84 render_switch_ =
new QAction(tr(
"Render Boundary Only"),
this);
85 render_switch_->setStatusTip(tr(
"Render Boundary Only"));
86 render_switch_->setCheckable(
true);
87 render_switch_->setChecked(
false);
88 connect(render_switch_, SIGNAL( triggered() ),
this, SLOT( switchRendering() ));
89 menu->addAction(render_switch_);
91 translucency_factor_action_ =
new QAction(tr(
"Set Translucency Factor"),
this);
92 translucency_factor_action_->setStatusTip(tr(
"Set Translucency Factor"));
93 translucency_factor_action_->setCheckable(
false);
94 connect(translucency_factor_action_, SIGNAL( triggered() ),
this, SLOT( setTranslucencyFactor() ));
95 menu->addAction(translucency_factor_action_);
102 int TypeHexahedralMeshPlugin::addEmpty() {
108 object->target(
true);
113 object->target(
true);
117 object->target(
true);
120 QString
name = QString(tr(
"New Hexahedral Mesh %1.ovm").arg( object->
id() ));
124 object->setName(f.fileName());
131 const QColor color = OpenFlipper::Options::defaultColor();
132 const ACG::Vec4f default_color(color.redF(), color.greenF(), color.blueF(), color.alphaF());
133 object->materialNode()->set_color(default_color);
136 if(OpenFlipper::Options::gui()) {
137 object->meshNode()->set_scaling(0.8);
146 emit emptyObjectAdded(object->
id());
153 void TypeHexahedralMeshPlugin::slotKeyEvent(QKeyEvent* _event) {
155 switch (_event->key()) {
157 if (_event->modifiers() & Qt::ShiftModifier)
158 slot_change_shrinkage();
167 void TypeHexahedralMeshPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type) {
174 slot_update_planes_in_scenegraph_node();
179 void TypeHexahedralMeshPlugin::objectDeleted(
int _identifier) {
183 slot_update_planes_in_scenegraph_node(_identifier);
189 void TypeHexahedralMeshPlugin::slotUpdateContextMenu(
int _objectId) {
193 render_switch_->setChecked(hmobj->
meshNode()->boundary_only());
199 void TypeHexahedralMeshPlugin::slot_update_planes_in_scenegraph_node(
int _deletedObject) {
202 std::vector<Plane> planes;
208 if(o_it->id() == _deletedObject)
continue;
217 planes.push_back(Plane(p, n, x, y));
225 for (
unsigned int i = 0; i < planes.size(); ++i) {
236 void TypeHexahedralMeshPlugin::switchRendering() {
238 QVariant contextObject = render_switch_->data();
239 int objectId = contextObject.toInt();
251 hexMeshObject->
meshNode()->set_boundary_only(render_switch_->isChecked());
252 hexMeshObject->
meshNode()->set_geometry_changed(
true);
258 void TypeHexahedralMeshPlugin::setTranslucencyFactor() {
260 QVariant contextObject = translucency_factor_action_->data();
261 int objectId = contextObject.toInt();
275 float val = hexMeshObject->
meshNode()->translucency_factor();
276 double factor = QInputDialog::getDouble(0, tr(
"Set translucency factor"), tr(
"Factor [0, 1]:"), val,
279 hexMeshObject->
meshNode()->set_translucency_factor((
float)factor);
285 void TypeHexahedralMeshPlugin::slot_change_shrinkage() {
292 double scale = QInputDialog::getDouble(0, tr(
"Set singularity scaling for hex shrinkage"), tr(
"Size * :"), val,
301 #if QT_VERSION < 0x050000
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
ACG::Vec3d position()
get center position of the plane
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
const QStringList ALL_OBJECTS
Iterable object range.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
int targetCount()
Get the number of target objects.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
virtual void updateView()
Update current view in Main Application.
bool getObject(int _identifier, BSplineCurveObject *&_object)
DLLEXPORT DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
VectorT< double, 3 > Vec3d
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
QString getObjectinfo()
Get all Info for the Object as a string.
VolumeMeshObject< HexahedralMesh > HexahedralMeshObject
Typedef for a mesh object containing a polyhedral mesh.
ACG::Vec3d xDirection()
local x direction (multiplied with width)
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
QString name()
Return a name for the plugin.
PlaneNode * planeNode(BaseObjectData *_object)
Get a PlaneNode from an object.
virtual void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse=false)
Register a key-combination for your plugin.
ACG::Vec3d normal()
get current normal
The Menu will be shown when an object was picked.
int objectCount()
Get the number of available objects.
#define DATA_HEXAHEDRAL_MESH
ACG::Vec3d yDirection()
local y direction (multiplied with height)