Commit ccfa0c91 authored by Mike Kremer's avatar Mike Kremer

Added translucency rendering options to polyhedral mesh type plugin.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14392 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 53b0b03a
......@@ -64,12 +64,36 @@ void TypePolyhedralMeshPlugin::pluginsInitialized() {
emit registerKey(Qt::Key_F8, Qt::ShiftModifier, "Set scaling of cell shrinkage");
QMenu* menu = new QMenu("Polyhedral Mesh Options");
// scaling action in context menu
QAction* act_scale_cells = new QAction(tr("Scale cells (Shift-F8)"), this);
act_scale_cells->setStatusTip(tr("Scale cells (Shift-F8)"));
connect(act_scale_cells, SIGNAL( triggered() ), this, SLOT( slot_change_shrinkage() ));
emit addContextMenuItem(act_scale_cells, DATA_POLYHEDRAL_MESH, CONTEXTOBJECTMENU);
menu->addAction(act_scale_cells);
// Change rendering
render_switch_ = new QAction(tr("Render Boundary Only"), this);
render_switch_->setStatusTip(tr("Render Boundary Only"));
render_switch_->setCheckable(true);
render_switch_->setChecked(false);
connect(render_switch_, SIGNAL( triggered() ), this, SLOT( switchRendering() ));
menu->addAction(render_switch_);
translucency_action_ = new QAction(tr("Translucent"), this);
translucency_action_->setStatusTip(tr("Translucent"));
translucency_action_->setCheckable(true);
translucency_action_->setChecked(false);
connect(translucency_action_, SIGNAL( triggered() ), this, SLOT( switchTranslucency() ));
menu->addAction(translucency_action_);
translucency_factor_action_ = new QAction(tr("Set Translucency Factor"), this);
translucency_factor_action_->setStatusTip(tr("Set Translucency Factor"));
translucency_factor_action_->setCheckable(false);
connect(translucency_factor_action_, SIGNAL( triggered() ), this, SLOT( setTranslucencyFactor() ));
menu->addAction(translucency_factor_action_);
emit addContextMenuItem(menu->menuAction(), DATA_POLYHEDRAL_MESH, CONTEXTOBJECTMENU);
}
//----------------------------------------------------------------------------
......@@ -159,6 +183,8 @@ void TypePolyhedralMeshPlugin::slotObjectUpdated(int _identifier) {
slot_update_planes_in_scenegraph_node();
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::objectDeleted(int _identifier) {
PlaneObject* pobj;
......@@ -169,6 +195,80 @@ void TypePolyhedralMeshPlugin::objectDeleted(int _identifier) {
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::switchRendering() {
QVariant contextObject = render_switch_->data();
int objectId = contextObject.toInt();
if(objectId == -1)
return;
BaseObjectData* bod = 0;
if(!PluginFunctions::getObject(objectId, bod))
return;
PolyhedralMeshObject* polyMeshObject = dynamic_cast<PolyhedralMeshObject*>(bod);
if(polyMeshObject) {
polyMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked());
polyMeshObject->meshNode()->set_geometry_changed(true);
}
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::switchTranslucency() {
QVariant contextObject = translucency_action_->data();
int objectId = contextObject.toInt();
if(objectId == -1)
return;
BaseObjectData* bod = 0;
if(!PluginFunctions::getObject(objectId, bod))
return;
PolyhedralMeshObject* polyMeshObject = dynamic_cast<PolyhedralMeshObject*>(bod);
if(polyMeshObject) {
polyMeshObject->meshNode()->set_translucent(translucency_action_->isChecked());
polyMeshObject->meshNode()->set_geometry_changed(true);
}
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::setTranslucencyFactor() {
QVariant contextObject = translucency_factor_action_->data();
int objectId = contextObject.toInt();
if(objectId == -1)
return;
BaseObjectData* bod = 0;
if(!PluginFunctions::getObject(objectId, bod))
return;
PolyhedralMeshObject* polyMeshObject = dynamic_cast<PolyhedralMeshObject*>(bod);
if(polyMeshObject) {
bool ok;
float val = polyMeshObject->meshNode()->translucency_factor();
double factor = QInputDialog::getDouble(0, tr("Set translucency factor"), tr("Factor [0, 1]:"), val,
0.0, 1.0, 2, &ok);
polyMeshObject->meshNode()->set_translucency_factor((float)factor);
if(polyMeshObject->meshNode()->translucent()) {
emit updatedObject(objectId, UPDATE_GEOMETRY);
}
}
}
//----------------------------------------------------------------------------
void TypePolyhedralMeshPlugin::slot_update_planes_in_scenegraph_node(int _deletedObject) {
typedef ACG::SceneGraph::VolumeMeshNodeT<PolyhedralMesh>::Plane Plane;
......
......@@ -90,6 +90,12 @@ private slots:
void slot_update_planes_in_scenegraph_node(int _deletedObject = -1);
void switchRendering();
void switchTranslucency();
void setTranslucencyFactor();
public:
~TypePolyhedralMeshPlugin() {
......@@ -124,6 +130,12 @@ public slots:
private:
QString get_unique_name(PolyhedralMeshObject* _object);
QAction* render_switch_;
QAction* translucency_action_;
QAction* translucency_factor_action_;
};
#endif //TYPEPOLYHEDRALMESH_HH
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment