31 #include <QApplication>
32 #include <QColorDialog>
33 #include <QMessageBox>
34 #include <QSizePolicy>
36 #ifdef USE_PCL_BACKEND
37 #include <Tools/MeasurementTools/PclMeasurementTools.h>
42 Ui::MeasurementToolDlg(),
44 m_updatingFromTool(false),
45 m_pickingHub(nullptr),
47 m_currentColor(QColor(0, 255, 0))
56 connect(resetButton, &QToolButton::clicked,
this,
58 connect(closeButton, &QToolButton::clicked,
this,
60 connect(exportButton, &QToolButton::clicked,
this,
64 connect(instancesComboBox,
65 QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
67 connect(addInstanceButton, &QToolButton::clicked,
this,
69 connect(removeInstanceButton, &QToolButton::clicked,
this,
73 connect(colorButton, &QPushButton::clicked,
this,
87 if (key == Qt::Key_Escape) {
93 removeInstanceButton->setEnabled(
false);
116 #ifdef USE_PCL_BACKEND
119 CVLog::Error(
"[ecvMeasurementTool] No visualizer available!");
135 if (applyToAllCheckBox && applyToAllCheckBox->isChecked() &&
140 #ifdef USE_PCL_BACKEND
141 PclMeasurementTools* firstPclTool =
142 qobject_cast<PclMeasurementTools*>(firstInstance);
144 double r = 0.0, g = 1.0, b = 0.0;
145 if (firstPclTool->getColor(r, g, b)) {
150 double fontR = 1.0, fontG = 1.0, fontB = 1.0;
151 firstPclTool->getFontColor(fontR, fontG, fontB);
153 tool->
setBold(firstPclTool->getFontBold());
154 tool->
setItalic(firstPclTool->getFontItalic());
155 tool->
setShadow(firstPclTool->getFontShadow());
158 firstPclTool->getHorizontalJustification());
160 firstPclTool->getVerticalJustification());
193 QList<ecvGenericMeasurementTools*> toolsToRemove;
198 toolsToRemove.append(existingTool);
205 toolToRemove->disableShortcuts();
208 QWidget* widget = toolToRemove->getMeasurementWidget();
210 parametersLayout->removeWidget(widget);
211 widget->setVisible(
false);
218 toolToRemove->clear();
237 if (applyToAllCheckBox && applyToAllCheckBox->isChecked() &&
243 #ifdef USE_PCL_BACKEND
244 PclMeasurementTools* firstPclTool =
245 qobject_cast<PclMeasurementTools*>(firstInstance);
247 double r = 0.0, g = 1.0, b = 0.0;
248 if (firstPclTool->getColor(r, g, b)) {
253 double fontR = 1.0, fontG = 1.0, fontB = 1.0;
254 firstPclTool->getFontColor(fontR, fontG, fontB);
256 tool->
setBold(firstPclTool->getFontBold());
257 tool->
setItalic(firstPclTool->getFontItalic());
258 tool->
setShadow(firstPclTool->getFontShadow());
261 firstPclTool->getHorizontalJustification());
263 firstPclTool->getVerticalJustification());
298 if (t && t->getMeasurementWidget()) {
299 QWidget* widget = t->getMeasurementWidget();
301 if (widget->parent() ==
nullptr ||
302 parametersLayout->indexOf(widget) >= 0) {
303 parametersLayout->removeWidget(widget);
305 widget->setVisible(
false);
310 t->lockInteraction();
318 parametersLayout->addWidget(currentWidget);
319 currentWidget->setVisible(
true);
325 currentWidget->setMinimumSize(0, 0);
326 currentWidget->setMaximumSize(16777215,
329 QSizePolicy::Preferred);
331 currentWidget->adjustSize();
332 currentWidget->updateGeometry();
334 QApplication::processEvents();
348 instancesComboBox->blockSignals(
true);
349 instancesComboBox->clear();
358 typeName =
"Protractor";
361 typeName =
"Contour";
364 QString instanceName = QString(
"%1 #%2").arg(typeName).arg(i + 1);
365 instancesComboBox->addItem(instanceName);
370 QString label = QString(
" #%1").arg(i + 1);
376 if (currentIndex >= 0) {
377 instancesComboBox->setCurrentIndex(currentIndex);
380 instancesComboBox->blockSignals(
false);
387 if (newTool ==
m_tool)
return;
409 "Setting m_vtkWidget=%1 for new tool")
418 "[ecvMeasurementTool::addInstance] m_linkedWidget is null, "
419 "new tool may not have shortcuts");
423 removeInstanceButton->setEnabled(
true);
433 int index = instancesComboBox->currentIndex();
442 parametersLayout->removeWidget(widget);
443 widget->setVisible(
false);
452 toolToRemove->
clear();
467 instancesComboBox->setCurrentIndex(newIndex);
472 removeInstanceButton->setEnabled(
false);
505 tool->setInputData(entity);
527 tool->setupShortcuts(win);
544 CVLog::Warning(
"[ecvMeasurementTool] Picking hub not available!");
560 tool->lockInteraction();
564 tool->unlockInteraction();
586 tool->disableShortcuts();
588 parametersLayout->removeWidget(tool->getMeasurementWidget());
629 #ifdef USE_PCL_BACKEND
630 PclMeasurementTools* pclTool = qobject_cast<PclMeasurementTools*>(
m_tool);
635 double r = 0.0, g = 1.0, b = 0.0;
636 if (pclTool->getColor(r, g, b)) {
637 QColor toolColor = QColor::fromRgbF(r, g, b);
650 props.
family = pclTool->getFontFamily();
651 props.
size = pclTool->getFontSize();
652 double fontR = 1.0, fontG = 1.0, fontB = 1.0;
653 pclTool->getFontColor(fontR, fontG, fontB);
654 props.
color = QColor::fromRgbF(fontR, fontG, fontB);
655 props.
bold = pclTool->getFontBold();
656 props.
italic = pclTool->getFontItalic();
657 props.
shadow = pclTool->getFontShadow();
658 props.
opacity = pclTool->getFontOpacity();
660 pclTool->getHorizontalJustification();
679 widget->setVisible(state);
694 "[ecvMeasurementTool] No measurement result to export from "
711 typeName =
"Protractor";
714 typeName =
"Measurement";
717 output->
setName(QString(
"%1_%2").arg(typeName).arg(
724 CVLog::Print(QString(
"[ecvMeasurementTool] Exported %1")
727 CVLog::Error(
"[ecvMeasurementTool] MainWindow instance not available");
741 "m_processing=%1, m_tool=%2, m_pickPointMode=%3")
743 .arg(
m_tool ?
"valid" :
"null")
761 QString(
"[ecvMeasurementTool] Point picked: (%1, %2, %3), mode: %4")
793 "[ecvMeasurementTool] Center picking only available "
802 CVLog::Warning(QString(
"[ecvMeasurementTool] Unknown pick mode: %1")
823 "[ecvMeasurementTool] Failed to register picking listener");
827 CVLog::Warning(
"[ecvMeasurementTool] Picking hub not available!");
843 QColor initialColor = QColor(0, 255, 0);
844 #ifdef USE_PCL_BACKEND
845 PclMeasurementTools* pclTool = qobject_cast<PclMeasurementTools*>(
m_tool);
847 double r = 0.0, g = 1.0, b = 0.0;
848 if (pclTool->getColor(r, g, b)) {
849 initialColor = QColor::fromRgbF(r, g, b);
854 QColor newColor = QColorDialog::getColor(initialColor,
this,
855 tr(
"Select Measurement Color"));
857 if (newColor.isValid()) {
875 QString(
"QPushButton { background-color: rgb(%1, %2, %3); }")
876 .arg(colorToDisplay.red())
877 .arg(colorToDisplay.green())
878 .arg(colorToDisplay.blue());
879 colorButton->setStyleSheet(styleSheet);
884 if (!
color.isValid())
return;
887 double r =
color.redF();
888 double g =
color.greenF();
889 double b =
color.blueF();
894 if (applyToAllCheckBox && applyToAllCheckBox->isChecked()) {
898 tool->setColor(r, g, b);
927 if (applyToAllCheckBox && applyToAllCheckBox->isChecked()) {
931 tool->setFontFamily(props.family);
932 tool->setFontSize(props.size);
933 tool->setFontColor(props.color.redF(), props.color.greenF(),
934 props.color.blueF());
935 tool->setBold(props.bold);
936 tool->setItalic(props.italic);
937 tool->setShadow(props.shadow);
938 tool->setFontOpacity(props.opacity);
939 tool->setHorizontalJustification(props.horizontalJustification);
940 tool->setVerticalJustification(props.verticalJustification);
949 props.color.blueF());
static bool PrintDebug(const char *format,...)
Same as Print, but works only in Debug mode.
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Print(const char *format,...)
Prints out a formatted message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
static MainWindow * TheInstance()
Returns the unique instance of this object.
void addToDB(const QStringList &filenames, QString fileFilter=QString(), bool displayDialog=true)
ccPickingHub * pickingHub() override
virtual void setVisible(bool state)
Sets entity visibility.
Hierarchical CLOUDVIEWER Object.
void removeAllChildren()
Removes all children.
ccHObject * getFirstChild() const
Shortcut: returns first child.
unsigned getChildrenNumber() const
Returns the number of children.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getChild(unsigned childPos) const
Returns the ith child.
bool isGroup() const
Returns whether the instance is a group.
virtual QString getName() const
Returns object name.
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
Generic overlay dialog interface.
void shortcutTriggered(int key)
Signal emitted when an overridden key shortcut is pressed.
virtual void stop(bool accepted)
Stops process/dialog.
virtual bool start()
Starts process.
bool m_processing
Running/processing state.
virtual bool linkWith(QWidget *win)
Links the overlay dialog with a MDI window.
void addOverridenShortcut(Qt::Key key)
void removeListener(ccPickingListener *listener, bool autoStopPickingIfLast=true)
Removes a listener.
bool addListener(ccPickingListener *listener, bool exclusive=false, bool autoStartPicking=true, ecvDisplayTools::PICKING_MODE mode=ecvDisplayTools::POINT_OR_TRIANGLE_PICKING)
Adds a listener.
Generic visualizer 3D interface.
Tensor Minimum(const Tensor &input, const Tensor &other)
Computes the element-wise minimum of input and other. The tensors must have same data type and device...