提交 803ed6ea 编写于 作者: V Vaclav Bubnik

Merge branch 'vb' into main.

此差异已折叠。
/*=========================================================================
Library: CTK
Copyright (c) Kitware Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0.txt
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=========================================================================*/
// Modifications Copyright 2020-present VUKOZ
// Extra ';' after some Qt macros were removed. Caused '-Wpedantic' warnings.
// Added conditional compilation HAS_CTK_VALUE_PROXY.
#ifndef __ctkDoubleRangeSlider_h
#define __ctkDoubleRangeSlider_h
// Qt includes
#include <QWidget>
#include <QSlider>
// CTK includes
// #include <ctkPimpl.h>
// #include "ctkWidgetsExport.h"
class ctkRangeSlider;
class ctkDoubleRangeSliderPrivate;
#if defined(HAS_CTK_VALUE_PROXY)
class ctkValueProxy;
#endif
/// \ingroup Widgets
/// ctkDoubleRangeSlider is a slider that controls 2 numbers as double.
/// ctkDoubleRangeSlider internally aggregates a ctkRangeSlider (not in the
/// API to prevent misuse). Only subclasses can have access to it.
/// \sa ctkRangeSlider, ctkDoubleSlider, ctkRangeWidget
class ctkDoubleRangeSlider : public QWidget
{
Q_OBJECT
Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
Q_PROPERTY(double minimumValue READ minimumValue WRITE setMinimumValue)
Q_PROPERTY(double maximumValue READ maximumValue WRITE setMaximumValue)
Q_PROPERTY(double minimumPosition READ minimumPosition WRITE setMinimumPosition)
Q_PROPERTY(double maximumPosition READ maximumPosition WRITE setMaximumPosition)
Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
Q_PROPERTY(double tickInterval READ tickInterval WRITE setTickInterval)
Q_PROPERTY(QSlider::TickPosition tickPosition READ tickPosition WRITE setTickPosition)
Q_PROPERTY(bool symmetricMoves READ symmetricMoves WRITE setSymmetricMoves)
public:
// Superclass typedef
typedef QWidget Superclass;
/// Constructor, builds a ctkDoubleRangeSlider whose default values are the same
/// as ctkRangeSlider.
ctkDoubleRangeSlider( Qt::Orientation o, QWidget* par= 0 );
/// Constructor, builds a ctkDoubleRangeSlider whose default values are the same
/// as ctkRangeSlider.
ctkDoubleRangeSlider( QWidget* par = 0 );
/// Destructor
virtual ~ctkDoubleRangeSlider();
///
/// This property holds the single step.
/// The smaller of two natural steps that an abstract sliders provides and
/// typically corresponds to the user pressing an arrow key
/// \sa isValidStep()
void setSingleStep(double ss);
double singleStep()const;
/// Return true if the step can be handled by the slider, false otherwise.
/// An invalid step is a step that can't be used to convert from double
/// to int (too large or too small).
/// \sa singleStep
bool isValidStep(double step)const;
///
/// This property holds the interval between tickmarks.
/// This is a value interval, not a pixel interval. If it is 0, the slider
/// will choose between lineStep() and pageStep().
/// The default value is 0.
void setTickInterval(double ti);
double tickInterval()const;
///
/// This property holds the tickmark position for this slider.
/// The valid values are described by the QSlider::TickPosition enum.
/// The default value is QSlider::NoTicks.
void setTickPosition(QSlider::TickPosition position);
QSlider::TickPosition tickPosition()const;
///
/// This property holds the sliders's minimum value.
/// When setting this property, the maximum is adjusted if necessary to
/// ensure that the range remains valid. Also the slider's current values
/// are adjusted to be within the new range.
double minimum()const;
void setMinimum(double min);
///
/// This property holds the slider's maximum value.
/// When setting this property, the minimum is adjusted if necessary to
/// ensure that the range remains valid. Also the slider's current values
/// are adjusted to be within the new range.
double maximum()const;
void setMaximum(double max);
///
/// Sets the slider's minimum to min and its maximum to max.
/// If max is smaller than min, min becomes the only legal value.
void setRange(double min, double max);
///
/// This property holds the slider's current minimum value.
/// The slider forces the minimum value to be within the legal range:
/// minimum <= minvalue <= maxvalue <= maximum.
/// Changing the minimumValue also changes the minimumPosition.
double minimumValue() const;
///
/// This property holds the slider's current maximum value.
/// The slider forces the maximum value to be within the legal range:
/// minimum <= minvalue <= maxvalue <= maximum.
/// Changing the maximumValue also changes the maximumPosition.
double maximumValue() const;
///
/// This property holds the current slider minimum position.
/// If tracking is enabled (the default), this is identical to minimumValue.
double minimumPosition() const;
void setMinimumPosition(double minPos);
///
/// This property holds the current slider maximum position.
/// If tracking is enabled (the default), this is identical to maximumValue.
double maximumPosition() const;
void setMaximumPosition(double maxPos);
///
/// Utility function that set the minimum position and
/// maximum position at once.
void setPositions(double minPos, double maxPos);
///
/// This property holds whether slider tracking is enabled.
/// If tracking is enabled (the default), the slider emits the minimumValueChanged()
/// signal while the left/bottom handler is being dragged and the slider emits
/// the maximumValueChanged() signal while the right/top handler is being dragged.
/// If tracking is disabled, the slider emits the minimumValueChanged()
/// and maximumValueChanged() signals only when the user releases the slider.
void setTracking(bool enable);
bool hasTracking()const;
///
/// Triggers a slider action on the current slider. Possible actions are
/// SliderSingleStepAdd, SliderSingleStepSub, SliderPageStepAdd,
/// SliderPageStepSub, SliderToMinimum, SliderToMaximum, and SliderMove.
void triggerAction(QAbstractSlider::SliderAction action);
///
/// This property holds the orientation of the slider.
/// The orientation must be Qt::Vertical (the default) or Qt::Horizontal.
Qt::Orientation orientation()const;
void setOrientation(Qt::Orientation orientation);
///
/// When symmetricMoves is true, moving a handle will move the other handle
/// symmetrically, otherwise the handles are independent. False by default
bool symmetricMoves()const;
void setSymmetricMoves(bool symmetry);
#if defined(HAS_CTK_VALUE_PROXY)
/// Set/Get the value proxy of the internal range slider.
/// \sa setValueProxy(), valueProxy()
void setValueProxy(ctkValueProxy* proxy);
ctkValueProxy* valueProxy() const;
#endif
Q_SIGNALS:
///
/// This signal is emitted when the slider minimum value has changed,
/// with the new slider value as argument.
void minimumValueChanged(double minVal);
///
/// This signal is emitted when the slider maximum value has changed,
/// with the new slider value as argument.
void maximumValueChanged(double maxVal);
///
/// Utility signal that is fired when minimum or maximum values have changed.
void valuesChanged(double minVal, double maxVal);
///
/// This signal is emitted when sliderDown is true and the slider moves.
/// This usually happens when the user is dragging the minimum slider.
/// The value is the new slider minimum position.
/// This signal is emitted even when tracking is turned off.
void minimumPositionChanged(double minPos);
///
/// This signal is emitted when sliderDown is true and the slider moves.
/// This usually happens when the user is dragging the maximum slider.
/// The value is the new slider maximum position.
/// This signal is emitted even when tracking is turned off.
void maximumPositionChanged(double maxPos);
///
/// Utility signal that is fired when minimum or maximum positions
/// have changed.
void positionsChanged(double minPos, double maxPos);
///
/// This signal is emitted when the user presses one slider with the mouse,
/// or programmatically when setSliderDown(true) is called.
void sliderPressed();
///
/// This signal is emitted when the user releases one slider with the mouse,
/// or programmatically when setSliderDown(false) is called.
void sliderReleased();
///
/// This signal is emitted when the slider range has changed, with min being
/// the new minimum, and max being the new maximum.
/// Warning: don't confound with valuesChanged(double, double);
/// \sa QAbstractSlider::rangeChanged()
void rangeChanged(double min, double max);
public Q_SLOTS:
///
/// This property holds the slider's current minimum value.
/// The slider forces the minimum value to be within the legal range:
/// minimum <= minvalue <= maxvalue <= maximum.
/// Changing the minimumValue also changes the minimumPosition.
void setMinimumValue(double minVal);
///
/// This property holds the slider's current maximum value.
/// The slider forces the maximum value to be within the legal range:
/// minimum <= minvalue <= maxvalue <= maximum.
/// Changing the maximumValue also changes the maximumPosition.
void setMaximumValue(double maxVal);
///
/// Utility function that set the minimum value and maximum value at once.
void setValues(double minVal, double maxVal);
protected Q_SLOTS:
void onValuesChanged(int min, int max);
void onMinPosChanged(int value);
void onMaxPosChanged(int value);
void onPositionsChanged(int min, int max);
void onRangeChanged(int min, int max);
void onValueProxyAboutToBeModified();
void onValueProxyModified();
protected:
ctkRangeSlider* slider()const;
/// Subclasses can change the internal slider
void setSlider(ctkRangeSlider* slider);
protected:
QScopedPointer<ctkDoubleRangeSliderPrivate> d_ptr;
private:
Q_DECLARE_PRIVATE(ctkDoubleRangeSlider)
Q_DISABLE_COPY(ctkDoubleRangeSlider)
};
#endif
......@@ -33,7 +33,7 @@
#include <QToolTip>
// CTK includes
#include "ctkrangeslider.h"
#include "ctkRangeSlider.h"
// Minor cleanup of compiler warnings to include this as 3rdparty source code.
// Extra ';' after some Qt macros caused by '-Wpedantic' were removed.
......
......@@ -833,7 +833,7 @@ powershell -C "gci | % {rni $_.Name ($_.Name -replace '24px', '24')}"
"${workspaceRoot}/3rdparty/libigl/include",
"${workspaceRoot}/3rdparty/stb",
"${workspaceRoot}/3rdparty/warnings",
"${workspaceRoot}/3rdparty/widgets/ctkrangeslider",
"${workspaceRoot}/3rdparty/widgets/ctk",
"${workspaceRoot}/3rdparty/widgets/flowlayout",
"${workspaceRoot}/src/apps/3dforest",
"${workspaceRoot}/src/apps/tools/sandbox",
......
......@@ -84,34 +84,55 @@ static void segmentation(const std::string &path,
std::cout << ctx.points.size() << " initial points" << std::endl;
for (size_t i = 0; i < ctx.points.size(); i++)
{
std::cout << "point[" << i << "] index " << ctx.points[i].index
<< std::endl;
std::cout << "point[" << i << "] is " << ctx.points[i] << std::endl;
}
}
int main(int argc, char *argv[])
{
int rc;
globalLogThread = std::make_shared<LogThread>();
LoggerStdout logger;
globalLogThread->setCallback(&logger);
try
{
ArgumentParser arg;
arg.add("--input", "");
arg.add("--iterations", "");
arg.add("--count", "");
arg.add("--test-data", "");
arg.parse(argc, argv);
SegmentationL1Parameters parameters;
(void)arg.read("--count", parameters.initialSamplesCount);
(void)arg.read("--iterations", parameters.numberOfIterations);
if (arg.contains("--test-data"))
{
createTestDataset(arg.toString("--input"));
}
segmentation(arg.toString("--input"), parameters);
rc = 0;
}
catch (std::exception &e)
{
std::cerr << "error: " << e.what() << std::endl;
return 1;
rc = 1;
}
catch (...)
{
std::cerr << "error: unknown" << std::endl;
rc = 1;
}
return 0;
globalLogThread->setCallback(nullptr);
globalLogThread->stop();
return rc;
}
......@@ -58,6 +58,17 @@ void ArgumentParser::parse(int argc, char *argv[])
}
}
bool ArgumentParser::read(const std::string &name, int &value) const
{
if (contains(name))
{
value = toInt(name);
return true;
}
return false;
}
float ArgumentParser::toFloat(const std::string &name) const
{
return std::stof(toString(name));
......
......@@ -44,6 +44,7 @@ public:
void parse(int argc, char *argv[]);
bool contains(const std::string &name) const;
bool read(const std::string &name, int &value) const;
const std::string &toString(const std::string &name) const;
float toFloat(const std::string &name) const;
......
......@@ -194,3 +194,39 @@ void LogThread::run()
}
}
}
const char *LogMessage::typeString() const
{
return typeString(type);
}
const char *LogMessage::typeString(int type_)
{
switch (type_)
{
case LOG_TYPE_DEBUG:
return " DBG ";
case LOG_TYPE_WARNING:
return " WRN ";
case LOG_TYPE_ERROR:
return " ERR ";
case LOG_TYPE_INFO:
return " INF ";
default:
break;
}
return " N/A ";
}
void LoggerStdout::println(const LogMessage &message)
{
std::cout << message.time << " " << message.typeString() << " "
<< message.text << " [" << message.module << ":"
<< message.function << "]" << std::endl;
}
void LoggerStdout::flush()
{
// empty
}
......@@ -71,6 +71,9 @@ public:
function = function_;
text = text_;
}
const char *typeString() const;
static const char *typeString(int type_);
};
/** Log Thread Callback Interface. */
......@@ -82,6 +85,15 @@ public:
virtual void flush() = 0;
};
/** Logger For Standard Output. */
class EXPORT_CORE LoggerStdout : public LogThreadCallbackInterface
{
public:
virtual ~LoggerStdout() = default;
virtual void println(const LogMessage &message);
virtual void flush();
};
/** Log Thread. */
class EXPORT_CORE LogThread
{
......
......@@ -47,7 +47,8 @@ add_library(
${SOURCES_PROJECT_NAVIGATOR}
${SOURCES_SETTINGS}
${SOURCES_VIEWER}
../../3rdparty/widgets/ctkrangeslider/ctkrangeslider.cpp
../../3rdparty/widgets/ctk/ctkRangeSlider.cpp
../../3rdparty/widgets/ctk/ctkDoubleRangeSlider.cpp
../../3rdparty/widgets/flowlayout/flowlayout.cpp
resources/resources.qrc
../plugins/exportfile/resources/resources.qrc
......@@ -64,7 +65,7 @@ target_include_directories(
${SUB_PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_LIST_DIR}
../../3rdparty/widgets/ctkrangeslider
../../3rdparty/widgets/ctk
../../3rdparty/widgets/flowlayout
../plugins/exportfile
../plugins/help
......
/*
Copyright 2020 VUKOZ
This file is part of 3D Forest.
3D Forest is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
3D Forest is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with 3D Forest. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file DoubleRangeSliderWidget.cpp */
#include <DoubleRangeSliderWidget.hpp>
#include <MainWindow.hpp>
#include <ThemeIcon.hpp>
#include <QComboBox>
#include <QDoubleSpinBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QVBoxLayout>
#include <ctkDoubleRangeSlider.h>
#define LOG_MODULE_NAME "DoubleRangeSliderWidget"
#include <Log.hpp>
DoubleRangeSliderWidget::DoubleRangeSliderWidget()
: QWidget(),
slider_(nullptr),
minSpinBox_(nullptr),
maxSpinBox_(nullptr),
minimumValue_(0),
maximumValue_(0)
{
}
void DoubleRangeSliderWidget::setMinimum(double min)
{
LOG_DEBUG(<< "Called with parameter min <" << min << ">.");
minSpinBox_->setMinimum(min);
maxSpinBox_->setMinimum(min);
slider_->setMinimum(min);
minimumValue_ = min;
}
void DoubleRangeSliderWidget::setMaximum(double max)
{
LOG_DEBUG(<< "Called with parameter min <" << max << ">.");
minSpinBox_->setMaximum(max);
maxSpinBox_->setMaximum(max);
slider_->setMaximum(max);
maximumValue_ = max;
}
void DoubleRangeSliderWidget::setMinimumValue(double value)
{
LOG_DEBUG(<< "Called with parameter value <" << value << ">.");
minSpinBox_->setValue(value);
slider_->setMinimumValue(value);
minimumValue_ = value;
}
double DoubleRangeSliderWidget::minimumValue()
{
return minimumValue_;
}
void DoubleRangeSliderWidget::setMaximumValue(double value)
{
LOG_DEBUG(<< "Called with parameter value <" << value << ">.");
maxSpinBox_->setValue(value);
slider_->setMaximumValue(value);
maximumValue_ = value;
}
double DoubleRangeSliderWidget::maximumValue()
{
return maximumValue_;
}
void DoubleRangeSliderWidget::blockSignals(bool block)
{
minSpinBox_->blockSignals(block);
maxSpinBox_->blockSignals(block);
slider_->blockSignals(block);
}
void DoubleRangeSliderWidget::slotIntermediateMinimumValue(double v)
{
LOG_DEBUG(<< "Called with parameter value <" << v << ">.");
QObject *obj = sender();
if (obj == slider_)
{
minSpinBox_->blockSignals(true);
minSpinBox_->setValue(v);
minSpinBox_->blockSignals(false);
}
else if (obj == minSpinBox_)
{
slider_->blockSignals(true);
slider_->setMinimumValue(v);
slider_->blockSignals(false);
}
minimumValue_ = v;
emit signalIntermediateMinimumValue();
}
void DoubleRangeSliderWidget::slotIntermediateMaximumValue(double v)
{
LOG_DEBUG(<< "Called with parameter value <" << v << ">.");
QObject *obj = sender();
if (obj == slider_)
{
maxSpinBox_->blockSignals(true);
maxSpinBox_->setValue(v);
maxSpinBox_->blockSignals(false);
}
else if (obj == maxSpinBox_)
{
slider_->blockSignals(true);
slider_->setMaximumValue(v);
slider_->blockSignals(false);
}
maximumValue_ = v;
emit signalIntermediateMaximumValue();
}
void DoubleRangeSliderWidget::create(DoubleRangeSliderWidget *&outputWidget,
const QObject *receiver,
const char *memberIntermediateMinimumValue,
const char *memberIntermediateMaximumValue,
const QString &text,
const QString &toolTip,
const QString &unitsList,
double step,
double min,
double max,
double minValue,
double maxValue)
{
LOG_DEBUG(<< "Called with parameter min <" << min << ">"
<< " max <" << max << ">"
<< " minValue <" << minValue << ">"
<< " maxValue <" << maxValue << ">.");
outputWidget = new DoubleRangeSliderWidget();
outputWidget->minimumValue_ = minValue;
outputWidget->maximumValue_ = maxValue;
// Description Name
QLabel *label = new QLabel(text);
// Description Tool Tip
QLabel *help = new QLabel;
help->setToolTip(toolTip);
ThemeIcon helpIcon(":/gui/", "question");
help->setPixmap(helpIcon.pixmap(MainWindow::ICON_SIZE_TEXT));
// Description Units
QComboBox *units = new QComboBox;
units->addItem(unitsList);
// Description Layout
QHBoxLayout *descriptionLayout = new QHBoxLayout;
descriptionLayout->addWidget(label);
descriptionLayout->addWidget(help);
descriptionLayout->addStretch();
descriptionLayout->addWidget(units);
// Value Slider
outputWidget->slider_ = new ctkDoubleRangeSlider;
ctkDoubleRangeSlider *slider = outputWidget->slider_;
slider->setRange(min, max);
slider->setValues(minValue, maxValue);
slider->setSingleStep(step);
slider->setOrientation(Qt::Horizontal);
connect(slider,
SIGNAL(minimumPositionChanged(double)),
outputWidget,
SLOT(slotIntermediateMinimumValue(double)));
if (memberIntermediateMinimumValue)
{
connect(outputWidget,
SIGNAL(signalIntermediateMinimumValue()),
receiver,
memberIntermediateMinimumValue);
}
connect(slider,
SIGNAL(maximumPositionChanged(double)),
outputWidget,
SLOT(slotIntermediateMaximumValue(double)));
if (memberIntermediateMaximumValue)
{
connect(outputWidget,
SIGNAL(signalIntermediateMaximumValue()),
receiver,
memberIntermediateMaximumValue);
}
// Value SpinBox
outputWidget->minSpinBox_ = new QDoubleSpinBox;
QDoubleSpinBox *minSpinBox = outputWidget->minSpinBox_;
minSpinBox->setRange(min, max);
minSpinBox->setValue(minValue);
minSpinBox->setSingleStep(step);
connect(minSpinBox,
SIGNAL(valueChanged(double)),
outputWidget,
SLOT(slotIntermediateMinimumValue(double)));
outputWidget->maxSpinBox_ = new QDoubleSpinBox;
QDoubleSpinBox *maxSpinBox = outputWidget->maxSpinBox_;
maxSpinBox->setRange(min, max);
maxSpinBox->setValue(maxValue);
maxSpinBox->setSingleStep(step);
connect(maxSpinBox,
SIGNAL(valueChanged(double)),
outputWidget,
SLOT(slotIntermediateMaximumValue(double)));
// Value Layout
QHBoxLayout *valueLayout = new QHBoxLayout;
valueLayout->addWidget(new QLabel("Min"));
valueLayout->addWidget(minSpinBox);
valueLayout->addWidget(new QLabel("Max"));
valueLayout->addWidget(maxSpinBox);
// Group Description and Value
QVBoxLayout *groupLayout = new QVBoxLayout;
groupLayout->addLayout(descriptionLayout);
groupLayout->addWidget(slider);
groupLayout->addLayout(valueLayout);
outputWidget->setLayout(groupLayout);
}
/*
Copyright 2020 VUKOZ
This file is part of 3D Forest.
3D Forest is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
3D Forest is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with 3D Forest. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file DoubleRangeSliderWidget.hpp */
#ifndef DOUBLE_RANGE_SLIDER_WIDGET_HPP
#define DOUBLE_RANGE_SLIDER_WIDGET_HPP
#include <ExportGui.hpp>
#include <QWidget>
class ctkDoubleRangeSlider;
class QDoubleSpinBox;
class QVBoxLayout;
/** Range Slider Widget with values in double. */
class EXPORT_GUI DoubleRangeSliderWidget : public QWidget
{
Q_OBJECT
public:
DoubleRangeSliderWidget();
static void create(DoubleRangeSliderWidget *&outputWidget,
const QObject *receiver,
const char *memberIntermediateMinimumValue,
const char *memberIntermediateMaximumValue,
const QString &text,
const QString &toolTip,
const QString &unitsList,
double step,
double min,
double max,
double minValue,
double maxValue);
void setMinimum(double min);
void setMaximum(double max);
void setMinimumValue(double value);
double minimumValue();
void setMaximumValue(double value);
double maximumValue();
void blockSignals(bool block);
signals:
void signalIntermediateMinimumValue();
void signalIntermediateMaximumValue();
protected slots:
void slotIntermediateMinimumValue(double v);
void slotIntermediateMaximumValue(double v);
protected:
ctkDoubleRangeSlider *slider_;
QDoubleSpinBox *minSpinBox_;
QDoubleSpinBox *maxSpinBox_;
double minimumValue_;
double maximumValue_;
};
#endif /* DOUBLE_RANGE_SLIDER_WIDGET_HPP */
......@@ -29,7 +29,7 @@
#include <QSpinBox>
#include <QVBoxLayout>
#include <ctkrangeslider.h>
#include <ctkRangeSlider.h>
#define LOG_MODULE_NAME "RangeSliderWidget"
#include <Log.hpp>
......
......@@ -84,27 +84,8 @@ void LoggerWindow::slotPrintln(const QString &time,
const QString &module,
const QString &function)
{
const char *messageType = " ";
switch (type)
{
case LOG_TYPE_DEBUG:
messageType = " DBG ";
break;
case LOG_TYPE_WARNING:
messageType = " WRN ";
break;
case LOG_TYPE_ERROR:
messageType = " ERR ";
break;
case LOG_TYPE_INFO:
messageType = " INF ";
break;
default:
break;
}
textEdit_->append(time + messageType + text + " [" + module + ":" +
function + "]");
textEdit_->append(time + QString(LogMessage::typeString(type)) + text +
" [" + module + ":" + function + "]");
}
static void loggerWindowQtMessageHandler(QtMsgType type,
......
......@@ -21,9 +21,9 @@
#include <Region.hpp>
#include <DoubleRangeSliderWidget.hpp>
#include <MainWindow.hpp>
#include <ProjectNavigatorItemClipping.hpp>
#include <RangeSliderWidget.hpp>
#include <ThemeIcon.hpp>
#include <QHBoxLayout>
......@@ -44,44 +44,47 @@ ProjectNavigatorItemClipping::ProjectNavigatorItemClipping(
LOG_DEBUG(<< "Called.");
// Input widgets
RangeSliderWidget::create(rangeInput_[0],
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("X range"),
tr("Min-max clipping range filter along X axis"),
tr("pt"),
1,
0,
100,
0,
100);
RangeSliderWidget::create(rangeInput_[1],
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Y range"),
tr("Min-max clipping range filter along Y axis"),
tr("pt"),
1,
0,
100,
0,
100);
RangeSliderWidget::create(rangeInput_[2],
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Z range"),
tr("Min-max clipping range filter along Z axis"),
tr("pt"),
1,
0,
100,
0,
100);
DoubleRangeSliderWidget::create(
rangeInput_[0],
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("X range"),
tr("Min-max clipping range filter along X axis"),
tr("pt"),
1,
0,
100,
0,
100);
DoubleRangeSliderWidget::create(
rangeInput_[1],
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Y range"),
tr("Min-max clipping range filter along Y axis"),
tr("pt"),
1,
0,
100,
0,
100);
DoubleRangeSliderWidget::create(
rangeInput_[2],
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Z range"),
tr("Min-max clipping range filter along Z axis"),
tr("pt"),
1,
0,
100,
0,
100);
resetButton_ = new QPushButton(tr("&Reset"), this);
connect(resetButton_, SIGNAL(clicked()), this, SLOT(reset()));
......@@ -154,7 +157,7 @@ void ProjectNavigatorItemClipping::slotRangeIntermediateMinimumValue()
{
if (obj == rangeInput_[i])
{
int v = rangeInput_[i]->minimumValue();
double v = rangeInput_[i]->minimumValue();
LOG_DEBUG(<< "Input minimumValue <" << v << ">.");
clipRange_[i].setMinimumValue(v);
}
......@@ -171,7 +174,7 @@ void ProjectNavigatorItemClipping::slotRangeIntermediateMaximumValue()
{
if (obj == rangeInput_[i])
{
int v = rangeInput_[i]->maximumValue();
double v = rangeInput_[i]->maximumValue();
LOG_DEBUG(<< "Input maximumValue <" << v << ">.");
clipRange_[i].setMaximumValue(v);
}
......
......@@ -27,7 +27,7 @@
#include <Range.hpp>
class MainWindow;
class RangeSliderWidget;
class DoubleRangeSliderWidget;
class QPushButton;
......@@ -58,7 +58,7 @@ public slots:
void reset();
protected:
RangeSliderWidget *rangeInput_[3];
DoubleRangeSliderWidget *rangeInput_[3];
QPushButton *resetButton_;
Range<double> clipRange_[3];
......
......@@ -19,9 +19,9 @@
/** @file ProjectNavigatorItemDensity.cpp */
#include <DoubleRangeSliderWidget.hpp>
#include <MainWindow.hpp>
#include <ProjectNavigatorItemDensity.hpp>
#include <RangeSliderWidget.hpp>
#include <QVBoxLayout>
......@@ -31,18 +31,18 @@ ProjectNavigatorItemDensity::ProjectNavigatorItemDensity(MainWindow *mainWindow,
: ProjectNavigatorItem(mainWindow, icon, text)
{
// Input widgets
RangeSliderWidget::create(densityInput_,
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Density"),
tr("Min-max density range filter"),
tr("pt"),
1,
0,
100,
0,
100);
DoubleRangeSliderWidget::create(densityInput_,
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Density"),
tr("Min-max density range filter"),
tr("pt"),
1,
0,
100,
0,
100);
// Layout
QVBoxLayout *mainLayout = new QVBoxLayout;
......@@ -83,13 +83,15 @@ void ProjectNavigatorItemDensity::slotUpdate(void *sender,
void ProjectNavigatorItemDensity::slotRangeIntermediateMinimumValue()
{
densityRange_.setMinimumValue(densityInput_->minimumValue() * 0.0039216F);
densityRange_.setMinimumValue(
static_cast<float>(densityInput_->minimumValue()) * 0.0039216F);
densityInputChanged();
}
void ProjectNavigatorItemDensity::slotRangeIntermediateMaximumValue()
{
densityRange_.setMaximumValue(densityInput_->maximumValue() * 0.0039216F);
densityRange_.setMaximumValue(
static_cast<float>(densityInput_->maximumValue()) * 0.0039216F);
densityInputChanged();
}
......
......@@ -27,7 +27,7 @@
#include <Range.hpp>
class MainWindow;
class RangeSliderWidget;
class DoubleRangeSliderWidget;
/** Project Navigator Density. */
class ProjectNavigatorItemDensity : public ProjectNavigatorItem
......@@ -56,7 +56,7 @@ public slots:
void slotRangeIntermediateMaximumValue();
protected:
RangeSliderWidget *densityInput_;
DoubleRangeSliderWidget *densityInput_;
Range<float> densityRange_;
void densityInputChanged();
......
......@@ -19,9 +19,9 @@
/** @file ProjectNavigatorItemDescriptor.cpp */
#include <DoubleRangeSliderWidget.hpp>
#include <MainWindow.hpp>
#include <ProjectNavigatorItemDescriptor.hpp>
#include <RangeSliderWidget.hpp>
#include <QVBoxLayout>
......@@ -32,18 +32,18 @@ ProjectNavigatorItemDescriptor::ProjectNavigatorItemDescriptor(
: ProjectNavigatorItem(mainWindow, icon, text)
{
// Input widgets
RangeSliderWidget::create(descriptorInput_,
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Descriptor"),
tr("Min-max descriptor range filter"),
tr("pt"),
1,
0,
100,
0,
100);
DoubleRangeSliderWidget::create(descriptorInput_,
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Descriptor"),
tr("Min-max descriptor range filter"),
tr("pt"),
1,
0,
100,
0,
100);
// Layout
QVBoxLayout *mainLayout = new QVBoxLayout;
......@@ -87,15 +87,15 @@ void ProjectNavigatorItemDescriptor::slotUpdate(
void ProjectNavigatorItemDescriptor::slotRangeIntermediateMinimumValue()
{
descriptorRange_.setMinimumValue(descriptorInput_->minimumValue() *
0.0039216F);
descriptorRange_.setMinimumValue(
static_cast<float>(descriptorInput_->minimumValue()) * 0.0039216F);
descriptorInputChanged();
}
void ProjectNavigatorItemDescriptor::slotRangeIntermediateMaximumValue()
{
descriptorRange_.setMaximumValue(descriptorInput_->maximumValue() *
0.0039216F);
descriptorRange_.setMaximumValue(
static_cast<float>(descriptorInput_->maximumValue()) * 0.0039216F);
descriptorInputChanged();
}
......
......@@ -27,7 +27,7 @@
#include <Range.hpp>
class MainWindow;
class RangeSliderWidget;
class DoubleRangeSliderWidget;
/** Project Navigator Descriptor. */
class ProjectNavigatorItemDescriptor : public ProjectNavigatorItem
......@@ -56,7 +56,7 @@ public slots:
void slotRangeIntermediateMaximumValue();
protected:
RangeSliderWidget *descriptorInput_;
DoubleRangeSliderWidget *descriptorInput_;
Range<float> descriptorRange_;
void descriptorInputChanged();
......
......@@ -19,9 +19,9 @@
/** @file ProjectNavigatorItemElevation.cpp */
#include <DoubleRangeSliderWidget.hpp>
#include <MainWindow.hpp>
#include <ProjectNavigatorItemElevation.hpp>
#include <RangeSliderWidget.hpp>
#include <QVBoxLayout>
......@@ -32,18 +32,18 @@ ProjectNavigatorItemElevation::ProjectNavigatorItemElevation(
: ProjectNavigatorItem(mainWindow, icon, text)
{
// Input widgets
RangeSliderWidget::create(rangeInput_,
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Elevation"),
tr("Min-max elevation range filter"),
tr("pt"),
1,
0,
100,
0,
100);
DoubleRangeSliderWidget::create(rangeInput_,
this,
SLOT(slotRangeIntermediateMinimumValue()),
SLOT(slotRangeIntermediateMaximumValue()),
tr("Elevation"),
tr("Min-max elevation range filter"),
tr("pt"),
1,
0,
100,
0,
100);
// Layout
QVBoxLayout *mainLayout = new QVBoxLayout;
......
......@@ -27,7 +27,7 @@
#include <Range.hpp>
class MainWindow;
class RangeSliderWidget;
class DoubleRangeSliderWidget;
/** Project Navigator Elevation. */
class ProjectNavigatorItemElevation : public ProjectNavigatorItem
......@@ -56,7 +56,7 @@ public slots:
void slotRangeIntermediateMaximumValue();
protected:
RangeSliderWidget *rangeInput_;
DoubleRangeSliderWidget *rangeInput_;
Range<double> elevationRange_;
void elevationInputChanged();
......
......@@ -23,6 +23,7 @@
#include <SegmentationL1.hpp>
#define LOG_MODULE_NAME "SegmentationL1"
#define LOG_MODULE_DEBUG_ENABLED 1
#include <Log.hpp>
SegmentationL1::SegmentationL1(Editor *editor) : context_(editor)
......@@ -30,9 +31,10 @@ SegmentationL1::SegmentationL1(Editor *editor) : context_(editor)
LOG_DEBUG(<< "Create.");
// Add individual actions from first to last.
actions_.push_back(&actionCount_);
actions_.push_back(&actionRandom_);
actions_.push_back(&actionInitializePoints_);
tasks_.push_back(&taskCount_);
tasks_.push_back(&taskRandom_);
tasks_.push_back(&taskSample_);
tasks_.push_back(&taskMedian_);
clear();
}
......@@ -71,7 +73,7 @@ bool SegmentationL1::applyParameters(const SegmentationL1Parameters &parameters)
newAction = 0;
}
if (newAction < actions_.size())
if (newAction < tasks_.size())
{
// Restart algorithm calculation from corresponding action.
currentAction_ = newAction;
......@@ -88,13 +90,13 @@ bool SegmentationL1::next()
{
LOG_DEBUG(<< "Compute the next step.");
if (currentAction_ < actions_.size())
if (currentAction_ < tasks_.size())
{
// Compute one step in the current action.
actions_[currentAction_]->next();
tasks_[currentAction_]->next();
// Check if the current action is finished.
if (actions_[currentAction_]->end())
if (tasks_[currentAction_]->end())
{
// Yes, move to the next action.
currentAction_++;
......@@ -102,19 +104,19 @@ bool SegmentationL1::next()
}
}
return currentAction_ < actions_.size();
return currentAction_ < tasks_.size();
}
void SegmentationL1::progress(size_t &nTasks,
size_t &iTask,
double &percent) const
{
nTasks = actions_.size();
nTasks = tasks_.size();
if (currentAction_ < actions_.size())
if (currentAction_ < tasks_.size())
{
iTask = currentAction_;
percent = actions_[currentAction_]->percent();
percent = tasks_[currentAction_]->percent();
}
else
{
......@@ -125,8 +127,8 @@ void SegmentationL1::progress(size_t &nTasks,
void SegmentationL1::initializeCurrentAction()
{
if (currentAction_ < actions_.size())
if (currentAction_ < tasks_.size())
{
actions_[currentAction_]->initialize(&context_);
tasks_[currentAction_]->initialize(&context_);
}
}
......@@ -22,10 +22,11 @@
#ifndef SEGMENTATION_L1_HPP
#define SEGMENTATION_L1_HPP
#include <SegmentationL1ActionCount.hpp>
#include <SegmentationL1ActionInitializePoints.hpp>
#include <SegmentationL1ActionRandom.hpp>
#include <SegmentationL1Context.hpp>
#include <SegmentationL1TaskCount.hpp>
#include <SegmentationL1TaskMedian.hpp>
#include <SegmentationL1TaskRandom.hpp>
#include <SegmentationL1TaskSample.hpp>
class Editor;
/** Segmentation L1. */
......@@ -47,11 +48,12 @@ public:
private:
SegmentationL1Context context_;
SegmentationL1ActionCount actionCount_;
SegmentationL1ActionRandom actionRandom_;
SegmentationL1ActionInitializePoints actionInitializePoints_;
SegmentationL1TaskCount taskCount_;
SegmentationL1TaskRandom taskRandom_;
SegmentationL1TaskSample taskSample_;
SegmentationL1TaskMedian taskMedian_;
std::vector<SegmentationL1ActionInterface *> actions_;
std::vector<SegmentationL1TaskInterface *> tasks_;
size_t currentAction_;
void initializeCurrentAction();
......
......@@ -34,6 +34,7 @@ public:
int initialSamplesDensityMaximum;
int neighborhoodRadiusMinimum;
int neighborhoodRadiusMaximum;
int numberOfIterations;
SegmentationL1Parameters() { setDefault(); }
......@@ -44,6 +45,7 @@ public:
initialSamplesDensityMaximum = 0;
neighborhoodRadiusMinimum = 0;
neighborhoodRadiusMaximum = 0;
numberOfIterations = 0;
}
void setDefault()
......@@ -53,19 +55,22 @@ public:
initialSamplesDensityMaximum = 100;
neighborhoodRadiusMinimum = 100;
neighborhoodRadiusMaximum = 500;
numberOfIterations = 1;
}
void set(int initialSamplesCount_,
int initialSamplesDensityMinimum_,
int initialSamplesDensityMaximum_,
int neighborhoodRadiusMinimum_,
int neighborhoodRadiusMaximum_)
int neighborhoodRadiusMaximum_,
int numberOfIterations_)
{
initialSamplesCount = initialSamplesCount_;
initialSamplesDensityMinimum = initialSamplesDensityMinimum_;
initialSamplesDensityMaximum = initialSamplesDensityMaximum_;
neighborhoodRadiusMinimum = neighborhoodRadiusMinimum_;
neighborhoodRadiusMaximum = neighborhoodRadiusMaximum_;
numberOfIterations = numberOfIterations_;
}
};
......@@ -80,7 +85,8 @@ inline std::ostream &operator<<(std::ostream &os,
<< "> neighborhoodRadiusMinimum <"
<< obj.neighborhoodRadiusMinimum
<< "> neighborhoodRadiusMaximum <"
<< obj.neighborhoodRadiusMaximum << ">";
<< obj.neighborhoodRadiusMaximum << "> numberOfIterations <"
<< obj.numberOfIterations << ">";
}
#endif /* SEGMENTATION_L1_PARAMETERS_HPP */
......@@ -17,16 +17,16 @@
along with 3D Forest. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file SegmentationL1ActionCount.hpp */
/** @file SegmentationL1TaskCount.hpp */
#ifndef SEGMENTATION_L1_ACTION_COUNT_HPP
#define SEGMENTATION_L1_ACTION_COUNT_HPP
#ifndef SEGMENTATION_L1_TASK_COUNT_HPP
#define SEGMENTATION_L1_TASK_COUNT_HPP
#include <Editor.hpp>
#include <SegmentationL1ActionInterface.hpp>
#include <SegmentationL1TaskInterface.hpp>
/** Segmentation L1 Action Count. */
class SegmentationL1ActionCount : public SegmentationL1ActionInterface
/** Segmentation L1 Task Count. */
class SegmentationL1TaskCount : public SegmentationL1TaskInterface
{
public:
virtual void initialize(SegmentationL1Context *context)
......@@ -84,4 +84,4 @@ private:
SegmentationL1Context *context_;
};
#endif /* SEGMENTATION_L1_ACTION_COUNT_HPP */
#endif /* SEGMENTATION_L1_TASK_COUNT_HPP */
......@@ -17,23 +17,23 @@
along with 3D Forest. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file SegmentationL1ActionInterface.hpp */
/** @file SegmentationL1TaskInterface.hpp */
#ifndef SEGMENTATION_L1_ACTION_INTERFACE_HPP
#define SEGMENTATION_L1_ACTION_INTERFACE_HPP
#ifndef SEGMENTATION_L1_TASK_INTERFACE_HPP
#define SEGMENTATION_L1_TASK_INTERFACE_HPP
#include <ProgressActionInterface.hpp>
#include <SegmentationL1Context.hpp>
/** Segmentation L1 Action Interface. */
class SegmentationL1ActionInterface : public ProgressActionInterface
/** Segmentation L1 Task Interface. */
class SegmentationL1TaskInterface : public ProgressActionInterface
{
public:
SegmentationL1ActionInterface() : ProgressActionInterface(){};
virtual ~SegmentationL1ActionInterface() = default;
SegmentationL1TaskInterface() : ProgressActionInterface(){};
virtual ~SegmentationL1TaskInterface() = default;
virtual void initialize(SegmentationL1Context *context) = 0;
virtual void next() = 0;
};
#endif /* SEGMENTATION_L1_ACTION_INTERFACE_HPP */
#endif /* SEGMENTATION_L1_TASK_INTERFACE_HPP */
......@@ -17,26 +17,24 @@
along with 3D Forest. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file SegmentationL1ActionInitializePoints.hpp */
/** @file SegmentationL1TaskMedian.hpp */
#ifndef SEGMENTATION_L1_ACTION_INITIALIZE_POINTS_HPP
#define SEGMENTATION_L1_ACTION_INITIALIZE_POINTS_HPP
#ifndef SEGMENTATION_L1_TASK_MEDIAN_HPP
#define SEGMENTATION_L1_TASK_MEDIAN_HPP
#include <Editor.hpp>
#include <SegmentationL1ActionInterface.hpp>
#include <SegmentationL1TaskInterface.hpp>
/** Segmentation L1 Initialize Points. */
class SegmentationL1ActionInitializePoints
: public SegmentationL1ActionInterface
/** Segmentation L1 Task Median. */
class SegmentationL1TaskMedian : public SegmentationL1TaskInterface
{
public:
virtual void initialize(SegmentationL1Context *context)
{
context_ = context;
context_->query.reset();
index_ = 0;
ProgressActionInterface::initialize(context_->totalSamplesCount,
ProgressActionInterface::initialize(context_->initialSamplesCount,
1000UL);
}
......@@ -50,8 +48,6 @@ public:
while (i < n)
{
i++;
index_++;
if (timedOut())
{
break;
......@@ -63,7 +59,6 @@ public:
private:
SegmentationL1Context *context_;
size_t index_;
};
#endif /* SEGMENTATION_L1_ACTION_INITIALIZE_POINTS_HPP */
#endif /* SEGMENTATION_L1_TASK_MEDIAN_HPP */
......@@ -17,23 +17,22 @@
along with 3D Forest. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file SegmentationL1ActionRandom.hpp */
/** @file SegmentationL1TaskRandom.hpp */
#ifndef SEGMENTATION_L1_ACTION_RANDOM_HPP
#define SEGMENTATION_L1_ACTION_RANDOM_HPP
#ifndef SEGMENTATION_L1_TASK_RANDOM_HPP
#define SEGMENTATION_L1_TASK_RANDOM_HPP
#include <Editor.hpp>
#include <SegmentationL1ActionInterface.hpp>
#include <SegmentationL1TaskInterface.hpp>
/** Segmentation L1 Action Random. */
class SegmentationL1ActionRandom : public SegmentationL1ActionInterface
/** Segmentation L1 Task Random. */
class SegmentationL1TaskRandom : public SegmentationL1TaskInterface
{
public:
virtual void initialize(SegmentationL1Context *context)
{
context_ = context;
context_->query.reset();
index_ = 0;
uint64_t max = context_->totalSamplesCount;
size_t n = 0;
......@@ -50,6 +49,14 @@ public:
context_->initialSamplesCount = n;
context_->points.resize(n);
pointsIndex_ = 0;
dataFrom_ = 0;
dataStep_ = 0;
if (n > 0)
{
dataStep_ = context_->totalSamplesCount / n;
}
ProgressActionInterface::initialize(context_->initialSamplesCount,
1000UL);
}
......@@ -64,12 +71,13 @@ public:
while (i < n)
{
uint64_t r = static_cast<uint64_t>(rand());
r %= context_->totalSamplesCount;
context_->points[index_].index = r;
r = dataFrom_ + (r % dataStep_);
context_->points[pointsIndex_].index = r;
i++;
index_++;
pointsIndex_++;
dataFrom_ += dataStep_;
i++;
if (timedOut())
{
break;
......@@ -81,7 +89,9 @@ public:
private:
SegmentationL1Context *context_;
size_t index_;
size_t pointsIndex_;
uint64_t dataFrom_;
uint64_t dataStep_;
};
#endif /* SEGMENTATION_L1_ACTION_RANDOM_HPP */
#endif /* SEGMENTATION_L1_TASK_RANDOM_HPP */
/*
Copyright 2020 VUKOZ
This file is part of 3D Forest.
3D Forest is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
3D Forest is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with 3D Forest. If not, see <https://www.gnu.org/licenses/>.
*/
/** @file SegmentationL1TaskSample.hpp */
#ifndef SEGMENTATION_L1_TASK_SAMPLE_HPP
#define SEGMENTATION_L1_TASK_SAMPLE_HPP
#include <Editor.hpp>
#include <SegmentationL1TaskInterface.hpp>
/** Segmentation L1 Task Sample. */
class SegmentationL1TaskSample : public SegmentationL1TaskInterface
{
public:
virtual void initialize(SegmentationL1Context *context)
{
context_ = context;
context_->query.reset();
pointsIndex_ = 0;
dataIndex_ = 0;
ProgressActionInterface::initialize(context_->totalSamplesCount,
1000UL);
}
virtual void next()
{
uint64_t n = process();
uint64_t i = 0;
startTimer();
while (i < n)
{
if (pointsIndex_ < context_->points.size() &&
context_->query.next() &&
context_->points[pointsIndex_].index == dataIndex_)
{
context_->points[pointsIndex_].x = context_->query.x();
context_->points[pointsIndex_].y = context_->query.y();
context_->points[pointsIndex_].z = context_->query.z();
pointsIndex_++;
}
dataIndex_++;
i++;
if (timedOut())
{
break;
}
}
increment(i);
}
private:
SegmentationL1Context *context_;
size_t pointsIndex_;
uint64_t dataIndex_;
};
#endif /* SEGMENTATION_L1_TASK_SAMPLE_HPP */
......@@ -41,6 +41,7 @@ SegmentationL1Window::SegmentationL1Window(MainWindow *mainWindow)
initialSamplesCountInput_(nullptr),
initialSamplesDensityInput_(nullptr),
neighborhoodRadiusInput_(nullptr),
numberOfIterationsInput_(nullptr),
segmentationL1_(&mainWindow->editor())
{
LOG_DEBUG(<< "Create.");
......@@ -49,7 +50,7 @@ SegmentationL1Window::SegmentationL1Window(MainWindow *mainWindow)
SliderWidget::create(initialSamplesCountInput_,
this,
nullptr,
SLOT(slotInitialSamplesCountFinalValue()),
SLOT(slotParametersChanged()),
tr("Number of initial samples"),
tr("Number of initial samples"),
tr("%"),
......@@ -60,10 +61,11 @@ SegmentationL1Window::SegmentationL1Window(MainWindow *mainWindow)
RangeSliderWidget::create(initialSamplesDensityInput_,
this,
SLOT(slotInitialSamplesDensityMinimumValue()),
SLOT(slotInitialSamplesDensityMaximumValue()),
tr("Density range of initial samples"),
SLOT(slotParametersChanged()),
SLOT(slotParametersChanged()),
tr("Density range of initial samples"),
tr("Density range of initial samples"
" to filter out leaves"),
tr("%"),
1,
0,
......@@ -73,8 +75,8 @@ SegmentationL1Window::SegmentationL1Window(MainWindow *mainWindow)
RangeSliderWidget::create(neighborhoodRadiusInput_,
this,
SLOT(slotNeighborhoodRadiusMinimumValue()),
SLOT(slotNeighborhoodRadiusMaximumValue()),
SLOT(slotParametersChanged()),
SLOT(slotParametersChanged()),
tr("Neighborhood radius range"),
tr("Neighborhood radius range"),
tr("pt"),
......@@ -84,11 +86,24 @@ SegmentationL1Window::SegmentationL1Window(MainWindow *mainWindow)
parameters_.neighborhoodRadiusMinimum,
parameters_.neighborhoodRadiusMaximum);
SliderWidget::create(numberOfIterationsInput_,
this,
nullptr,
SLOT(slotParametersChanged()),
tr("Number of iterations"),
tr("Number of iterations"),
tr("cnt"),
1,
1,
100,
parameters_.numberOfIterations);
// Create layout with parameters.
QVBoxLayout *settingsLayout = new QVBoxLayout;
settingsLayout->addWidget(initialSamplesCountInput_);
settingsLayout->addWidget(initialSamplesDensityInput_);
settingsLayout->addWidget(initialSamplesCountInput_);
settingsLayout->addWidget(neighborhoodRadiusInput_);
settingsLayout->addWidget(numberOfIterationsInput_);
// Create widget layout.
QVBoxLayout *widgetLayout = new QVBoxLayout;
......@@ -110,7 +125,8 @@ bool SegmentationL1Window::applyParameters()
initialSamplesDensityInput_->minimumValue(),
initialSamplesDensityInput_->maximumValue(),
neighborhoodRadiusInput_->minimumValue(),
neighborhoodRadiusInput_->maximumValue());
neighborhoodRadiusInput_->maximumValue(),
numberOfIterationsInput_->value());
LOG_DEBUG(<< "Apply parameters <" << parameters_ << ">.");
......@@ -136,37 +152,8 @@ void SegmentationL1Window::updateData()
mainWindow_->update({Editor::TYPE_LAYER});
}
void SegmentationL1Window::slotInitialSamplesCountFinalValue()
{
LOG_DEBUG(<< "New value for the number of initial samples <"
<< initialSamplesCountInput_->value() << ">.");
emit signalParametersChanged();
}
void SegmentationL1Window::slotInitialSamplesDensityMinimumValue()
{
LOG_DEBUG(<< "New value for minimum density of initial samples <"
<< initialSamplesDensityInput_->minimumValue() << ">.");
emit signalParametersChanged();
}
void SegmentationL1Window::slotInitialSamplesDensityMaximumValue()
{
LOG_DEBUG(<< "New value for maximum density of initial samples <"
<< initialSamplesDensityInput_->maximumValue() << ">.");
emit signalParametersChanged();
}
void SegmentationL1Window::slotNeighborhoodRadiusMinimumValue()
{
LOG_DEBUG(<< "New value for minimum neighborhood radius <"
<< neighborhoodRadiusInput_->minimumValue() << ">.");
emit signalParametersChanged();
}
void SegmentationL1Window::slotNeighborhoodRadiusMaximumValue()
void SegmentationL1Window::slotParametersChanged()
{
LOG_DEBUG(<< "New value for maximum neighborhood radius <"
<< neighborhoodRadiusInput_->maximumValue() << ">.");
LOG_DEBUG(<< "New value for some input parameter.");
emit signalParametersChanged();
}
......@@ -47,11 +47,7 @@ public:
/**@}*/
protected slots:
void slotInitialSamplesCountFinalValue();
void slotInitialSamplesDensityMinimumValue();
void slotInitialSamplesDensityMaximumValue();
void slotNeighborhoodRadiusMinimumValue();
void slotNeighborhoodRadiusMaximumValue();
void slotParametersChanged();
private:
MainWindow *mainWindow_;
......@@ -59,6 +55,7 @@ private:
SliderWidget *initialSamplesCountInput_;
RangeSliderWidget *initialSamplesDensityInput_;
RangeSliderWidget *neighborhoodRadiusInput_;
SliderWidget *numberOfIterationsInput_;
SegmentationL1 segmentationL1_;
SegmentationL1Parameters parameters_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册