完成断层和轮廓的初版
commit
1486954791
@ -0,0 +1 @@
|
||||
*.pro.user
|
@ -0,0 +1,27 @@
|
||||
#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
|
@ -0,0 +1,36 @@
|
||||
#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
|
@ -0,0 +1,14 @@
|
||||
#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,11 @@
|
||||
#include "mainwindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return a.exec();
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setMouseTracking(true);
|
||||
ui->centralWidget->setMouseTracking(true);
|
||||
rectPath.moveTo(20.0, 30.0);
|
||||
rectPath.lineTo(80.0, 30.0);
|
||||
rectPath.lineTo(80.0, 70.0);
|
||||
rectPath.lineTo(20.0, 70.0);
|
||||
scalex = 1;
|
||||
scaley = 1;
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::mousePressEvent(QMouseEvent *event){
|
||||
for(int i=0;i<vf.size();++i){
|
||||
Fault&f = vf[i];
|
||||
if(!f.isGenerated()){
|
||||
continue;
|
||||
}
|
||||
if(f.contains(event->posF())){
|
||||
isPressed = true;
|
||||
iPoint = f.dotContains(event->posF());
|
||||
}else if(c.contains(event->posF())){
|
||||
isPressed = true;
|
||||
iPoint = c.dotContains(event->posF());
|
||||
}
|
||||
if(event->button()==Qt::RightButton){
|
||||
f.setMove(false);
|
||||
c.setMove(false);
|
||||
}
|
||||
if(ui->checkBox->checkState()==Qt::Unchecked && event->button()==Qt::LeftButton){
|
||||
f.pick(event);
|
||||
}
|
||||
}
|
||||
if(ui->checkBox->checkState()==Qt::Checked){
|
||||
// Fault 测试集
|
||||
int n = f.elementCount();
|
||||
if(event->button()==Qt::LeftButton){
|
||||
qreal x = event->posF().x();
|
||||
qreal y = event->posF().y();
|
||||
if(n>1){
|
||||
f.setPoint(n-1,x+0.01,y+0.01);
|
||||
}
|
||||
f.addPoint(x,y);
|
||||
if(n==0){
|
||||
f.addPoint(x+3,y+3);
|
||||
}
|
||||
|
||||
}
|
||||
else if(event->button()==Qt::RightButton){
|
||||
f.generate();
|
||||
vf.push_back(f);
|
||||
f.clear();
|
||||
ui->checkBox->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
else if(ui->checkBox2->checkState()==Qt::Checked){
|
||||
// contour测试集
|
||||
int n = c.elementCount();
|
||||
if(event->button()==Qt::LeftButton){
|
||||
qreal x = event->posF().x();
|
||||
qreal y = event->posF().y();
|
||||
c.addPoint(x,y);
|
||||
if(n==0){
|
||||
c.addPoint(x+3,y+3);
|
||||
}
|
||||
}else if(event->button()==Qt::RightButton){
|
||||
c.generate();
|
||||
ui->checkBox2->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
if(ui->checkBox2->checkState()==Qt::Unchecked && event->button()==Qt::LeftButton){
|
||||
c.pick(event);
|
||||
}
|
||||
this->update();
|
||||
}
|
||||
|
||||
void MainWindow::mouseReleaseEvent(QMouseEvent *event){
|
||||
isPressed = false;
|
||||
this->update();
|
||||
}
|
||||
void MainWindow::mouseMoveEvent(QMouseEvent *event){
|
||||
if(ui->checkBox->checkState()==Qt::Checked){
|
||||
int n = f.elementCount();
|
||||
qreal x1 = event->posF().x();
|
||||
qreal y1 = event->posF().y();
|
||||
if(n > 1){
|
||||
f.setPoint(n-1,x1,y1);
|
||||
}
|
||||
}
|
||||
else if(ui->checkBox2->checkState()==Qt::Checked){
|
||||
int n = c.elementCount();
|
||||
qreal x1 = event->posF().x();
|
||||
qreal y1 = event->posF().y();
|
||||
if(n > 1){
|
||||
c.setPoint(n-1,x1,y1);
|
||||
}
|
||||
}
|
||||
if(ui->checkBox2->checkState()==Qt::Unchecked&&ui->checkBox->checkState()==Qt::Unchecked&&isPressed){
|
||||
if(c.isMove()){
|
||||
if(iPoint!=-1){
|
||||
c.setPoint(iPoint,event->posF().x(),event->posF().y());
|
||||
}else{
|
||||
c.move(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(ui->checkBox->checkState()==Qt::Unchecked&&ui->checkBox2->checkState()==Qt::Unchecked&&isPressed){
|
||||
for(int i=0;i<vf.size();++i){
|
||||
Fault&f = vf[i];
|
||||
if(f.isMove()){
|
||||
if(iPoint!=-1){
|
||||
f.setPoint(iPoint,event->posF().x(),event->posF().y());
|
||||
}else{
|
||||
f.move(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this->update();
|
||||
}
|
||||
|
||||
void MainWindow::paintEvent(QPaintEvent *event){
|
||||
c.paint(this,event);
|
||||
f.paint(this,event);
|
||||
for(int i=0;i<vf.size();++i){
|
||||
vf[i].paint(this,event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// scalex = this->width() / 100.0;
|
||||
// scaley = this->height() / 100.0;
|
||||
// painter.begin(this);
|
||||
// painter.setRenderHint(QPainter::Antialiasing);
|
||||
// painter.scale(scalex, scaley);
|
||||
// QColor color(255,30,1);
|
||||
// QPen pen;
|
||||
// pen.setColor(color);
|
||||
// painter.setPen(pen);
|
||||
// int n = rectPath.elementCount();
|
||||
// if(ismove){
|
||||
// painter.save();
|
||||
// for(int i=0;i<n;++i){
|
||||
// painter.setPen(Qt::NoPen);
|
||||
|
||||
// painter.setBrush(color);
|
||||
// painter.drawEllipse(QPointF(rectPath.elementAt(i).x,rectPath.elementAt(i).y),3,3);
|
||||
// }
|
||||
// painter.restore();
|
||||
// painter.drawPath(outline);
|
||||
// }
|
||||
// else{
|
||||
// painter.drawPath(rectPath);
|
||||
// }
|
||||
// painter.end();
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include "QtGui"
|
||||
|
||||
#include <QPainter>
|
||||
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPainterPathStroker>
|
||||
#include <QPen>
|
||||
|
||||
#include "fault.h"
|
||||
#include "contour.h"
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QPainterPath rectPath;
|
||||
QPainterPath outline;
|
||||
QPainter painter;
|
||||
int x;
|
||||
int y;
|
||||
double scalex;
|
||||
double scaley;
|
||||
Contour c;
|
||||
bool isPressed;
|
||||
int iPoint;
|
||||
QVector<Fault>vf;
|
||||
Fault f;
|
||||
|
||||
|
||||
// QWidget interface
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void paintEvent(QPaintEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>560</width>
|
||||
<height>482</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>220</x>
|
||||
<y>10</y>
|
||||
<width>79</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>断层</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="checkBox2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>370</x>
|
||||
<y>10</y>
|
||||
<width>79</width>
|
||||
<height>18</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>轮廓</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<widget class="QToolBar" name="mainToolBar">
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>560</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -0,0 +1,41 @@
|
||||
#-------------------------------------------------
|
||||
#
|
||||
# Project created by QtCreator 2024-09-15T14:22:53
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = oilpool
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
# any feature of Qt which as been marked as deprecated (the exact warnings
|
||||
# depend on your compiler). Please consult the documentation of the
|
||||
# deprecated API in order to know how to port your code away from it.
|
||||
DEFINES += QT_DEPRECATED_WARNINGS
|
||||
|
||||
# You can also make your code fail to compile if you use deprecated APIs.
|
||||
# In order to do so, uncomment the following line.
|
||||
# You can also select to disable deprecated APIs only up to a certain version of Qt.
|
||||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
|
||||
|
||||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mainwindow.cpp \
|
||||
scalegraphicsview.cpp
|
||||
|
||||
HEADERS += \
|
||||
mainwindow.h \
|
||||
basicgeometry.h \
|
||||
basicgeometryoperator.h \
|
||||
fault.h \
|
||||
aoi.h \
|
||||
contour.h \
|
||||
scalegraphicsview.h
|
||||
|
||||
FORMS += \
|
||||
mainwindow.ui
|
Loading…
Reference in New Issue