42 #include "TypeTetrahedralMesh.hh" 47 #include <QInputDialog> 50 TypeTetrahedralMeshPlugin::TypeTetrahedralMeshPlugin() :
52 translucency_factor_action_(0)
56 bool TypeTetrahedralMeshPlugin::registerType() {
58 addDataType(
"TetrahedralMesh", tr(
"Tetrahedral Volume Mesh"));
59 setTypeIcon(
"TetrahedralMesh",
"PolyVolMeshType.png");
65 void TypeTetrahedralMeshPlugin::pluginsInitialized() {
67 if(OpenFlipper::Options::nogui())
return;
69 emit
registerKey(Qt::Key_F8, Qt::ShiftModifier,
"Set scaling of Tet shrinkage");
71 QMenu* menu =
new QMenu(
"Tetrahedral Mesh Options");
74 QAction* act_scale_cells =
new QAction(tr(
"Scale cells (Shift-F8)"),
this);
75 act_scale_cells->setStatusTip(tr(
"Scale cells (Shift-F8)"));
76 connect(act_scale_cells, SIGNAL( triggered() ),
this, SLOT( slot_change_shrinkage() ));
77 menu->addAction(act_scale_cells);
80 render_switch_ =
new QAction(tr(
"Render Boundary Only"),
this);
81 render_switch_->setStatusTip(tr(
"Render Boundary Only"));
82 render_switch_->setCheckable(
true);
83 render_switch_->setChecked(
false);
84 connect(render_switch_, SIGNAL( triggered() ),
this, SLOT( switchRendering() ));
85 menu->addAction(render_switch_);
87 translucency_factor_action_ =
new QAction(tr(
"Set Translucency Factor"),
this);
88 translucency_factor_action_->setStatusTip(tr(
"Set Translucency Factor"));
89 translucency_factor_action_->setCheckable(
false);
90 connect(translucency_factor_action_, SIGNAL( triggered() ),
this, SLOT( setTranslucencyFactor() ));
91 menu->addAction(translucency_factor_action_);
98 int TypeTetrahedralMeshPlugin::addEmpty() {
104 object->target(
true);
107 object->target(
true);
109 QString
name = QString(tr(
"New Tetrahedral Mesh %1.ovm").arg( object->
id() ));
113 object->setName(f.fileName());
120 const QColor color = OpenFlipper::Options::defaultColor();
121 const ACG::Vec4f default_color(color.redF(), color.greenF(), color.blueF(), color.alphaF());
122 object->materialNode()->set_color(default_color);
125 if(OpenFlipper::Options::gui()) {
126 object->meshNode()->set_scaling(0.8);
135 emit emptyObjectAdded(object->
id());
142 void TypeTetrahedralMeshPlugin::slotKeyEvent(QKeyEvent* _event) {
144 switch (_event->key()) {
146 if (_event->modifiers() & Qt::ShiftModifier)
147 slot_change_shrinkage();
156 void TypeTetrahedralMeshPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type) {
163 slot_update_planes_in_scenegraph_node();
168 void TypeTetrahedralMeshPlugin::objectDeleted(
int _identifier) {
172 slot_update_planes_in_scenegraph_node(_identifier);
178 void TypeTetrahedralMeshPlugin::slotUpdateContextMenu(
int _objectId) {
182 render_switch_->setChecked(hmobj->
meshNode()->boundary_only());
188 void TypeTetrahedralMeshPlugin::slot_update_planes_in_scenegraph_node(
int _deletedObject) {
190 std::vector<Plane> planes;
196 if(o_it->id() == _deletedObject)
continue;
205 planes.push_back(
Plane(p, n, x, y));
213 for (
unsigned int i = 0; i < planes.size(); ++i) {
224 void TypeTetrahedralMeshPlugin::switchRendering() {
226 QVariant contextObject = render_switch_->data();
227 int objectId = contextObject.toInt();
239 tetMeshObject->
meshNode()->set_boundary_only(render_switch_->isChecked());
240 tetMeshObject->
meshNode()->set_geometry_changed(
true);
246 void TypeTetrahedralMeshPlugin::setTranslucencyFactor() {
248 QVariant contextObject = translucency_factor_action_->data();
249 int objectId = contextObject.toInt();
264 float val = tetMeshObject->
meshNode()->translucency_factor();
265 double factor = QInputDialog::getDouble(0, tr(
"Set translucency factor"), tr(
"Factor [0, 1]:"), val,
268 tetMeshObject->
meshNode()->set_translucency_factor((
float)factor);
274 void TypeTetrahedralMeshPlugin::slot_change_shrinkage() {
281 double scale = QInputDialog::getDouble(0, tr(
"Set singularity scaling for tet shrinkage"), tr(
"Size * :"), val,
ACG::SceneGraph::VolumeMeshNodeT< MeshT > * meshNode()
Get the Scenegraph Mesh Node.
ACG::Vec3d yDirection()
local y direction (multiplied with height)
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
QString name()
Return a name for the plugin.
decltype(std::declval< S >() *std::declval< S >()) sqrnorm() const
compute squared euclidean norm
VolumeMeshObject< TetrahedralMesh > TetrahedralMeshObject
Typedef for a mesh object containing a polyhedral mesh.
virtual void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse=false)
Register a key-combination for your plugin.
QString getObjectinfo()
Get all Info for the Object as a string.
TetrahedralMeshObject * tetrahedralMeshObject(BaseObjectData *_object)
Cast an BaseObject to an TetrahedralMeshObject if possible.
const QStringList ALL_OBJECTS
Iterable object range.
#define DATA_TETRAHEDRAL_MESH
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
VectorT< double, 3 > Vec3d
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
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.
ACG::Vec3d position()
get center position of the plane
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
virtual void updateView()
Update current view in Main Application.
ACG::Vec3d normal()
get current normal
int objectCount()
Get the number of available objects.
int targetCount()
Get the number of target objects.
The Menu will be shown when an object was picked.
ACG::Vec3d xDirection()
local x direction (multiplied with width)