add qad_graphic3d library
scatter3d widget
This commit is contained in:
90
libs/graphic3d/scatter3d.h
Normal file
90
libs/graphic3d/scatter3d.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
QAD - Qt ADvanced
|
||||
|
||||
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program 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 Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SCATTER_H
|
||||
#define SCATTER_H
|
||||
|
||||
#include "qad_graphic3d_export.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtDataVisualization/QAbstract3DSeries>
|
||||
|
||||
namespace QtDataVisualization {
|
||||
class Q3DScatter;
|
||||
class QScatterDataProxy;
|
||||
class QScatter3DSeries;
|
||||
} // namespace QtDataVisualization
|
||||
|
||||
class QAD_GRAPHIC3D_EXPORT Scatter3D: public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
using Mesh = QtDataVisualization::QAbstract3DSeries::Mesh;
|
||||
|
||||
Q_PROPERTY(int currentGraphic READ currentGraphic WRITE setCurrentGraphic)
|
||||
Q_PROPERTY(int graphicsCount READ graphicsCount WRITE setGraphicsCount)
|
||||
Q_PROPERTY(QColor graphicColor READ graphicColor WRITE setGraphicColor)
|
||||
Q_PROPERTY(float graphicPointSize READ graphicPointSize WRITE setGraphicPointSize)
|
||||
Q_PROPERTY(Mesh graphicMesh READ graphicMesh WRITE setGraphicMesh)
|
||||
Q_PROPERTY(bool labelAutoRotation READ labelAutoRotation WRITE setLabelAutoRotation)
|
||||
|
||||
public:
|
||||
explicit Scatter3D(QWidget * parent = nullptr);
|
||||
~Scatter3D();
|
||||
|
||||
int currentGraphic() const { return curGraphic; }
|
||||
int graphicsCount() const { return graphics.size(); }
|
||||
QColor graphicColor() const { return graphicColor(curGraphic); }
|
||||
QColor graphicColor(int index) const;
|
||||
float graphicPointSize() const { return graphicPointSize(curGraphic); }
|
||||
float graphicPointSize(int index) const;
|
||||
Mesh graphicMesh() const { return graphicMesh(curGraphic); }
|
||||
Mesh graphicMesh(int index) const;
|
||||
bool labelAutoRotation() const;
|
||||
|
||||
public slots:
|
||||
void setCurrentGraphic(int arg);
|
||||
void setGraphicsCount(int count);
|
||||
void setGraphicColor(const QColor & color, int index);
|
||||
void setGraphicColor(const QColor & color) { setGraphicColor(color, curGraphic); }
|
||||
void setGraphicPointSize(float sz, int index);
|
||||
void setGraphicPointSize(float sz) { setGraphicPointSize(sz, curGraphic); }
|
||||
void setGraphicMesh(Mesh mesh, int index);
|
||||
void setGraphicMesh(Mesh mesh) { setGraphicMesh(mesh, curGraphic); }
|
||||
void addGraphic(const QColor & color = Qt::darkBlue, float pointSize = 1.f, Mesh mesh = Mesh::MeshSphere);
|
||||
void clear() { setGraphicsCount(0); }
|
||||
void setLabelAutoRotation(bool on);
|
||||
void setGraphicData(const QVector<QVector3D> & points, int index);
|
||||
void setGraphicData(const QVector<QVector3D> & points) { setGraphicData(points, curGraphic); }
|
||||
void addPoint(const QVector3D & point, int index);
|
||||
void addPoint(const QVector3D & point) { addPoint(point, curGraphic); }
|
||||
|
||||
private:
|
||||
struct Scatter3DGraphic {
|
||||
QtDataVisualization::QScatter3DSeries * series;
|
||||
QtDataVisualization::QScatterDataProxy * data;
|
||||
};
|
||||
|
||||
QWidget * container;
|
||||
QtDataVisualization::Q3DScatter * canvas;
|
||||
QVector<Scatter3DGraphic> graphics;
|
||||
|
||||
int curGraphic;
|
||||
};
|
||||
|
||||
#endif // SCATTER_H
|
||||
Reference in New Issue
Block a user