Commit ea201944 authored by Jan Möbius's avatar Jan Möbius

Added context menu options to resize selection and feature linewidth.

closes OpenFlipper-Free#172
parent 07d9a2e3
......@@ -97,6 +97,16 @@ PYBIND11_EMBEDDED_MODULE(ViewControl, m) {
py::arg(QCoreApplication::translate("PythonDocViewControl","ID of the mesh object").toLatin1().data()),
py::arg(QCoreApplication::translate("PythonDocViewControl","Visible or not?").toLatin1().data()) );
view.def("setSelectionLineWidth", &ViewControlPlugin::setSelectionLineWidth,
QCoreApplication::translate("PythonDocViewControl","For meshes set the line width of selections.").toLatin1().data(),
py::arg(QCoreApplication::translate("PythonDocViewControl","ID of the mesh object").toLatin1().data()),
py::arg(QCoreApplication::translate("PythonDocViewControl","Line width to set").toLatin1().data()) );
view.def("setFeatureLineWidth", &ViewControlPlugin::setFeatureLineWidth,
QCoreApplication::translate("PythonDocViewControl","For meshes set the line width of features.").toLatin1().data(),
py::arg(QCoreApplication::translate("PythonDocViewControl","ID of the mesh object").toLatin1().data()),
py::arg(QCoreApplication::translate("PythonDocViewControl","Line width to set").toLatin1().data()) );
// /** Disable the given shader for a given object and draw mode.
// * @param _objectId ID of the object for which to disable the shader
......
......@@ -49,12 +49,15 @@
#include <ACG/Scenegraph/CoordsysNode.hh>
#include <QWidgetAction>
#define SHOW_SELECTION "Selections"
#define SHOW_AREAS "Modeling Areas"
#define SHOW_AREA "Modeling Area"
#define SHOW_HANDLE "Handle Area"
#define SHOW_FEATURES "Feature Selection"
#include <QInputDialog>
#define SHOW_SELECTION "Show/Hide Selections"
#define SHOW_AREAS "Show/Hide All Modeling Areas"
#define SHOW_AREA "Show/Hide Modeling Area"
#define SHOW_HANDLE "Show/Hide Handle Area"
#define SHOW_FEATURES "Show/Hide Feature Selection"
#define SIZE_SELECTION "Set Selection Width"
#define SIZE_FEATURES "Set Feature Width"
#define USEGLOBALDRAWMODE "Use Global DrawMode"
#define SETSHADERS "Set Shader"
......@@ -300,6 +303,40 @@ void ViewControlPlugin::contextMenuTriggered(QAction* _action){
emit updateView();
}
if ( _action->text() == SIZE_SELECTION) {
QVariant contextObject = _action->data();
int objectId = contextObject.toInt();
if ( objectId == -1)
return;
BaseObjectData* object = 0;
if ( ! PluginFunctions::getObject(objectId,object) )
return;
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
bool ok = true;
double d = QInputDialog::getDouble(0, tr("Line width for features"),
tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
Qt::WindowFlags(), 1);
setSelectionLineWidth(objectId,d);
}
if ( object->dataType( DATA_POLY_MESH ) ) {
bool ok = true;
double d = QInputDialog::getDouble(0, tr("Line width for features"),
tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
Qt::WindowFlags(), 1);
setSelectionLineWidth(objectId,d);
}
emit updateView();
}
if ( _action->text() == SHOW_AREAS) {
QVariant contextObject = _action->data();
......@@ -367,6 +404,42 @@ void ViewControlPlugin::contextMenuTriggered(QAction* _action){
}
if ( _action->text() == SIZE_FEATURES) {
QVariant contextObject = _action->data();
int objectId = contextObject.toInt();
if ( objectId == -1)
return;
BaseObjectData* object = 0;
if ( ! PluginFunctions::getObject(objectId,object) )
return;
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
bool ok = true;
double d = QInputDialog::getDouble(0, tr("Line width for features"),
tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
Qt::WindowFlags(), 1);
setFeatureLineWidth(objectId,d);
}
if ( object->dataType( DATA_POLY_MESH ) ) {
bool ok = true;
double d = QInputDialog::getDouble(0, tr("Line width for features"),
tr("Size:"), 2.0, 1.0, 50.0, 2, &ok,
Qt::WindowFlags(), 1);
setFeatureLineWidth(objectId,d);
}
emit updateView();
}
if ( _action->text() == SETSHADERS ) {
if ( shaderWidget_ == 0 ) {
shaderWidget_ = new ShaderWidget(0);
......@@ -471,6 +544,54 @@ void ViewControlPlugin::showModelingAreas( int _id , bool _state ) {
showAreas(StatusBits(HANDLEAREA | AREA) , _id, _state );
}
void ViewControlPlugin::setSelectionLineWidth( int _id , double _width ) {
if ( _id == -1)
return;
BaseObjectData* object = 0;
if ( ! PluginFunctions::getObject(_id,object) )
return;
//statusNode()
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
if ( triMeshObject )
triMeshObject->statusNode()->material().lineWidth(_width );
}
if ( object->dataType( DATA_POLY_MESH ) ) {
PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
if ( polyMeshObject )
polyMeshObject->statusNode()->material().lineWidth(_width );
}
}
void ViewControlPlugin::setFeatureLineWidth( int _id , double _width ) {
if ( _id == -1)
return;
BaseObjectData* object = 0;
if ( ! PluginFunctions::getObject(_id,object) )
return;
//statusNode()
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
if ( triMeshObject )
triMeshObject->featureNode()->material().lineWidth(_width );
}
if ( object->dataType( DATA_POLY_MESH ) ) {
PolyMeshObject* polyMeshObject = PluginFunctions::polyMeshObject( object );
if ( polyMeshObject )
polyMeshObject->featureNode()->material().lineWidth(_width );
}
}
void ViewControlPlugin::showSelection( int _id , bool _state ) {
......@@ -558,7 +679,7 @@ void ViewControlPlugin::slotUpdateContextMenu( int _objectId ){
act = viewControlMenu_->addAction( SHOW_HANDLE );
act->setCheckable(true);
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"handleSelection.png"));
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_handleSelection.png"));
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
......@@ -578,7 +699,7 @@ void ViewControlPlugin::slotUpdateContextMenu( int _objectId ){
act = viewControlMenu_->addAction( SHOW_AREA );
act->setCheckable(true);
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"modelingSelection.png"));
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_modelingSelection.png"));
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
......@@ -593,14 +714,14 @@ void ViewControlPlugin::slotUpdateContextMenu( int _objectId ){
}
// ============================================
// Action for features
// Actions for feature visibility
// ============================================
act = viewControlMenu_->addAction( SHOW_FEATURES );
act->setCheckable(true);
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"featureSelections.png"));
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_featureSelections.png"));
if ( object->dataType( DATA_TRIANGLE_MESH ) ) {
TriMeshObject* triMeshObject = PluginFunctions::triMeshObject( object );
......@@ -614,6 +735,23 @@ void ViewControlPlugin::slotUpdateContextMenu( int _objectId ){
act->setChecked( polyMeshObject->featuresVisible() );
}
// ============================================
// Action for features size
// ============================================
act = viewControlMenu_->addAction( SIZE_FEATURES );
act->setCheckable(true);
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_featureSize.png"));
// ============================================
// Action for selection size
// ============================================
act = viewControlMenu_->addAction( SIZE_SELECTION );
act->setCheckable(true);
act->setIcon(QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+"viewcontrol_selectionSize.png"));
}
......
......@@ -229,6 +229,12 @@ class ViewControlPlugin : public QObject, BaseInterface , PickingInterface, Logg
/// Allows to enable/disable visualization of the objects modeling area for meshes
void showModelingAreas( int _id , bool _state );
/// Set the line width of the selections
void setSelectionLineWidth( int _id , double _width );
/// Set the line width of the features
void setFeatureLineWidth( int _id , double _width );
/** Disable the given shader for a given object and draw mode.
* @param _objectId ID of the object for which to disable the shader
* @param _drawMode _drawMode for which the shader is disabled
......
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