50 #include "SelectionBasePlugin.hh"
55 #define TOGGLE_IMG "selection_toggle.png"
56 #define LASSO_IMG "selection_lasso.png"
57 #define VOLUME_LASSO_IMG "selection_lasso2.png"
58 #define SURFACE_LASSO_IMG "surface-lasso.png"
59 #define SPHERE_IMG "selection_paintSphere.png"
60 #define BOUNDARY_IMG "selection_boundary.png"
61 #define FLOODFILL_IMG "selection_floodFill.png"
62 #define COMPONENTS_IMG "selection_connected.png"
65 #define TOGGLE_DESC "Toggle Selection"
66 #define LASSO_DESC "Lasso Selection"
67 #define VOLUME_LASSO_DESC "Volume Lasso Selection"
68 #define SURFACE_LASSO_DESC "Surface Lasso Selection"
69 #define SPHERE_DESC "Sphere Selection"
70 #define BOUNDARY_DESC "Boundary Selection"
71 #define FLOODFILL_DESC "Floodfill Selection"
72 #define COMPONENTS_DESC "Selected Components Selection"
75 #define SB_TOGGLE "sb_toggle"
76 #define SB_LASSO "sb_lasso"
77 #define SB_VOLUME_LASSO "sb_volumelasso"
78 #define SB_SURFACE_LASSO "sb_surfacelasso"
79 #define SB_SPHERE "sb_sphere"
80 #define SB_BOUNDARY "sb_closestboundary"
81 #define SB_FLOODFILL "sb_floodfill"
82 #define SB_COMPONENTS "sb_components"
85 #define NO_SELECTION_PICKING "No_Selection_Picking"
86 #define NO_SELECTION_MODE "No_Selection_Mode"
88 #define SELECTION_PICKING "SelectionBasePicking"
94 primitivesBarGroup_(0),
96 selectionModesGroup_(0),
97 toggleSelectionAction_(0),
98 lassoSelectionAction_(0),
99 volumeLassoSelectionAction_(0),
100 surfaceLassoSelectionAction_(0),
101 sphereSelectionAction_(0),
102 boundarySelectionAction_(0),
103 floodFillSelectionAction_(0),
104 componentsSelectionAction_(0),
105 nextFreePrimitiveType_(1u),
109 lassoSelection_(false),
111 availableObjectTypes_(0u)
115 currentPickMode_ = NO_SELECTION_PICKING;
116 lastPickMode_ = NO_SELECTION_PICKING;
117 currentSelectionMode_ = NO_SELECTION_MODE;
119 currentPrimitiveType_ = 0u;
122 deselection_ =
false;
124 sphere_radius_ = 0.0;
129 void SelectionBasePlugin::initializePlugin() {
132 if (OpenFlipper::Options::nogui())
137 QSize size(300, 300);
141 connect(tool_->loadSelection, SIGNAL(clicked()),
this, SLOT(slotLoadSelectionButton()));
142 connect(tool_->saveSelection, SIGNAL(clicked()),
this, SLOT(slotSaveSelectionButton()));
145 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"selection_base.png");
146 emit addToolbox(
"Selections", tool_, toolIcon_ );
149 toolBar_ =
new QToolBar(tr(
"Selection Base"));
150 emit addToolbar(toolBar_);
152 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
153 QAction* selectionEnvironmentButton =
new QAction(QIcon(iconPath +
"selection_base.png"),
"Selections", toolBar_);
154 toolBar_->addAction(selectionEnvironmentButton);
157 connect(selectionEnvironmentButton, SIGNAL(triggered(
bool)),
this, SLOT(slotSelectionEnvironmentRequested(
bool)));
160 emit registerKey(Qt::Key_Control, Qt::NoModifier, tr(
"Deselection"),
true);
161 emit registerKey(Qt::Key_Control, Qt::ControlModifier, tr(
"Deselection"),
true);
163 emit registerKey(Qt::Key_Shift, Qt::NoModifier, tr(
"Source/Target Selection"),
true);
164 emit registerKey(Qt::Key_Shift, Qt::ShiftModifier, tr(
"Source/Target Selection"),
true);
167 emit addPickMode(SELECTION_PICKING);
169 emit setPickModeMouseTracking(SELECTION_PICKING,
true);
172 tool_->typeTabWidget->setMovable(
true);
175 pickModeToolBar_ =
new QToolBar(
"Selection Picking Toolbar");
176 pickModeToolBar_->setObjectName(
"Selection_Picking_Toolbar");
179 primitivesBarGroup_ =
new QActionGroup(pickModeToolBar_);
180 primitivesBarGroup_->setExclusive(
true);
184 selectionModesGroup_ =
new QActionGroup(pickModeToolBar_);
185 selectionModesGroup_->setExclusive(
true);
186 toggleSelectionAction_ =
new HandleAction(QIcon(iconPath + TOGGLE_IMG), TOGGLE_DESC, selectionModesGroup_);
187 toggleSelectionAction_->setCheckable(
true);
189 connect(toggleSelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
190 lassoSelectionAction_ =
new HandleAction(QIcon(iconPath + LASSO_IMG), LASSO_DESC, selectionModesGroup_);
191 lassoSelectionAction_->setCheckable(
true);
193 connect(lassoSelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
194 volumeLassoSelectionAction_ =
new HandleAction(QIcon(iconPath + VOLUME_LASSO_IMG), VOLUME_LASSO_DESC, selectionModesGroup_);
195 volumeLassoSelectionAction_->setCheckable(
true);
197 connect(volumeLassoSelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
198 surfaceLassoSelectionAction_ =
new HandleAction(QIcon(iconPath + SURFACE_LASSO_IMG), SURFACE_LASSO_DESC, selectionModesGroup_);
199 surfaceLassoSelectionAction_->setCheckable(
true);
201 connect(surfaceLassoSelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
202 sphereSelectionAction_ =
new HandleAction(QIcon(iconPath + SPHERE_IMG), SPHERE_DESC, selectionModesGroup_);
203 sphereSelectionAction_->setCheckable(
true);
205 connect(sphereSelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
206 boundarySelectionAction_ =
new HandleAction(QIcon(iconPath + BOUNDARY_IMG), BOUNDARY_DESC, selectionModesGroup_);
207 boundarySelectionAction_->setCheckable(
true);
209 connect(boundarySelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
210 floodFillSelectionAction_ =
new HandleAction(QIcon(iconPath + FLOODFILL_IMG), FLOODFILL_DESC, selectionModesGroup_);
211 floodFillSelectionAction_->setCheckable(
true);
213 connect(floodFillSelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
214 componentsSelectionAction_ =
new HandleAction(QIcon(iconPath + COMPONENTS_IMG), COMPONENTS_DESC, selectionModesGroup_);
215 componentsSelectionAction_->setCheckable(
true);
217 connect(componentsSelectionAction_, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
219 pickModeToolBar_->clear();
220 pickModeToolBar_->addActions(primitivesBarGroup_->actions());
221 pickModeToolBar_->addSeparator();
222 pickModeToolBar_->addActions(selectionModesGroup_->actions());
224 emit setPickModeToolbar(SELECTION_PICKING, pickModeToolBar_);
229 void SelectionBasePlugin::pluginsInitialized() {
236 std::string nodeName = std::string( tr(
"Selection Base Plugin: Selection Sphere Material").toUtf8() );
249 nodeName = std::string( tr(
"Selection Base Plugin: Selection Sphere").toUtf8() );
253 sphere_node_->
hide();
257 nodeName = std::string( tr(
"Selection Base Plugin: Lasso Selection Line").toUtf8() );
275 _env.primitivesBar =
new QHBoxLayout(tab->toolPrimitivesBar);
278 _env.operationsBar =
new QVBoxLayout(tab->toolOperationsWidget);
281 policy.setVerticalPolicy(QSizePolicy::MinimumExpanding);
282 policy.setHorizontalPolicy(QSizePolicy::Preferred);
283 tab->selectionGroup->setSizePolicy(policy);
285 tab->toolPrimitivesBar->setLayout(_env.primitivesBar);
286 tab->toolPrimitivesBar->setMinimumHeight(68);
287 tab->toolOperationsWidget->setLayout(_env.operationsBar);
288 tab->toolOperationsWidget->setMinimumHeight(150);
290 _env.primitiveActions =
new QActionGroup(0);
291 _env.primitiveActions->setExclusive(
true);
298 void SelectionBasePlugin::slotLoadSelectionButton() {
301 QString filename = QFileDialog::getOpenFileName(0, tr(
"Load Selection"),
"selection.ini", tr(
"Selection files ( *.ini )"));
303 if(filename.length() > 0) {
307 if(!file.
connect(filename,
false)) {
308 emit log(
LOGERR, QString(
"Could not read file '%1'!").arg(filename));
313 emit loadSelection(file);
322 void SelectionBasePlugin::slotSaveSelectionButton() {
325 QString filename = QFileDialog::getSaveFileName(0, tr(
"Save Selection"),
"selection.ini", tr(
"Selection files ( *.ini )"));
327 if(filename.length() > 0) {
331 if(!file.
connect(filename,
true)) {
332 emit log(
LOGERR, QString(
"Could not create file '%1'!").arg(filename));
337 emit saveSelection(file);
346 void SelectionBasePlugin::slotKeyEvent(QKeyEvent* _event) {
349 if ((_event->modifiers() & Qt::ControlModifier) || (_event->key() == Qt::Key_Control)) {
351 primitivesBarGroup_->setExclusive(
false);
353 deselection_ =
false;
354 primitivesBarGroup_->setExclusive(
true);
358 if ((_event->modifiers() & Qt::ShiftModifier) || (_event->key() == Qt::Key_Shift))
359 tool_->restrictOnTargets->setChecked(
true);
361 tool_->restrictOnTargets->setChecked(
false);
368 std::set<std::pair<int,Qt::KeyboardModifiers> >::iterator f =
369 registeredKeys_.find(std::pair<int,Qt::KeyboardModifiers>(_event->key(), _event->modifiers()));
371 if(f != registeredKeys_.end()) {
373 emit keyShortcutEvent((*f).first,(*f).second);
379 void SelectionBasePlugin::slotKeyReleaseEvent(QKeyEvent* _event) {
382 if ((_event->modifiers() & Qt::ControlModifier) || (_event->key() == Qt::Key_Control)) {
383 deselection_ =
false;
384 primitivesBarGroup_->setExclusive(
true);
388 if ((_event->modifiers() & Qt::ShiftModifier) || (_event->key() == Qt::Key_Shift))
389 tool_->restrictOnTargets->setChecked(
false);
394 void SelectionBasePlugin::slotAddSelectionEnvironment(QString _modeName, QString _description, QString _icon, QString& _handleName) {
401 std::map<QString,SelectionEnvironment>::iterator it =
402 selectionEnvironments_.begin();
404 for(; it != selectionEnvironments_.end(); ++it) {
405 if(_modeName == (*it).second.name) {
406 emit log(
LOGINFO, QString(
"Selection environment %1 already exists.").arg(_modeName));
412 SelectionEnvironment env;
413 env.name = _modeName;
417 if ( OpenFlipper::Options::gui() ) {
420 int index = tool_->typeTabWidget->addTab(tab, QIcon(_icon), _modeName);
421 env.tabWidget = tool_->typeTabWidget->widget(index);
425 tool_->typeTabWidget->setTabEnabled(index,
false);
426 tool_->typeTabWidget->widget(index)->setEnabled(
false);
434 env.handle = _handleName;
440 selectionEnvironments_.insert(std::pair<QString,SelectionEnvironment>(_handleName, env));
445 void SelectionBasePlugin::slotRegisterType(QString _handleName,
DataType _type) {
450 std::map<QString,SelectionEnvironment>::iterator it =
451 selectionEnvironments_.find(_handleName);
455 if(it != selectionEnvironments_.end()) {
457 for(std::vector<DataType>::iterator t_it = (*it).second.types.begin();
458 t_it != (*it).second.types.end(); ++t_it) {
460 if ((*t_it) == _type)
return;
463 (*it).second.types.push_back(_type);
468 tool_->typeTabWidget->setTabEnabled(tool_->typeTabWidget->indexOf((*it).second.tabWidget),
true);
469 (*it).second.tabWidget->setEnabled(
true);
473 emit log(
LOGERR,
"The specified selection environment has not been found! The data type could not be registered.");
480 QList<QAction*> primitivesList = primitivesBarGroup_->actions();
482 for(QList<QAction*>::iterator it = primitivesList.begin(); it != primitivesList.end(); ++it) {
483 (*it)->setEnabled(
false);
489 std::map<QString,SelectionEnvironment>::iterator sit =
491 if(sit != selectionEnvironments_.end()) {
493 bool atLeastOne =
false;
494 for(std::vector<DataType>::iterator tit = (*sit).second.types.begin();
495 tit != (*sit).second.types.end(); ++tit) {
502 (*it)->setEnabled(
true);
511 for(std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.begin();
512 it != selectionEnvironments_.end(); ++it) {
515 toggleSelectionAction_->setEnabled(toggleSelectionAction_->isAssociated(currentPrimitiveType_,
true));
516 lassoSelectionAction_->setEnabled(lassoSelectionAction_->isAssociated(currentPrimitiveType_,
true));
517 volumeLassoSelectionAction_->setEnabled(volumeLassoSelectionAction_->isAssociated(currentPrimitiveType_,
true));
518 surfaceLassoSelectionAction_->setEnabled(surfaceLassoSelectionAction_->isAssociated(currentPrimitiveType_,
true));
519 sphereSelectionAction_->setEnabled(sphereSelectionAction_->isAssociated(currentPrimitiveType_,
true));
520 boundarySelectionAction_->setEnabled(boundarySelectionAction_->isAssociated(currentPrimitiveType_,
true));
521 floodFillSelectionAction_->setEnabled(floodFillSelectionAction_->isAssociated(currentPrimitiveType_,
true));
522 componentsSelectionAction_->setEnabled(componentsSelectionAction_->isAssociated(currentPrimitiveType_,
true));
525 for(std::set<HandleAction*>::iterator cit = (*it).second.customSelectionModes.begin();
526 cit != (*it).second.customSelectionModes.end(); ++cit) {
528 (*cit)->setEnabled((availableObjectTypes_ & (*cit)->objectTypeRestriction()) &&
529 (*cit)->isAssociated(currentPrimitiveType_,
true));
536 void SelectionBasePlugin::slotMouseWheelEvent(QWheelEvent* _event,
const std::string& _mode) {
538 if(currentPickMode_ == NO_SELECTION_PICKING)
return;
541 if (currentSelectionMode_ == SB_SPHERE) {
543 float d = -(float)_event->delta() / 120.0 * 0.1;
544 sphere_radius_ *= 1.0 + d;
546 sphere_node_->
set_size(sphere_radius_);
547 sphere_node_->
show();
555 void SelectionBasePlugin::slotMouseEvent(QMouseEvent* _event) {
557 if(currentPickMode_ == NO_SELECTION_PICKING)
return;
560 if(currentSelectionMode_ == SB_TOGGLE) {
561 slotMouseToggleSelection(_event);
562 }
else if (currentSelectionMode_ == SB_LASSO) {
563 slotMouseLassoSelection(_event);
564 }
else if (currentSelectionMode_ == SB_VOLUME_LASSO) {
565 slotMouseVolumeLassoSelection(_event);
566 }
else if (currentSelectionMode_ == SB_SURFACE_LASSO) {
567 slotMouseSurfaceLassoSelection(_event);
568 }
else if (currentSelectionMode_ == SB_SPHERE) {
569 slotMouseSphereSelection(_event);
570 }
else if (currentSelectionMode_ == SB_BOUNDARY) {
571 slotMouseBoundarySelection(_event);
572 }
else if (currentSelectionMode_ == SB_FLOODFILL) {
573 slotMouseFloodFillSelection(_event);
574 }
else if (currentSelectionMode_ == SB_COMPONENTS) {
575 slotMouseComponentsSelection(_event);
578 slotMouseCustomSelection(_event);
584 void SelectionBasePlugin::slotAddPrimitiveType(QString _handleName, QString _name, QString _icon, SelectionInterface::PrimitiveType& _typeHandle) {
586 if ( !OpenFlipper::Options::gui() )
590 std::map<QString,SelectionEnvironment>::iterator it =
591 selectionEnvironments_.find(_handleName);
593 if(it == selectionEnvironments_.end()) {
594 emit log(
LOGERR, QString(
"Could not find selection environment width handle '%1'!").arg(_handleName));
598 SelectionEnvironment& env = (*it).second;
602 if(nextFreePrimitiveType_ > nextFreePrimitiveType_ << 1) {
603 emit log(
LOGERR,
"Maximum number of custom primitive types for selection reached!");
608 QList<QAction*>::const_iterator a_it = env.primitiveActions->actions().constBegin();
609 for(; a_it != env.primitiveActions->actions().constEnd(); ++a_it) {
610 if((*a_it)->text() == _name) {
611 emit log(
LOGERR, QString(
"A custom primitive type with name \"%1\" already exists!").arg(_name));
618 action->setCheckable(
true);
620 primitivesBarGroup_->addAction(action);
621 pickModeToolBar_->clear();
622 pickModeToolBar_->addActions(primitivesBarGroup_->actions());
623 pickModeToolBar_->addSeparator();
624 pickModeToolBar_->addActions(selectionModesGroup_->actions());
628 button->setMinimumSize(QSize(32,32));
629 button->setMaximumSize(QSize(64,64));
630 env.primitivesBar->addWidget(button);
632 _typeHandle = nextFreePrimitiveType_;
636 env.primitiveTypes |= _typeHandle;
638 primitiveTypeButtons_.insert(std::pair<PrimitiveType,QAction*>(_typeHandle,action));
641 nextFreePrimitiveType_ <<= 1;
644 connect(action, SIGNAL(toggled(
bool)),
this, SLOT(updateActivePrimitiveTypes(
bool)));
651 void SelectionBasePlugin::updateActivePrimitiveTypes(
bool _checked) {
653 QObject* sender = QObject::sender();
657 if(!clickedAction)
return;
660 clickedAction->setChecked(_checked);
663 currentPrimitiveType_ = 0u;
665 QList<QAction*> actions = primitivesBarGroup_->actions();
666 for(
int i = 0; i < actions.size(); ++i) {
668 if(actions[i]->isChecked()) {
681 slotSelectionEnvironmentRequested(_checked);
686 QList<QAction*> sm_actions = selectionModesGroup_->actions();
687 bool atLeastOneSelectionMode =
false;
688 for(
int i = 0; i < sm_actions.size(); ++i) {
690 if(sm_actions[i]->isChecked()) {
691 atLeastOneSelectionMode =
true;
695 if(!ha->isAssociated(currentPrimitiveType_)) {
696 ha->blockSignals(
true);
697 ha->setChecked(
false);
698 ha->blockSignals(
false);
699 toggleSelectionAction_->trigger();
705 if(!atLeastOneSelectionMode) {
706 toggleSelectionAction_->trigger();
710 std::map<QString,SelectionEnvironment>::iterator sit = selectionEnvironments_.find(clickedAction->
selectionEnvironmentHandle());
711 if(sit != selectionEnvironments_.end() && _checked) {
712 tool_->typeTabWidget->setCurrentIndex(tool_->typeTabWidget->indexOf((*sit).second.tabWidget));
718 lassoSelection_ =
false;
722 slotShowAndHideOperations();
731 if (_metaphor == SB_TOGGLE)
732 toggleSelectionAction_->trigger();
733 else if (_metaphor == SB_LASSO)
734 lassoSelectionAction_->trigger();
735 else if (_metaphor == SB_VOLUME_LASSO)
736 volumeLassoSelectionAction_->trigger();
737 else if (_metaphor == SB_SURFACE_LASSO)
738 surfaceLassoSelectionAction_->trigger();
739 else if (_metaphor == SB_SPHERE)
740 sphereSelectionAction_->trigger();
741 else if (_metaphor == SB_BOUNDARY)
742 boundarySelectionAction_->trigger();
743 else if (_metaphor == SB_FLOODFILL)
744 floodFillSelectionAction_->trigger();
745 else if (_metaphor == SB_COMPONENTS)
746 componentsSelectionAction_->trigger();
749 std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.begin();
751 for (; it != selectionEnvironments_.end() && !found; ++it) {
752 std::set<HandleAction*>::iterator e = it->second.customSelectionModes.begin();
753 for(; e != it->second.customSelectionModes.end(); ++e) {
755 QString customModeName = QString((*e)->selectionEnvironmentHandle() +
"_" + _metaphor).replace(
" ",
"_");
756 if((*e)->selectionModeHandle().contains(customModeName)) {
769 QList<QAction*>::iterator a_it = primitivesBarGroup_->actions().begin();
770 for(; a_it != primitivesBarGroup_->actions().end(); ++a_it) {
771 if((*a_it)->text() == _primitive) {
780 void SelectionBasePlugin::slotAddSelectionOperations(QString _handleName, QStringList _operationsList, QString _category, PrimitiveType _type) {
783 std::map<QString,SelectionEnvironment>::iterator e_it =
784 selectionEnvironments_.find(_handleName);
786 if(e_it == selectionEnvironments_.end()) {
787 emit log(
LOGERR, QString(
"Could not find selection environment with handle '%1'!").arg(_handleName));
791 SelectionEnvironment& env = (*e_it).second;
794 std::map<QString,std::pair<FillingLayout*,QGroupBox*> >::iterator it = env.categories.find(_category);
795 if(it == env.categories.end()) {
798 QGroupBox* group =
new QGroupBox(_category);
799 group->setLayout(fillLayout);
801 std::pair<std::map<QString,std::pair<FillingLayout*,QGroupBox*> >::iterator,
bool> ret;
802 ret = env.categories.insert(std::pair<QString,std::pair<FillingLayout*,QGroupBox*> >(_category,
803 std::pair<FillingLayout*,QGroupBox*>(fillLayout,group)));
806 env.operationsBar->addWidget(group);
810 for(
int i = 0; i < _operationsList.size(); ++i) {
811 QPushButton* button =
new QPushButton(_operationsList[i]);
812 button->setDisabled(
true);
813 button->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
814 int width = button->fontMetrics().width(_operationsList[i]);
815 button->setMinimumWidth(width);
816 button->setFixedHeight(26);
818 connect(button, SIGNAL(clicked()),
this, SLOT(slotOperationRequested()));
820 env.operations.insert(std::pair<PrimitiveType,QPushButton*>(_type, button));
822 (*it).second.first->addWidget(button);
825 slotShowAndHideOperations();
830 void SelectionBasePlugin::slotOperationRequested() {
832 QObject* sender = QObject::sender();
833 QPushButton* button = 0;
834 button =
dynamic_cast<QPushButton*
>(sender);
838 emit selectionOperation(button->text());
843 void SelectionBasePlugin::slotShowAndHideOperations() {
845 for(std::map<QString,SelectionEnvironment>::iterator e_it = selectionEnvironments_.begin();
846 e_it != selectionEnvironments_.end(); ++e_it) {
848 for(std::multimap<PrimitiveType,QPushButton*>::iterator it = (*e_it).second.operations.begin();
849 it != (*e_it).second.operations.end(); ++it) {
851 if((currentPrimitiveType_ & (*it).first) || (*it).first == 0u) {
853 (*it).second->setDisabled(
false);
856 (*it).second->setDisabled(
true);
864 void SelectionBasePlugin::slotSelectionEnvironmentRequested(
bool _checked) {
871 currentPickMode_ = SELECTION_PICKING;
876 void SelectionBasePlugin::slotEnterSelectionMode(
bool _checked) {
878 QObject* obj = QObject::sender();
885 act->setChecked(_checked);
895 lassoSelection_ =
false;
897 if(currentSelectionMode_ == SB_SPHERE) {
905 void SelectionBasePlugin::slotPickModeChanged (
const std::string& _pickmode) {
908 bool selectionPicking = (_pickmode ==
"SelectionBasePicking");
911 if(currentSelectionMode_ == SB_SPHERE)
912 sphere_node_->
show();
914 sphere_node_->
hide();
916 if(currentSelectionMode_ == SB_LASSO || currentSelectionMode_ == SB_VOLUME_LASSO)
921 bool resetPickToolBar =
false;
923 if(currentPickMode_ != NO_SELECTION_PICKING) {
927 sphere_node_->
hide();
931 lastPickMode_ = currentPickMode_;
932 currentPickMode_ = NO_SELECTION_PICKING;
934 }
else if (selectionPicking && currentPickMode_ == NO_SELECTION_PICKING && lastPickMode_ != NO_SELECTION_PICKING) {
937 currentPickMode_ = lastPickMode_;
939 }
else if (!selectionPicking && currentPickMode_ == NO_SELECTION_PICKING) {
948 currentPickMode_ = NO_SELECTION_PICKING;
949 currentSelectionMode_ = NO_SELECTION_MODE;
950 lastPickMode_ = NO_SELECTION_PICKING;
953 resetPickToolBar =
true;
959 lastPickMode_ = currentPickMode_ = _pickmode.c_str();
962 resetPickToolBar =
true;
970 toggleSelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_TOGGLE);
971 lassoSelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_LASSO);
972 volumeLassoSelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_VOLUME_LASSO);
973 surfaceLassoSelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_SURFACE_LASSO);
974 sphereSelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_SPHERE);
975 boundarySelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_BOUNDARY);
976 floodFillSelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_FLOODFILL);
977 componentsSelectionAction_->setChecked(!resetPickToolBar && currentSelectionMode_ == SB_COMPONENTS);
979 for(std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.begin();
980 it != selectionEnvironments_.end(); ++it) {
983 for(std::set<HandleAction*>::iterator csm_it = (*it).second.customSelectionModes.begin();
984 csm_it != (*it).second.customSelectionModes.end(); ++csm_it) {
985 (*csm_it)->setChecked(!resetPickToolBar && currentSelectionMode_ == (*csm_it)->selectionModeHandle());
996 bool _show, SelectionInterface::PrimitiveType _associatedTypes,
997 QString& _customIdentifier,
bool _custom,
DataType _objectTypeRestriction) {
999 if ( !OpenFlipper::Options::gui() )
1003 std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.find(_handleName);
1006 if(it == selectionEnvironments_.end())
return;
1009 if(_mode == SB_TOGGLE) {
1011 (*it).second.defaultSelectionModes.insert(toggleSelectionAction_);
1014 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(toggleSelectionAction_);
1015 if(e != (*it).second.defaultSelectionModes.end()) {
1016 (*it).second.defaultSelectionModes.erase(e);
1017 toggleSelectionAction_->removeAssociatedType(_associatedTypes);
1020 }
else if (_mode == SB_LASSO) {
1022 (*it).second.defaultSelectionModes.insert(lassoSelectionAction_);
1025 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(lassoSelectionAction_);
1026 if(e != (*it).second.defaultSelectionModes.end()) {
1027 (*it).second.defaultSelectionModes.erase(e);
1028 lassoSelectionAction_->removeAssociatedType(_associatedTypes);
1031 }
else if (_mode == SB_VOLUME_LASSO) {
1033 (*it).second.defaultSelectionModes.insert(volumeLassoSelectionAction_);
1036 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(volumeLassoSelectionAction_);
1037 if(e != (*it).second.defaultSelectionModes.end()) {
1038 (*it).second.defaultSelectionModes.erase(e);
1039 volumeLassoSelectionAction_->removeAssociatedType(_associatedTypes);
1042 }
else if (_mode == SB_SURFACE_LASSO) {
1044 (*it).second.defaultSelectionModes.insert(surfaceLassoSelectionAction_);
1047 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(surfaceLassoSelectionAction_);
1048 if(e != (*it).second.defaultSelectionModes.end()) {
1049 (*it).second.defaultSelectionModes.erase(e);
1050 surfaceLassoSelectionAction_->removeAssociatedType(_associatedTypes);
1053 }
else if (_mode == SB_SPHERE) {
1055 (*it).second.defaultSelectionModes.insert(sphereSelectionAction_);
1058 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(sphereSelectionAction_);
1059 if(e != (*it).second.defaultSelectionModes.end()) {
1060 (*it).second.defaultSelectionModes.erase(e);
1061 sphereSelectionAction_->removeAssociatedType(_associatedTypes);
1064 }
else if (_mode == SB_BOUNDARY) {
1066 (*it).second.defaultSelectionModes.insert(boundarySelectionAction_);
1069 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(boundarySelectionAction_);
1070 if(e != (*it).second.defaultSelectionModes.end()) {
1071 (*it).second.defaultSelectionModes.erase(e);
1072 boundarySelectionAction_->removeAssociatedType(_associatedTypes);
1075 }
else if (_mode == SB_FLOODFILL) {
1077 (*it).second.defaultSelectionModes.insert(floodFillSelectionAction_);
1080 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(floodFillSelectionAction_);
1081 if(e != (*it).second.defaultSelectionModes.end()) {
1082 (*it).second.defaultSelectionModes.erase(e);
1083 floodFillSelectionAction_->removeAssociatedType(_associatedTypes);
1086 }
else if (_mode == SB_COMPONENTS) {
1088 (*it).second.defaultSelectionModes.insert(componentsSelectionAction_);
1091 std::set<HandleAction*>::iterator e = (*it).second.defaultSelectionModes.find(componentsSelectionAction_);
1092 if(e != (*it).second.defaultSelectionModes.end()) {
1093 (*it).second.defaultSelectionModes.erase(e);
1094 componentsSelectionAction_->removeAssociatedType(_associatedTypes);
1106 action->setCheckable(
true);
1112 selectionModesGroup_->addAction(action);
1113 pickModeToolBar_->clear();
1114 pickModeToolBar_->addActions(primitivesBarGroup_->actions());
1115 pickModeToolBar_->addSeparator();
1116 pickModeToolBar_->addActions(selectionModesGroup_->actions());
1119 (*it).second.customSelectionModes.insert(action);
1121 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(slotEnterSelectionMode(
bool)));
1124 std::set<HandleAction*>::iterator e = (*it).second.customSelectionModes.begin();
1125 for(; e != (*it).second.customSelectionModes.end(); ++e) {
1126 if((*e)->selectionEnvironmentHandle() == _handleName)
1131 if(e != (*it).second.customSelectionModes.end()) {
1132 (*e)->removeAssociatedType(_associatedTypes);
1133 (*it).second.customSelectionModes.erase(e);
1141 void SelectionBasePlugin::slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
1142 SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier) {
1144 showSelectionMode(_modeName, _icon, _description, _handleName,
true, _associatedTypes, _customIdentifier,
true);
1150 void SelectionBasePlugin::slotAddCustomSelectionMode(QString _handleName, QString _modeName, QString _description, QString _icon,
1151 SelectionInterface::PrimitiveType _associatedTypes, QString& _customIdentifier,
1154 showSelectionMode(_modeName, _icon, _description, _handleName,
true, _associatedTypes, _customIdentifier,
true, _objectTypeRestriction);
1160 void SelectionBasePlugin::slotShowToggleSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1162 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1164 showSelectionMode(SB_TOGGLE, iconPath + TOGGLE_IMG, TOGGLE_DESC, _handleName, _show, _associatedTypes, dummy);
1170 void SelectionBasePlugin::slotShowLassoSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1172 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1174 showSelectionMode(SB_LASSO, iconPath + LASSO_IMG, LASSO_DESC, _handleName, _show, _associatedTypes, dummy);
1180 void SelectionBasePlugin::slotShowVolumeLassoSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1182 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1184 showSelectionMode(SB_VOLUME_LASSO, iconPath + VOLUME_LASSO_IMG, VOLUME_LASSO_DESC, _handleName, _show, _associatedTypes, dummy);
1190 void SelectionBasePlugin::slotShowSurfaceLassoSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1192 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1194 showSelectionMode(SB_SURFACE_LASSO, iconPath + SURFACE_LASSO_IMG, SURFACE_LASSO_DESC, _handleName, _show, _associatedTypes, dummy);
1200 void SelectionBasePlugin::slotShowSphereSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1202 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1204 showSelectionMode(SB_SPHERE, iconPath + SPHERE_IMG, SPHERE_DESC, _handleName, _show, _associatedTypes, dummy);
1210 void SelectionBasePlugin::slotShowClosestBoundarySelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1212 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1214 showSelectionMode(SB_BOUNDARY, iconPath + BOUNDARY_IMG, BOUNDARY_DESC, _handleName, _show, _associatedTypes, dummy);
1220 void SelectionBasePlugin::slotShowFloodFillSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1222 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1224 showSelectionMode(SB_FLOODFILL, iconPath + FLOODFILL_IMG, FLOODFILL_DESC, _handleName, _show, _associatedTypes, dummy);
1230 void SelectionBasePlugin::slotShowComponentsSelectionMode(QString _handleName,
bool _show, SelectionInterface::PrimitiveType _associatedTypes) {
1232 QString iconPath = OpenFlipper::Options::iconDirStr() + OpenFlipper::Options::dirSeparator();
1234 showSelectionMode(SB_COMPONENTS, iconPath + COMPONENTS_IMG, COMPONENTS_DESC, _handleName, _show, _associatedTypes, dummy);
1240 void SelectionBasePlugin::slotGetActiveDataTypes(TypeList& _types) {
1242 if(currentPickMode_ == NO_SELECTION_PICKING) {
1243 _types = TypeList();
1245 std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.find(currentPickMode_);
1246 if(it == selectionEnvironments_.end()) {
1247 _types = TypeList();
1249 _types = (*it).second.types;
1256 void SelectionBasePlugin::slotGetActivePrimitiveType(SelectionInterface::PrimitiveType& _type) {
1258 _type = currentPrimitiveType_;
1263 void SelectionBasePlugin::slotMouseToggleSelection(QMouseEvent* _event) {
1266 if (_event->type() == QEvent::MouseButtonPress) {
1268 if (_event->button() == Qt::RightButton)
return;
1270 emit toggleSelection(_event, currentPrimitiveType_, deselection_);
1276 void SelectionBasePlugin::slotMouseLassoSelection(QMouseEvent* _event) {
1279 if (_event->button() == Qt::RightButton)
return;
1281 unsigned int node_idx, target_idx;
1289 if(_event->type() == QEvent::MouseButtonPress && _event->button() == Qt::LeftButton) {
1292 if(!lassoSelection_) {
1294 linePoints_.clear();
1295 lassoSelection_ =
true;
1301 linePoints_.push_back(hit_point);
1304 emit lassoSelection(_event, currentPrimitiveType_, deselection_);
1306 }
else if(_event->type() == QEvent::MouseMove) {
1308 if(!lassoSelection_)
return;
1318 line_node_->
clear();
1319 for (std::vector< ACG::Vec3d >::iterator it = linePoints_.begin(); it != linePoints_.end(); ++it)
1325 if( !linePoints_.empty() )
1328 }
else if(_event->type() == QEvent::MouseButtonDblClick) {
1331 lassoSelection_ =
false;
1332 linePoints_.clear();
1333 line_node_->
clear();
1337 emit lassoSelection(_event, currentPrimitiveType_, deselection_);
1343 void SelectionBasePlugin::slotMouseVolumeLassoSelection(QMouseEvent* _event) {
1346 if (_event->button() == Qt::RightButton)
return;
1348 unsigned int node_idx, target_idx;
1356 if(_event->type() == QEvent::MouseButtonPress && _event->button() == Qt::LeftButton) {
1359 if(!lassoSelection_) {
1361 linePoints_.clear();
1362 lassoSelection_ =
true;
1369 linePoints_.push_back(hit_point);
1372 emit volumeLassoSelection(_event, currentPrimitiveType_, deselection_);
1374 }
else if(_event->type() == QEvent::MouseMove) {
1376 if(!lassoSelection_)
return;
1386 line_node_->
clear();
1387 for (std::vector< ACG::Vec3d >::iterator it = linePoints_.begin(); it != linePoints_.end(); ++it)
1393 if( !linePoints_.empty() )
1396 }
else if(_event->type() == QEvent::MouseButtonDblClick) {
1399 lassoSelection_ =
false;
1400 linePoints_.clear();
1401 line_node_->
clear();
1405 emit volumeLassoSelection(_event, currentPrimitiveType_, deselection_);
1411 void SelectionBasePlugin::slotMouseSurfaceLassoSelection(QMouseEvent* _event) {
1418 void SelectionBasePlugin::slotMouseSphereSelection(QMouseEvent* _event) {
1421 if (_event->button() == Qt::RightButton)
return;
1424 unsigned int node_idx, target_idx;
1428 sphere_node_->
hide();
1432 _event->pos(), node_idx, target_idx, &hit_point)) {
1439 sphere_node_->
show();
1441 sphere_node_->
set_size(sphere_radius_);
1444 if( (_event->buttons() & Qt::LeftButton)
1445 ||( (_event->buttons() == Qt::NoButton) && (_event->type() == QEvent::MouseButtonRelease))
1448 emit sphereSelection(_event, sphere_radius_, currentPrimitiveType_, deselection_);
1454 sphere_node_->
hide();
1460 void SelectionBasePlugin::slotMouseBoundarySelection(QMouseEvent* _event) {
1463 if (_event->type() == QEvent::MouseButtonPress) {
1465 if (_event->button() == Qt::RightButton)
return;
1467 emit closestBoundarySelection(_event, currentPrimitiveType_, deselection_);
1473 void SelectionBasePlugin::slotMouseFloodFillSelection(QMouseEvent* _event) {
1476 if (_event->type() == QEvent::MouseButtonPress) {
1478 if (_event->button() == Qt::RightButton)
return;
1480 double maxAngle = 2*M_PI;
1482 if(!OpenFlipper::Options::nogui())
1483 maxAngle = tool_->maxFloodFillAngle->value();
1485 emit floodFillSelection(_event, maxAngle, currentPrimitiveType_, deselection_);
1491 void SelectionBasePlugin::slotMouseComponentsSelection(QMouseEvent* _event) {
1494 if (_event->type() == QEvent::MouseButtonPress) {
1496 if (_event->button() == Qt::RightButton)
return;
1498 emit componentsSelection(_event, currentPrimitiveType_, deselection_);
1504 void SelectionBasePlugin::slotMouseCustomSelection(QMouseEvent* _event) {
1506 emit customSelection(_event, currentPrimitiveType_, currentSelectionMode_, deselection_);
1511 void SelectionBasePlugin::addedEmptyObject (
int _id) {
1518 std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.begin();
1527 for(;it != selectionEnvironments_.end(); ++it) {
1530 for(std::vector<DataType>::iterator t_it = (*it).second.types.begin();
1531 t_it != (*it).second.types.end(); ++t_it) {
1543 availableObjectTypes_ |= obj->
dataType();
1550 if (bObject && !bObject->
isGroup()) {
1551 emit log(
LOGERR,
"Could not retrieve object type! Maybe a selection environment will be missing.");
1560 tool_->typeTabWidget->setTabEnabled(tool_->typeTabWidget->indexOf((*it).second.tabWidget),
true);
1561 (*it).second.tabWidget->setEnabled(
true);
1579 void SelectionBasePlugin::objectDeleted (
int _id) {
1587 std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.begin();
1597 for(;it != selectionEnvironments_.end(); ++it) {
1600 for(std::vector<DataType>::iterator t_it = (*it).second.types.begin();
1601 t_it != (*it).second.types.end(); ++t_it) {
1612 availableObjectTypes_ = (availableObjectTypes_ & ~obj->
dataType().value());
1615 emit log(
LOGERR,
"Could not retrieve object type!");
1626 bool atLeastOne =
false;
1627 for(std::vector<DataType>::iterator t_it = (*it).second.types.begin();
1628 t_it != (*it).second.types.end(); ++t_it) {
1637 tool_->typeTabWidget->setTabEnabled(tool_->typeTabWidget->indexOf((*it).second.tabWidget), atLeastOne);
1638 (*it).second.tabWidget->setEnabled(atLeastOne);
1648 std::cerr <<
"====== ERROR =======" << std::endl;
1649 std::cerr <<
"Negative counter for type " << obj->
dataType().name().toStdString() << std::endl;
1652 std::cerr <<
"Error: No counter for type " << obj->
dataType().name().toStdString() << std::endl;
1662 void SelectionBasePlugin::updateTabsOrder() {
1664 std::map<int, int> newMappings;
1667 for(
int i = 0; i < tool_->typeTabWidget->count(); ++i) {
1668 if(tool_->typeTabWidget->isTabEnabled(i)) {
1669 tool_->typeTabWidget->insertTab(firstFree, tool_->typeTabWidget->widget(i), tool_->typeTabWidget->tabText(i));
1670 newMappings.insert(std::pair<int,int>(i,firstFree));
1674 newMappings.insert(std::pair<int,int>(i,i));
1679 if(tool_->typeTabWidget->count() > 0) tool_->typeTabWidget->setCurrentIndex(0);
1684 void SelectionBasePlugin::slotTargetObjectsOnly(
bool& _targetsOnly) {
1686 if(OpenFlipper::Options::nogui() || tool_ == 0) _targetsOnly =
true;
1688 _targetsOnly = tool_->restrictOnTargets->isChecked();
1702 QString needle = _name;;
1705 needle.append(QString::number(_num));
1709 for(std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.begin();
1710 it != selectionEnvironments_.end(); ++it) {
1714 for(std::set<HandleAction*>::iterator dsm_it = (*it).second.defaultSelectionModes.begin();
1715 dsm_it != (*it).second.defaultSelectionModes.end(); ++dsm_it) {
1717 if((*dsm_it)->selectionModeHandle() == needle) {
1738 QString needle = _name;;
1741 needle.append(QString::number(_num));
1745 for(std::map<QString,SelectionEnvironment>::iterator it = selectionEnvironments_.begin();
1746 it != selectionEnvironments_.end(); ++it) {
1748 if((*it).first == needle) {
1762 QMap<DataType, int>::iterator iterator =
typeCounter_.find(_type);
1767 if ( _excludeId != -1 ) {
1773 if (
object == 0 ) {
1774 std::cerr <<
"Unable to get Object for type exists" << std::endl;
1784 std::cerr <<
"Type exists Error after mismatch exclude: " << _type.
name().toStdString() <<
" negative count" << std::endl;
1796 std::cerr <<
"Type exists Error " << _type.
name().toStdString() <<
" negative count" << std::endl;
1807 std::cerr <<
"Type exists Error " << _type.
name().toStdString() <<
" negative count" << std::endl;
1823 void SelectionBasePlugin::slotRegisterKeyShortcut(
int _key, Qt::KeyboardModifiers _modifiers) {
1825 std::set<std::pair<int,Qt::KeyboardModifiers> >::iterator f =
1826 registeredKeys_.find(std::pair<int,Qt::KeyboardModifiers>(_key,_modifiers));
1828 if(f == registeredKeys_.end()) {
1830 emit registerKey(_key, _modifiers, QString(
"Selection base key %1").arg(_key),
true);
1831 registeredKeys_.insert(std::pair<int,Qt::KeyboardModifiers>(_key,_modifiers));
1837 #if QT_VERSION < 0x050000
void setTraverseMode(unsigned int _mode)
Set traverse mode for node.
Viewer::ViewerProperties & viewerProperties(int _id)
Get the viewer properties Use this functions to get basic viewer properties such as backgroundcolor o...
void add_point(const Vec3d &_v)
add point (for LineMode == PolygonMode)
void enable_backface_culling()
enable backface culling (not active by default, see applyProperties)
int context_height() const
get gl context height
void set_line_width(float _sz)
set line width (default: 1.0)
unsigned int applyProperties() const
get properties that will be applied (OR'ed ApplyProperties)
void clear_points()
clear points/lines
void disconnect()
Remove connection of this object to a file.
QString getUniqueIdentifierName(QString _name, int _num=0)
Get a unique pickmode name.
picks faces (should be implemented for all nodes)
pick any of the prior targets (should be implemented for all nodes)
Vec3d unproject(const Vec3d &_winPoint) const
unproject point in window coordinates _winPoint to world coordinates
bool getObject(int _identifier, BSplineCurveObject *&_object)
void set_base_color(const Vec4f &_c)
set the base color
bool hidden()
Is node not visible (status != Active)?
QString getUniqueHandleName(QString _name, int _num=0)
Get a unique handle name.
void selectionEnvironmentHandle(QString _handle)
Get/Set selection environment handle name.
Execute action on node first and then on its children.
void addAssociatedType(unsigned int _associatedType)
Get/Set associated primitive types.
VectorT< float, 4 > Vec4f
bool connect(const QString &name, const bool create)
Connect INIFile object with given filename.
bool isGroup() const
Check if object is a group.
void disable_alpha_test()
disable alpha test
DrawMode SOLID_SMOOTH_SHADED
draw smooth shaded (Gouraud shaded) faces (requires halfedge normals)
bool dataType(DataType _type) const
DrawModes::DrawMode drawMode() const
Return the own draw modes of this node.
void selectionEnvironmentHandle(const QString _handle)
Get/Set associated selection environment handle.
void hide()
Hide Node: set status to HideNode.
const std::string pickMode()
Get the current Picking mode.
void set_size(double _s, int _idx=0)
set size
Class for the handling of simple configuration files.
void selectionModeHandle(QString _handle)
Get/Set selection mode handle name.
void set_color(const Vec4f &_c)
set color (base, ambient, diffuse, specular) based on _c
SelectionBasePlugin()
Default constructor.
apply material (ambient, diffuse, specular, shininess)
void showSelectionMode(QString _mode, QString _icon, QString _desc, QString _handleName, bool _show, SelectionInterface::PrimitiveType _associatedTypes, QString &_customIdentifier, bool _custom=false, DataType _objectTypeRestriction=DATA_ALL)
void clear()
clear points/lines and colors
Draw node in second pass.
void addGlobalNode(ACG::SceneGraph::BaseNode *_node)
Add a global node.
double sceneRadius()
Returns the current scene radius from the active examiner widget.
bool typeExists(DataType _type, int _excludeId=-1)
Test if at least one object of type _type is in the scene graph.
void updatePickModeToolBar()
Update the pickmode toolbar.
void setSelectionMetaphor(QString _metaphor)
Enables setting the selection metaphor via scripting The default selection metaphors are: ...
Primitive & get_primitive(int _idx)
get a primitive
bool & alwaysOnTop()
get and set always on top
void show()
Show node: set status to Active.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, unsigned int &_nodeIdx, unsigned int &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
SelectionTypeFrameWidget * createNewTypeFrame(SelectionEnvironment &_env)
Create new type frame for tabs widget.
void set_color(const Vec4f &_c)
Override material node's set color function in order to locally add color.
Viewer::ActionMode actionMode()
Get the current Action mode.
ACG::SceneGraph::MaterialNode MaterialNode
Materialnode.
void set_position(const Vec3d &_p, int _idx=0)
set position
QString name() const
Return the name of this type as text.
ACG::GLState & glState()
Get the glState of the Viewer.
bool getPickedObject(const unsigned int _node_idx, BaseObjectData *&_object)
Get the picked mesh.
QMap< DataType, int > typeCounter_
Caches the number of available elements of a certain data type for the typeExists function...
void primitiveType(unsigned int _type)
Get/Set primitive type.
void enable_blending(GLenum _p1=GL_SRC_ALPHA, GLenum _p2=GL_ONE_MINUS_SRC_ALPHA)
enable blending with Parameters (_p1, _p2)
void enablePicking(bool _enable)
void setSelectionPrimitiveType(QString _primitive)
Enables setting the selection primitive via scripting The default primitives for OpenMesh are: ...