43 #include "TypeHexahedralMesh.hh" 48 #include <QInputDialog> 51 TypeHexahedralMeshPlugin::TypeHexahedralMeshPlugin() :
53 translucency_factor_action_(0)
57 bool TypeHexahedralMeshPlugin::registerType() {
59 addDataType(
"HexahedralMesh", tr(
"Hexahedral Volume Mesh"));
60 setTypeIcon(
"HexahedralMesh",
"PolyVolMeshType.png");
66 void TypeHexahedralMeshPlugin::pluginsInitialized() {
68 if(OpenFlipper::Options::nogui())
return;
70 emit
registerKey(Qt::Key_F8, Qt::ShiftModifier,
"Set scaling of Hex shrinkage");
72 QMenu* menu =
new QMenu(
"Hexahedral Mesh Options");
75 QAction* act_scale_cells =
new QAction(tr(
"Scale cells (Shift-F8)"),
this);
76 act_scale_cells->setStatusTip(tr(
"Scale cells (Shift-F8)"));
77 connect(act_scale_cells, SIGNAL( triggered() ),
this, SLOT( slot_change_shrinkage() ));
78 menu->addAction(act_scale_cells);
81 render_switch_ =
new QAction(tr(
"Render Boundary Only"),
this);
82 render_switch_->setStatusTip(tr(
"Render Boundary Only"));
83 render_switch_->setCheckable(
true);
84 render_switch_->setChecked(
false);
85 connect(render_switch_, SIGNAL( triggered() ),
this, SLOT( switchRendering() ));
86 menu->addAction(render_switch_);
88 translucency_factor_action_ =
new QAction(tr(
"Set Translucency Factor"),
this);
89 translucency_factor_action_->setStatusTip(tr(
"Set Translucency Factor"));
90 translucency_factor_action_->setCheckable(
false);
91 connect(translucency_factor_action_, SIGNAL( triggered() ),
this, SLOT( setTranslucencyFactor() ));
92 menu->addAction(translucency_factor_action_);
99 int TypeHexahedralMeshPlugin::addEmpty() {
105 object->target(
true);
110 object->target(
true);
114 object->target(
true);
117 QString
name = QString(tr(
"New Hexahedral Mesh %1.ovm").arg( object->
id() ));
121 object->setName(f.fileName());
128 const QColor color = OpenFlipper::Options::defaultColor();
129 const ACG::Vec4f default_color(color.redF(), color.greenF(), color.blueF(), color.alphaF());
130 object->materialNode()->set_color(default_color);
133 if(OpenFlipper::Options::gui()) {
134 object->meshNode()->set_scaling(0.8);
143 emit emptyObjectAdded(object->
id());
150 void TypeHexahedralMeshPlugin::slotKeyEvent(QKeyEvent* _event) {
152 switch (_event->key()) {
154 if (_event->modifiers() & Qt::ShiftModifier)
155 slot_change_shrinkage();
164 void TypeHexahedralMeshPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type) {
171 slot_update_planes_in_scenegraph_node();
176 void TypeHexahedralMeshPlugin::objectDeleted(
int _identifier) {
180 slot_update_planes_in_scenegraph_node(_identifier);
186 void TypeHexahedralMeshPlugin::slotUpdateContextMenu(
int _objectId) {
190 render_switch_->setChecked(hmobj->
meshNode()->boundary_only());
196 void TypeHexahedralMeshPlugin::slot_update_planes_in_scenegraph_node(
int _deletedObject) {
198 std::vector<Plane> planes;
204 if(o_it->id() == _deletedObject)
continue;
213 planes.push_back(
Plane(p, n, x, y));
221 for (
unsigned int i = 0; i < planes.size(); ++i) {
232 void TypeHexahedralMeshPlugin::switchRendering() {
234 QVariant contextObject = render_switch_->data();
235 int objectId = contextObject.toInt();
247 hexMeshObject->
meshNode()->set_boundary_only(render_switch_->isChecked());
248 hexMeshObject->
meshNode()->set_geometry_changed(
true);
254 void TypeHexahedralMeshPlugin::setTranslucencyFactor() {
256 QVariant contextObject = translucency_factor_action_->data();
257 int objectId = contextObject.toInt();
271 float val = hexMeshObject->
meshNode()->translucency_factor();
272 double factor = QInputDialog::getDouble(0, tr(
"Set translucency factor"), tr(
"Factor [0, 1]:"), val,
275 hexMeshObject->
meshNode()->set_translucency_factor((
float)factor);
281 void TypeHexahedralMeshPlugin::slot_change_shrinkage() {
288 double scale = QInputDialog::getDouble(0, tr(
"Set singularity scaling for hex shrinkage"), tr(
"Size * :"), val,
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
virtual void updateView()
Update current view in Main Application.
ACG::Vec3d yDirection()
local y direction (multiplied with height)
int objectCount()
Get the number of available objects.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
#define DATA_HEXAHEDRAL_MESH
QString getObjectinfo()
Get all Info for the Object as a string.
ACG::Vec3d xDirection()
local x direction (multiplied with width)
const QStringList ALL_OBJECTS
Iterable object range.
PlaneNode * planeNode(BaseObjectData *_object)
Get a PlaneNode from an object.
DLLEXPORT DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
ACG::Vec3d position()
get center position of the plane
QString name() const
return the name of the object. The name defaults to NONAME if unset.
int targetCount()
Get the number of target objects.
virtual void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse=false)
Register a key-combination for your plugin.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
decltype(std::declval< S >() *std::declval< S >()) sqrnorm() const
compute squared euclidean norm
HexahedralMeshObject * hexahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an HexahedralMeshObject if possible.
VolumeMeshObject< HexahedralMesh > HexahedralMeshObject
Typedef for a mesh object containing a polyhedral mesh.
DLLEXPORT OpenFlipperQSettings & OpenFlipperSettings()
QSettings object containing all program settings of OpenFlipper.
ACG::Vec3d normal()
get current normal
VectorT< double, 3 > Vec3d