14 #include <QMainWindow>
15 #include <QMouseEvent>
17 #include <QSpacerItem>
65 m_meanDipDir_deg(-1.0),
67 m_densityColorScale(0),
68 m_densityColorScaleSteps(
76 m_trackMouseClick(false),
78 m_clickDipDir_deg(0.0),
79 m_clickDipSpan_deg(30.0),
80 m_clickDipDirSpan_deg(30.0),
84 QSizePolicy policy = sizePolicy();
85 policy.setHeightForWidth(
true);
86 setSizePolicy(policy);
96 double resolution_deg ) {
102 if (!entity)
return false;
106 pDlg.
setInfo(QObject::tr(
"Preparing polar display..."));
108 QApplication::processEvents();
119 count = facets.size();
123 count = planes.size();
132 if (!
count)
return false;
136 static_cast<unsigned>(
count));
140 densityGrid->
step_deg = resolution_deg;
141 densityGrid->
step_R = 0.02;
147 static_cast<unsigned>(
ceil(1.0 / densityGrid->
step_R));
150 static_cast<unsigned>(
ceil(360.0 / densityGrid->
step_deg));
152 unsigned cellCount = densityGrid->
rSteps * densityGrid->
ddSteps;
153 densityGrid->
grid =
new double[cellCount];
154 if (densityGrid->
grid) {
155 memset(densityGrid->
grid, 0,
sizeof(
double) * cellCount);
158 double surfaceSum = 0.0;
160 for (
size_t i = 0; i <
count; ++i) {
166 }
else if (facets.size() != 0)
171 }
else if (planes.size() != 0)
178 Nmean.
x +=
static_cast<double>(N.
x) * weight;
179 Nmean.
y +=
static_cast<double>(N.
y) * weight;
180 Nmean.
z +=
static_cast<double>(N.
z) * weight;
181 surfaceSum += weight;
190 unsigned iDipDir =
static_cast<unsigned>(
192 if (iDipDir == densityGrid->
ddSteps) iDipDir--;
195 double R = sin(dip_rad) / (1.0 + cos(dip_rad));
197 unsigned iR =
static_cast<unsigned>(
198 floor(
static_cast<double>(R) / densityGrid->
step_R));
199 if (iR == densityGrid->
rSteps) iR--;
201 densityGrid->
grid[iR + iDipDir * densityGrid->
rSteps] += weight;
211 if (surfaceSum > 0) {
238 for (
unsigned j = 1; j < cellCount; ++j) {
248 QApplication::processEvents();
265 if (e->button() == Qt::LeftButton) {
266 QRect contentRect = contentsRect();
267 QPoint pos = e->pos() - contentRect.topLeft();
269 int squareDistToCenter = AB.x() * AB.x() + AB.y() * AB.y();
274 90.0 * sqrt(
static_cast<double>(squareDistToCenter)) /
277 atan2(
static_cast<double>(AB.y()),
278 static_cast<double>(AB.x())));
296 double dipDirSpan_deg ) {
315 QLabel::paintEvent(
event);
316 QPainter painter(
this);
317 painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing,
322 pen.setStyle(Qt::SolidLine);
326 int halfW =
width() / 2;
328 QPoint center(halfW, halfH);
330 int hsvThickness = 0;
332 int newDiameter =
static_cast<int>(
ceil(0.9 * diameter));
333 hsvThickness = diameter - newDiameter;
336 if (hsvThickness > 0) {
337 QRect rectangle(center.x() - diameter / 2 + 1,
338 center.y() - diameter / 2 + 1, diameter - 2,
343 brush.setStyle(Qt::SolidPattern);
344 painter.setPen(Qt::NoPen);
347 unsigned ddSteps =
static_cast<unsigned>(
349 for (
unsigned j = 0; j < ddSteps; ++j) {
356 brush.setColor(QColor(
static_cast<int>(col.
r),
357 static_cast<int>(col.
g),
358 static_cast<int>(col.
b), 255));
359 painter.setBrush(brush);
361 int angle_start =
static_cast<int>(
364 painter.drawPie(rectangle, angle_start, angle_span);
368 diameter = newDiameter;
375 int radius = diameter / 2 - 2;
376 painter.drawEllipse(center, radius, radius);
377 painter.setBrush(Qt::NoBrush);
384 painter.drawLine(center - QPoint(radius, 0), center + QPoint(radius, 0));
385 painter.drawLine(center - QPoint(0, radius), center + QPoint(0, radius));
397 pen.setColor(Qt::gray);
399 for (
unsigned i = 1; i < dSteps; ++i) {
401 if (dip_deg < 90.0) {
402 int R =
static_cast<int>(radius * (dip_deg / 90.0));
403 if (R > 1) painter.drawEllipse(center, R - 1, R - 1);
409 for (
unsigned j = 1; j <= ddSteps * ticksFreq; ++j) {
411 if (dipDir_deg < 360.0) {
420 if ((j % ticksFreq) == 0)
421 painter.drawLine(center, center +
X);
423 painter.drawLine(center +
X * 0.93, center +
X);
435 brush.setStyle(Qt::SolidPattern);
436 painter.setPen(Qt::NoPen);
445 double cos_dipDir0 = cos(dipDir0_rad);
446 double sin_dipDir0 = sin(dipDir0_rad);
447 double cos_dipDir1 = cos(dipDir1_rad);
448 double sin_dipDir1 = sin(dipDir1_rad);
456 brush.setColor(QColor(
static_cast<int>(col->
r),
457 static_cast<int>(col->
g),
458 static_cast<int>(col->
b), 255));
459 painter.setBrush(brush);
467 center + QPoint(
static_cast<int>(sin_dipDir0 * R0),
468 -
static_cast<int>(cos_dipDir0 *
472 center + QPoint(
static_cast<int>(sin_dipDir0 * R1),
473 -
static_cast<int>(cos_dipDir0 *
477 center + QPoint(
static_cast<int>(sin_dipDir1 * R1),
478 -
static_cast<int>(cos_dipDir1 *
482 center + QPoint(
static_cast<int>(sin_dipDir1 * R0),
483 -
static_cast<int>(cos_dipDir1 *
486 painter.drawPolygon(poly);
498 QPoint
X(
static_cast<int>(
504 pen.setStyle(Qt::DashLine);
506 painter.drawLine(center, center +
X);
509 QPoint Y(
static_cast<int>(
515 pen.setStyle(Qt::SolidLine);
517 painter.drawLine(center - Y, center + Y);
529 painter.setBrush(Qt::NoBrush);
556 painter.drawLine(center + X0, center + X1);
575 painter.drawLine(center + X0, center + X1);
587 QRectF rect0(center.x() - R0, center.y() - R0, 2 * R0, 2 * R0);
588 painter.drawArc(rect0, angle_start, angle_span);
590 QRectF rect1(center.x() - R1, center.y() - R1, 2 * R1, 2 * R1);
591 painter.drawArc(rect1, angle_start, angle_span);
597 : QDialog(app ? app->getMainWindow() : 0),
600 m_colorScaleSelector(0),
602 m_facetGroupUniqueID(0) {
608 if (!
frame->layout())
frame->setLayout(
new QHBoxLayout());
618 QString::fromUtf8(
":/CC/plugin/qFacets/images/gearIcon.png"));
631 if (!colorRampGroupBox->layout())
632 colorRampGroupBox->setLayout(
new QHBoxLayout());
633 colorRampGroupBox->layout()->addItem(
new QSpacerItem(
643 connect(colorScaleStepsSpinBox, SIGNAL(valueChanged(
int)),
this,
645 connect(ticksFreqSpinBox, SIGNAL(valueChanged(
int)),
this,
647 connect(showHSVColorsCheckBox, SIGNAL(toggled(
bool)),
this,
651 connect(filterFacetsGroupBox, SIGNAL(toggled(
bool)),
this,
653 connect(dipSpanDoubleSpinBox, SIGNAL(valueChanged(
double)),
this,
655 connect(dipDirSpanDoubleSpinBox, SIGNAL(valueChanged(
double)),
this,
657 connect(dipDoubleSpinBox, SIGNAL(valueChanged(
double)),
this,
659 connect(dipDirDoubleSpinBox, SIGNAL(valueChanged(
double)),
this,
663 connect(exportPushButton, SIGNAL(clicked()),
this,
669 double resolution_deg ) {
675 double meanDipDir_deg, meanDip_deg;
678 meanDirLabel->setText(
685 bool filterModeEnabled = filterFacetsGroupBox->isChecked();
690 if (filterModeEnabled) {
699 if (filterFacetsGroupBox->isChecked()) {
707 dipSpanDoubleSpinBox->value(),
708 dipDirSpanDoubleSpinBox->value());
718 dipSpanDoubleSpinBox->value(),
719 dipDirSpanDoubleSpinBox->value());
728 dipDirDoubleSpinBox->value());
737 if (filterFacetsGroupBox->isChecked()) {
738 dipDoubleSpinBox->blockSignals(
true);
739 dipDirDoubleSpinBox->blockSignals(
true);
741 dipDoubleSpinBox->setValue(dip_deg);
742 dipDirDoubleSpinBox->setValue(dipDir_deg);
744 dipDoubleSpinBox->blockSignals(
false);
745 dipDirDoubleSpinBox->blockSignals(
false);
777 if (facets.empty())
return;
779 for (
size_t i = 0; i < facets.size(); ++i) {
788 double dDip =
fabs(dip - dipFilter);
789 double dDipDir =
fabs(dipDir - dipDirFilter);
792 ((dDip <= halfDipSpan || dDip >= 360.0 - halfDipSpan) &&
793 (dDipDir <= halfDipDirSpan ||
794 dDipDir >= 360.0 - halfDipDirSpan));
820 if (
count == 0)
return;
827 assert(!visTable.empty());
829 for (
unsigned i = 0; i < static_cast<unsigned>(
count); ++i) {
834 double dDip =
fabs(dip - dipFilter);
835 double dDipDir =
fabs(dipDir - dipDirFilter);
838 ((dDip <= halfDipSpan || dDip >= 360.0 - halfDipSpan) &&
839 (dDipDir <= halfDipDirSpan ||
840 dDipDir >= 360.0 - halfDipDirSpan));
872 QString selectionSuffix = QString(
" [dip=(%1 - %2)][dipDir=(%3 - %4)]")
873 .arg(dipFilter - halfDipSpan)
874 .arg(dipFilter + halfDipSpan)
875 .arg(dipDirFilter - halfDipDirSpan)
876 .arg(dipDirFilter + halfDipDirSpan);
882 if (facets.empty())
return;
886 for (
size_t i = 0; i < facets.size(); ++i) {
893 double dDip =
fabs(dip - dipFilter);
894 double dDipDir =
fabs(dipDir - dipDirFilter);
897 ((dDip <= halfDipSpan || dDip >= 360.0 - halfDipSpan) &&
898 (dDipDir <= halfDipDirSpan ||
899 dDipDir >= 360.0 - halfDipDirSpan));
903 if (facetClone) newGroup->
addChild(facetClone);
922 if (subset->
size() != 0) {
939 static_cast<unsigned>(value));
962 unsigned steps =
static_cast<unsigned>(colorScaleStepsSpinBox->value());
constexpr unsigned char POINT_VISIBLE
constexpr unsigned char POINT_HIDDEN
float PointCoordinateType
Type of the coordinates of a (N-D) point.
boost::geometry::model::polygon< point_xy > polygon
unsigned rSteps
Dimension (X)
double step_deg
Grid step along Y (in degrees)
~FacetDensityGrid()
Destructor.
double step_R
Grid step along X (in unit)
FacetDensityGrid()
Default constructor.
double minMaxDensity[2]
Min/max density.
unsigned ddSteps
Dimension (Y)
static void GenerateSubfamilyColor(ecvColor::Rgb &col, double dip, double dipDir, unsigned subFamilyIndex, unsigned subFamilyCount, ecvColor::Rgb *darkCol=0)
Generates a given sub-family color.
Dialog for displaying the angular repartition of facets (qFacets plugin)
void onTicksFreqChanged(int)
ecvMainAppInterface * m_app
Main application interface.
void updateFacetsFilter(bool enable)
ccColorScaleSelector * m_colorScaleSelector
Color scale selector/editor.
void closeEvent(QCloseEvent *e)
void onFilterCenterChanged(double)
StereogramDialog(ecvMainAppInterface *app)
Default constructor.
void onDensityColorStepsChanged(int)
void colorScaleChanged(int)
void onFilterEnabled(bool)
void onPointClicked(double, double)
int m_facetGroupUniqueID
Associated set of facets (unique ID)
void spawnColorScaleEditor()
void exportCurrentSelection()
bool init(double angularStep_deg, ccHObject *facetGroup, double resolution_deg=2.0)
Inits dialog.
void onFilterSizeChanged(double)
void onHSVColorsToggled(bool)
StereogramWidget * m_classifWidget
Associated widget.
void normalize()
Sets vector norm to unity.
Dialog to edit/create color scales.
ccColorScale::Shared getActiveScale()
Returns active scale.
Advanced editor for color scales.
void init()
Inits selector with the Color Scales Manager.
void setSelectedScale(QString uuid)
Sets selected combo box item (scale) by UUID.
ccColorScale::Shared getSelectedScale() const
Returns currently selected color scale.
static const unsigned MIN_STEPS
Minimum number of steps.
QSharedPointer< ccColorScale > Shared
Shared pointer type.
static const unsigned MAX_STEPS
Maximum number of steps (internal representation)
Color scales manager/container.
static ccColorScale::Shared GetDefaultScale(DEFAULT_SCALES scale=BGYR)
Returns a pre-defined color scale (static shortcut)
void toPersistentSettings() const
Save custom color scales to persistent settings.
ccColorScale::Shared getDefaultScale(DEFAULT_SCALES scale) const
Returns a pre-defined color scale.
virtual void setVisible(bool state)
Sets entity visibility.
virtual void setRedraw(bool state)
Sets entity redraw mode.
ccFacet * clone() const
Clones this facet.
ccMesh * getPolygon()
Returns polygon mesh (if any)
double getSurface() const
Returns associated surface area.
ccPolyline * getContour()
Returns contour polyline (if any)
CCVector3 getNormal() const override
Returns the entity normal.
A 3D cloud interface with associated features (color, normals, octree, etc.)
virtual bool isVisibilityTableInstantiated() const
Returns whether the visibility array is allocated or not.
virtual VisibilityTableType & getTheVisibilityArray()
Returns associated visibility array.
virtual bool resetVisibilityArray()
Resets the associated visibility array.
std::vector< unsigned char > VisibilityTableType
Array of "visibility" information for each point.
virtual void unallocateVisibilityArray()
Erases the points visibility information.
Hierarchical CLOUDVIEWER Object.
ccHObject * find(unsigned uniqueID)
Finds an entity in this object hierarchy.
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.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
static QString ConvertDipAndDipDirToString(PointCoordinateType dip_deg, PointCoordinateType dipDir_deg)
Converts geological 'dip direction & dip' parameters to a string.
static void ConvertNormalToDipAndDipDir(const CCVector3 &N, PointCoordinateType &dip_deg, PointCoordinateType &dipDir_deg)
Converts a normal vector to geological 'dip direction & dip' parameters.
virtual QString getName() const
Returns object name.
virtual unsigned getUniqueID() const
Returns object unique ID.
bool isA(CV_CLASS_ENUM type) const
virtual void setName(const QString &name)
Sets object name.
CCVector3 getNormal() const override
Returns the entity normal.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool hasNormals() const override
Returns whether normals are enabled or not.
ccGenericPointCloud * createNewCloudFromVisibilitySelection(bool removeSelectedPoints=false, VisibilityTableType *visTable=nullptr, std::vector< int > *newIndexesOfRemainingPoints=nullptr, bool silent=false, cloudViewer::ReferenceCloud *selection=nullptr) override
const CCVector3 & getPointNormal(unsigned pointIndex) const override
Returns normal corresponding to a given point.
void setWidth(PointCoordinateType width)
Sets the width of the line.
virtual unsigned size() const =0
Returns the number of points.
bool oneStep()
Increments total progress value of a single unit.
unsigned size() const override
Main application interface (for plugins)
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual QMainWindow * getMainWindow()=0
Returns main window.
virtual void refreshAll(bool only2D=false, bool forceRedraw=true)=0
Redraws all GL windows that have the 'refresh' flag on.
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
virtual ccColorScalesManager * getColorScalesManager()=0
Returns color scale manager (unique instance)
Graphical progress indicator (thread-safe)
virtual void stop() override
Notifies the fact that the process has ended.
virtual void start() override
virtual void setInfo(const char *infoStr) override
Notifies some information about the ongoing process.
virtual void setMethodTitle(const char *methodTitle) override
Notifies the algorithm title.
__host__ __device__ float2 fabs(float2 v)
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...
MiniVec< float, N > floor(const MiniVec< float, N > &a)
MiniVec< float, N > ceil(const MiniVec< float, N > &a)
float RadiansToDegrees(int radians)
Convert radians to degrees.
float DegreesToRadians(int degrees)
Convert degrees to radians.
constexpr Rgb black(0, 0, 0)
constexpr Rgb magenta(MAX, 0, MAX)
constexpr Rgb white(MAX, MAX, MAX)
constexpr Rgb red(MAX, 0, 0)