ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvContourExtractorDlg.cpp
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
9 
10 // CV_CORE_LIB
11 #include <CVPlatform.h>
12 
13 // Qt
14 #include <QCoreApplication>
15 
16 // system
17 #include <assert.h>
18 #if defined(CV_WINDOWS)
19 #include <windows.h>
20 #else
21 #include <time.h>
22 #include <unistd.h>
23 #endif
24 
26  : QDialog(parent, Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint),
27  Ui::ContourExtractorDlg(),
28  m_skipped(false) {
29  setupUi(this);
30 }
31 
33  connect(nextPushButton, &QAbstractButton::clicked, &m_loop,
34  &QEventLoop::quit);
35  // connect(nextPushButton, SIGNAL(clicked()), this, SLOT(accept()));
36  connect(skipPushButton, &QAbstractButton::clicked, this,
38  nextPushButton->setFocus();
39 
40  // create 3D window
41  {
42  // QWidget* glWidget = 0;
43  // CreateGLWindow(m_glWindow, glWidget, false, true);
44  // assert(m_glWindow && glWidget);
45 
47  // black (text) & white (background) display by default
51  params.drawBackgroundGradient = false;
52  params.decimateMeshOnMove = false;
53  params.displayCross = false;
54  params.colorScaleUseShader = false;
63  viewFrame->setLayout(new QHBoxLayout);
64  viewFrame->layout()->addWidget(ecvDisplayTools::GetMainWindow());
65  }
66 }
67 
69  float pixSize = std::max(
70  box.getDiagVec().x /
71  std::max(20, ecvDisplayTools::GetScreenRect().width() - 20),
72  box.getDiagVec().y /
73  std::max(20,
74  ecvDisplayTools::GetScreenRect().height() - 20));
77 }
78 
80  return skipPushButton->isChecked();
81 }
82 
84  bool noDependency /*=true*/) {
85  if (obj) {
86  ecvDisplayTools::AddToOwnDB(obj, noDependency);
87  }
88 }
89 
91  if (obj) {
93  }
94 }
95 
97  if (m_skipped) return;
99  QCoreApplication::processEvents();
100 }
101 
103  QString message, bool waitForUserConfirmation /*=false*/) {
104  if (m_skipped) return;
105  messageLabel->setText(message);
106  if (waitForUserConfirmation) waitForUser(20);
107 }
108 
110  m_skipped = true;
111  hide();
112  QCoreApplication::processEvents();
113 }
114 
115 void ccContourExtractorDlg::waitForUser(unsigned defaultDelay_ms /*=100*/) {
116  if (m_skipped) return;
117 
118  if (autoCheckBox->isChecked()) {
119  // simply wait a pre-determined time
120 #if defined(CV_WINDOWS)
121  ::Sleep(defaultDelay_ms);
122 #else
123  usleep(defaultDelay_ms * 1000);
124 #endif
125  } else {
126  setModal(true);
127  // wait for the user to click on the 'Next' button
128  m_loop.exec();
129  setModal(false);
130  // exec();
131  }
132 }
Type y
Definition: CVGeom.h:137
Type u[3]
Definition: CVGeom.h:139
Type x
Definition: CVGeom.h:137
static Vector3Tpl fromArray(const int a[3])
Constructor from an int array.
Definition: CVGeom.h:268
Bounding box structure.
Definition: ecvBBox.h:25
void removFromDisplay(ccHObject *obj)
Removes an entity from the (2D/3D) display.
bool isSkipped() const
Returns whether the dialog has been 'skipped' or not.
void init()
Initializes the display.
void addToDisplay(ccHObject *obj, bool noDependency=true)
Adds an entity to the (2D/3D) display.
QEventLoop m_loop
Local event loop.
void onSkipButtonClicked()
When the skip button is clicked.
void zoomOn(const ccBBox &bbox)
Zooms on a given 2D region (3D bouding-box considered in 2D only)
void waitForUser(unsigned defaultDelay_ms=100)
Waits for user action.
void refresh()
Forces refresh.
ccContourExtractorDlg(QWidget *parent=0)
Default constructor.
void displayMessage(QString message, bool waitForUserConfirmation=false)
Display a new message.
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
Vector3Tpl< T > getDiagVec() const
Returns diagonal vector.
Definition: BoundingBox.h:169
Vector3Tpl< T > getCenter() const
Returns center.
Definition: BoundingBox.h:164
static void SetDisplayParameters(const ecvGui::ParamStruct &params)
Sets current parameters for this display.
static void RemoveFromOwnDB(ccHObject *obj)
Removes an entity from window own DB.
static void DisplayOverlayEntities(bool state)
static QMainWindow * GetMainWindow()
static void SetPixelSize(float pixelSize)
Sets pixel size (i.e. zoom base)
static void SetPickingMode(PICKING_MODE mode=DEFAULT_PICKING)
static const ecvGui::ParamStruct & GetDisplayParameters()
Returns current parameters for this display (const version)
static QRect GetScreenRect()
static void RedrawDisplay(bool only2D=false, bool forceRedraw=true)
static void AddToOwnDB(ccHObject *obj, bool noDependency=true)
Adds an entity to window own DB.
static void SetCameraPos(const CCVector3d &P)
Sets camera position.
static void SetPerspectiveState(bool state, bool objectCenteredView)
Set perspective state/mode.
static void SetInteractionMode(INTERACTION_FLAGS flags)
Definition: sfEditDlg.h:16
void Sleep(int milliseconds)
Definition: Helper.cpp:278
constexpr Rgb black(0, 0, 0)
constexpr Rgb white(MAX, MAX, MAX)
GUI parameters.
ecvColor::Rgbub backgroundCol
Background color.
ecvColor::Rgbub textDefaultCol
Default text color.
bool displayCross
Display cross in the middle of the screen.
bool colorScaleUseShader
Whether to use shader for color scale display (if available) or not.
bool decimateMeshOnMove
Decimate meshes when moved.
bool drawBackgroundGradient
Use background gradient.
ecvColor::Rgbub pointsDefaultCol
Default 3D points color.