parent
1486954791
commit
9f2976be43
@ -1,27 +0,0 @@
|
||||
#ifndef AOI_H
|
||||
#define AOI_H
|
||||
|
||||
//
|
||||
#include "basicgeometryoperator.h"
|
||||
#include "contour.h"
|
||||
|
||||
|
||||
//std
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
|
||||
//Qt
|
||||
#include <QColor>
|
||||
#include <QLineF>
|
||||
|
||||
class aoi : public BasicGeometryOperator
|
||||
{
|
||||
public:
|
||||
aoi();
|
||||
|
||||
private:
|
||||
// Outline outline;
|
||||
};
|
||||
|
||||
#endif // AOI_H
|
@ -1,36 +0,0 @@
|
||||
#ifndef BASICGEOMETRY_H
|
||||
#define BASICGEOMETRY_H
|
||||
|
||||
|
||||
class BasicGeometry
|
||||
{
|
||||
public:
|
||||
BasicGeometry();
|
||||
virtual void set_color(int red,int green, int blue)=0;
|
||||
|
||||
virtual void set_unit(QString unit)=0;
|
||||
|
||||
virtual void set_move(bool isMove)=0;
|
||||
|
||||
|
||||
// points
|
||||
virtual void add_points(int x,int y)=0;
|
||||
virtual int get_point_id()=0;
|
||||
virtual void remove_by_id()=0;// 删除一个点之后,是否遍历拓扑表删除和这个点相关的所有数据
|
||||
|
||||
// topology
|
||||
virtual void add_topology()=0;
|
||||
virtual int get_topology_id()=0;
|
||||
virtual void remove_by_id()=0;
|
||||
|
||||
// rgb
|
||||
virtual int red()=0;
|
||||
virtual int green()=0;
|
||||
virtual int blue()=0;
|
||||
|
||||
virtual QString unit()=0;
|
||||
virtual bool isMove()=0;
|
||||
|
||||
};
|
||||
|
||||
#endif // BASICGEOMETRY_H
|
@ -1,14 +0,0 @@
|
||||
#ifndef BASICGEOMETRYOPERATOR_H
|
||||
#define BASICGEOMETRYOPERATOR_H
|
||||
|
||||
|
||||
class BasicGeometryOperator
|
||||
{
|
||||
public:
|
||||
virtual void paint()=0;
|
||||
virtual void saveData()=0;
|
||||
virtual void pick()=0;// 点、线、单元,区域 四种拾取
|
||||
virtual void move()=0;
|
||||
};
|
||||
|
||||
#endif // BASICGEOMETRYOPERATOR_H
|
@ -0,0 +1,122 @@
|
||||
#ifndef BITMAP_H
|
||||
#define BITMAP_H
|
||||
|
||||
|
||||
|
||||
//Qt
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPaintEvent>
|
||||
#include <QVector>
|
||||
#include <QPainterPathStroker>
|
||||
#include <QPen>
|
||||
#include <QWidget>
|
||||
#include <QPaintEngine>
|
||||
#include <QPoint>
|
||||
#include <QBitmap>
|
||||
#include <QPixmap>
|
||||
#include <QDebug>
|
||||
#include <QIODevice>
|
||||
#include <QDir>
|
||||
#include <QCursor>
|
||||
class Bitmap
|
||||
{
|
||||
public:
|
||||
Bitmap(const QPoint& topLeft,const QPoint& bottomRight,QString fileName=nullptr){
|
||||
_topLeft = topLeft;
|
||||
_bottomRight = bottomRight;
|
||||
_scaley = 1;
|
||||
_scalex = 1;
|
||||
|
||||
// TODO 需要加入文件检测判断文件是否存在
|
||||
_pixmap = QPixmap(fileName);
|
||||
|
||||
}
|
||||
|
||||
Bitmap(){
|
||||
_scaley = 1;
|
||||
_scalex = 1;
|
||||
_pixmap = QPixmap();
|
||||
}
|
||||
|
||||
void paint(QPixmap& w, QPaintEvent *event=nullptr){
|
||||
|
||||
QPainter painter;
|
||||
painter.begin(&w);
|
||||
QPoint center = QPoint((_topLeft.x()+_bottomRight.x())/2/_scalex,(_topLeft.y()+_bottomRight.y())/2/_scaley);
|
||||
QPixmap p;
|
||||
center -= QPoint(_pixmap.width()/2,_pixmap.height()/2);
|
||||
painter.scale(_scalex,_scaley);
|
||||
painter.drawPixmap(center,_pixmap);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
QPoint topLeft() const
|
||||
{
|
||||
return _topLeft;
|
||||
}
|
||||
|
||||
void setTopLeft(const QPoint &topLeft)
|
||||
{
|
||||
_topLeft = topLeft;
|
||||
}
|
||||
|
||||
QPoint bottomRight() const
|
||||
{
|
||||
return _bottomRight;
|
||||
}
|
||||
|
||||
void setBottomRight(const QPoint &bottomRight)
|
||||
{
|
||||
_bottomRight = bottomRight;
|
||||
}
|
||||
|
||||
double scalex() const
|
||||
{
|
||||
return _scalex;
|
||||
}
|
||||
|
||||
void setScalex(double scalex)
|
||||
{
|
||||
_scalex = scalex;
|
||||
}
|
||||
|
||||
double scaley() const
|
||||
{
|
||||
return _scaley;
|
||||
}
|
||||
|
||||
void setScaley(double scaley)
|
||||
{
|
||||
_scaley = scaley;
|
||||
}
|
||||
|
||||
QPixmap getPixmap() const
|
||||
{
|
||||
return _pixmap;
|
||||
}
|
||||
|
||||
void setPixmap(const QPixmap &value)
|
||||
{
|
||||
_pixmap = value;
|
||||
}
|
||||
void setPixmap(const QString& fileName)
|
||||
{
|
||||
_pixmap = QPixmap(fileName);;
|
||||
}
|
||||
|
||||
private:
|
||||
QPixmap _pixmap;
|
||||
QPoint _topLeft;
|
||||
QPoint _bottomRight;
|
||||
QColor _scaleColor;
|
||||
|
||||
// 缩放
|
||||
double _scalex;
|
||||
double _scaley;
|
||||
};
|
||||
|
||||
#endif // BITMAP_H
|
||||
|
||||
|
@ -0,0 +1,84 @@
|
||||
#ifndef CIRCULAR_H
|
||||
#define CIRCULAR_H
|
||||
|
||||
//Qt
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPaintEvent>
|
||||
#include <QVector>
|
||||
#include <QPainterPathStroker>
|
||||
#include <QPen>
|
||||
#include <QWidget>
|
||||
#include <QPaintEngine>
|
||||
#include <QPoint>
|
||||
#include <QRect>
|
||||
#include <QThread>
|
||||
|
||||
|
||||
class Circular
|
||||
{
|
||||
public:
|
||||
Circular(){
|
||||
_scalex = 1;
|
||||
_scaley = 1;
|
||||
}
|
||||
Circular(const QPointF& center){
|
||||
_center = center;
|
||||
_scalex = 1;
|
||||
_scaley = 1;
|
||||
}
|
||||
|
||||
void paint(QPixmap& w, QPaintEvent* event=nullptr){
|
||||
QPainter painter;
|
||||
painter.begin(&w);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.scale(_scalex,_scaley);
|
||||
painter.setPen(QPen(Qt::black, 0.8));
|
||||
painter.drawEllipse(_center,_radius,_radius);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
QPointF center() const
|
||||
{
|
||||
return _center;
|
||||
}
|
||||
|
||||
void setCenter(const QPointF ¢er)
|
||||
{
|
||||
_center = center;
|
||||
}
|
||||
|
||||
QColor color() const
|
||||
{
|
||||
return _color;
|
||||
}
|
||||
|
||||
void setColor(const QColor &color)
|
||||
{
|
||||
_color = color;
|
||||
}
|
||||
|
||||
double radius() const
|
||||
{
|
||||
return _radius;
|
||||
}
|
||||
|
||||
void setRadius(double radius)
|
||||
{
|
||||
_radius = radius;
|
||||
}
|
||||
|
||||
private:
|
||||
QPointF _center;
|
||||
double _radius;
|
||||
double _scalex;
|
||||
double _scaley;
|
||||
QColor _color;
|
||||
};
|
||||
|
||||
#endif // CIRCULAR_H
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
1. 几何部分的 fault.h 和contour.h 完成度较高
|
||||
|
||||
2. contour.h 画轮廓
|
||||
fault.h 画断层
|
||||
bitmap.h 画位图
|
||||
circular.h 画圆形
|
||||
rectangle.h 画矩形
|
||||
scale.h 画比例尺
|
||||
mainwindow.h和mainwindow.cpp用于测试
|
@ -0,0 +1,106 @@
|
||||
#ifndef RECTANGLE_H
|
||||
#define RECTANGLE_H
|
||||
|
||||
|
||||
//Qt
|
||||
#include <QDebug>
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPaintEvent>
|
||||
#include <QVector>
|
||||
#include <QPainterPathStroker>
|
||||
#include <QPen>
|
||||
#include <QWidget>
|
||||
#include <QPaintEngine>
|
||||
#include <qmath.h>
|
||||
#include <QPixmap>
|
||||
|
||||
class Rectangle
|
||||
{
|
||||
public:
|
||||
Rectangle(){
|
||||
_scalex = 1;
|
||||
_scaley = 1;
|
||||
}
|
||||
|
||||
Rectangle(double scalex,double scaley){
|
||||
_scalex = scalex;
|
||||
_scaley = scaley;
|
||||
}
|
||||
|
||||
void paint(QPixmap&mp, QPaintEvent *event = nullptr){
|
||||
QPainter painter;
|
||||
painter.begin(&mp);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.scale(_scalex,_scaley);
|
||||
painter.setPen(QPen(Qt::black, 0.8));
|
||||
QRect r(_topLeft,_bottomRight);
|
||||
_rect = r;
|
||||
painter.drawRect(_rect);
|
||||
painter.end();
|
||||
}
|
||||
|
||||
|
||||
double scalex() const
|
||||
{
|
||||
return _scalex;
|
||||
}
|
||||
|
||||
void setScalex(double scalex)
|
||||
{
|
||||
_scalex = scalex;
|
||||
}
|
||||
|
||||
double scaley() const
|
||||
{
|
||||
return _scaley;
|
||||
}
|
||||
|
||||
void setScaley(double scaley)
|
||||
{
|
||||
_scaley = scaley;
|
||||
}
|
||||
|
||||
QPoint topLeft() const
|
||||
{
|
||||
return _topLeft;
|
||||
}
|
||||
|
||||
void setTopLeft(const QPoint &topLeft)
|
||||
{
|
||||
_topLeft = topLeft;
|
||||
}
|
||||
|
||||
QPoint bottomRight() const
|
||||
{
|
||||
return _bottomRight;
|
||||
}
|
||||
|
||||
void setBottomRight(const QPoint &bottomRight)
|
||||
{
|
||||
_bottomRight = bottomRight;
|
||||
}
|
||||
|
||||
QColor rectColor() const
|
||||
{
|
||||
return _rectColor;
|
||||
}
|
||||
|
||||
void setRectColor(const QColor &rectColor)
|
||||
{
|
||||
_rectColor = rectColor;
|
||||
}
|
||||
|
||||
private:
|
||||
QPoint _topLeft;
|
||||
QPoint _bottomRight;
|
||||
QColor _rectColor;
|
||||
double _scalex;
|
||||
double _scaley;
|
||||
QRect _rect;
|
||||
};
|
||||
|
||||
#endif // RECTANGLE_H
|
||||
|
||||
|
@ -0,0 +1,196 @@
|
||||
#ifndef SCALE_H
|
||||
#define SCALE_H
|
||||
|
||||
//Qt
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QPainterPath>
|
||||
#include <QPaintEvent>
|
||||
#include <QVector>
|
||||
#include <QPainterPathStroker>
|
||||
#include <QPen>
|
||||
#include <QWidget>
|
||||
#include <QPaintEngine>
|
||||
#include <QPoint>
|
||||
#include <QRect>
|
||||
#include <QThread>
|
||||
|
||||
class Scale
|
||||
{
|
||||
public:
|
||||
Scale(int scaleLength,int scaleCount,int width,int height,const QPoint& topleft,const QPoint& bottomright){
|
||||
_scaleLength = scaleLength;
|
||||
_scaleCount = scaleCount;
|
||||
_topLeft = topleft;
|
||||
_bottomRight = bottomright;
|
||||
_scaleColor = QColor(192,192,192);
|
||||
_scalex = 1;
|
||||
_scaley = 1;
|
||||
_width = width;
|
||||
_height = height;
|
||||
}
|
||||
Scale(){
|
||||
_scaleLength = 6;
|
||||
_scaleCount = 8;
|
||||
_topLeft = QPoint(90,90);
|
||||
_bottomRight = QPoint(300,300);
|
||||
_scaleColor = QColor(192,192,192);
|
||||
_scalex = 1;
|
||||
_scaley = 1;
|
||||
_width = 0;
|
||||
_height = 0;
|
||||
}
|
||||
|
||||
void paint(QPixmap& w, QPaintEvent* event=nullptr){
|
||||
_scaleCount = _scaleCount > 8? _scaleCount : 8;
|
||||
QPainter painter;
|
||||
painter.begin(&w);
|
||||
painter.setRenderHint(QPainter::Antialiasing, true);
|
||||
painter.scale(_scalex,_scaley);
|
||||
_rect = QRect(QPoint(_topLeft.x()/_scalex,_topLeft.y()/_scaley),QPoint(_bottomRight.x()/_scalex,_bottomRight.y()/_scaley));
|
||||
painter.setPen(QPen(Qt::black, 0.8));
|
||||
painter.setBrush(_scaleColor);
|
||||
painter.drawRect(_rect);
|
||||
int width = _rect.width();
|
||||
int height = _rect.height();
|
||||
int tmp = _scaleCount/2;
|
||||
if(_width==0){
|
||||
_width = width;
|
||||
}
|
||||
if(_height==0){
|
||||
_height = height;
|
||||
}
|
||||
|
||||
// 上
|
||||
for (int i = 1; i < _scaleCount; ++i) {
|
||||
int x = _rect.left() + (i * width / _scaleCount);
|
||||
painter.drawLine(x, _rect.y(), x, _rect.y() - _scaleLength);
|
||||
const QRect rectangle = QRect(QPoint(x-25, _rect.y()-50), QPoint(x+25, _rect.y()- _scaleLength));
|
||||
painter.drawText(rectangle,Qt::AlignBottom,QString::number((i-tmp) * _width / _scaleCount));
|
||||
}
|
||||
|
||||
// 下
|
||||
for (int i = 1; i < _scaleCount; ++i) {
|
||||
int x = _rect.left() + (i * width / _scaleCount);
|
||||
painter.drawLine(x, _rect.y() + height, x, _rect.y() + height + _scaleLength);
|
||||
const QRect rectangle = QRect(x, _rect.y() + height + _scaleLength,x, _rect.y() + height + 100);
|
||||
painter.drawText(rectangle,Qt::AlignTop,QString::number((i-tmp) * _width / _scaleCount));
|
||||
}
|
||||
|
||||
//左
|
||||
for (int i = 1; i < _scaleCount; ++i) {
|
||||
int y = _rect.top() + (i * height / _scaleCount);
|
||||
painter.drawLine(_rect.x() - _scaleLength, y, _rect.x(), y);
|
||||
const QRect rectangle = QRect(_rect.x() -_scaleLength-100, y, _rect.x() -_scaleLength, y);
|
||||
painter.drawText(rectangle,Qt::AlignRight,QString::number((i-tmp) * _height / _scaleCount));
|
||||
}
|
||||
|
||||
|
||||
//右
|
||||
for (int i = 1; i < _scaleCount; ++i) {
|
||||
int y = _rect.top() + (i * height / _scaleCount);
|
||||
painter.drawLine(_rect.x() + width, y, _rect.x() + width + _scaleLength, y);
|
||||
const QRect rectangle = QRect(_rect.x() + width + _scaleLength, y, _rect.x() + width + _scaleLength+100, y);
|
||||
painter.drawText(rectangle,Qt::AlignLeft,QString::number((i-tmp) * _height / _scaleCount));
|
||||
}
|
||||
painter.end();
|
||||
|
||||
}
|
||||
|
||||
int scaleLength() const{
|
||||
return _scaleLength;
|
||||
}
|
||||
void setScaleLength(int scaleLength){
|
||||
_scaleLength = scaleLength;
|
||||
}
|
||||
|
||||
double scalex() const
|
||||
{
|
||||
return _scalex;
|
||||
}
|
||||
|
||||
void setScalex(double scalex)
|
||||
{
|
||||
_scalex = scalex;
|
||||
}
|
||||
|
||||
double scaley() const
|
||||
{
|
||||
return _scaley;
|
||||
}
|
||||
|
||||
void setScaley(double scaley)
|
||||
{
|
||||
_scaley = scaley;
|
||||
}
|
||||
|
||||
QRect rect() const{
|
||||
return _rect;
|
||||
}
|
||||
|
||||
QPoint topLeft() const
|
||||
{
|
||||
return _topLeft;
|
||||
}
|
||||
|
||||
void setTopLeft(const QPoint &topLeft)
|
||||
{
|
||||
_topLeft = topLeft;
|
||||
}
|
||||
|
||||
QPoint bottomRight() const
|
||||
{
|
||||
return _bottomRight;
|
||||
}
|
||||
|
||||
void setBottomRight(const QPoint &bottomRight)
|
||||
{
|
||||
_bottomRight = bottomRight;
|
||||
}
|
||||
|
||||
int width() const
|
||||
{
|
||||
return _width;
|
||||
}
|
||||
|
||||
void setWidth(int width)
|
||||
{
|
||||
_width = width;
|
||||
}
|
||||
|
||||
int height() const
|
||||
{
|
||||
return _height;
|
||||
}
|
||||
|
||||
void setHeight(int height)
|
||||
{
|
||||
_height = height;
|
||||
}
|
||||
|
||||
int scaleCount() const
|
||||
{
|
||||
return _scaleCount;
|
||||
}
|
||||
|
||||
void setScaleCount(int scaleCount)
|
||||
{
|
||||
_scaleCount = scaleCount;
|
||||
}
|
||||
|
||||
private:
|
||||
int _scaleLength;
|
||||
int _scaleCount;
|
||||
QPoint _topLeft;
|
||||
QPoint _bottomRight;
|
||||
QRect _rect;
|
||||
QColor _scaleColor;
|
||||
double _scalex;
|
||||
double _scaley;
|
||||
int _width;
|
||||
int _height;
|
||||
|
||||
};
|
||||
|
||||
#endif // SCALE_H
|
||||
|
Loading…
Reference in New Issue