Compare commits
2 Commits
0b2744656b
...
741e0e6734
| Author | SHA1 | Date | |
|---|---|---|---|
| 741e0e6734 | |||
| 5d5b440ba2 |
@ -11,6 +11,7 @@
|
||||
#include "MapTool.h"
|
||||
#include "MapToolPan.h"
|
||||
#include "MapToolSpectral.h"
|
||||
#include "MapTools.h"
|
||||
|
||||
HPPA* HPPA::s_instance = nullptr;
|
||||
|
||||
@ -89,8 +90,6 @@ HPPA::HPPA(QWidget* parent)
|
||||
ui.splitter->setStretchFactor(1, 1);
|
||||
ui.splitter->setStretchFactor(2, 3);*/
|
||||
|
||||
|
||||
|
||||
initMenubarToolbar();
|
||||
initMapTools();
|
||||
//光谱仪操作
|
||||
@ -242,7 +241,6 @@ sizePolicy1.setHeightForWidth(graphicsView_delete->sizePolicy().hasHeightForWidt
|
||||
|
||||
auto* g2 = m_LayerTreeModel->addGroup(m_LayerTreeModel->root(), "Vector");
|
||||
//model->addLayer(g2, "Rivers");
|
||||
|
||||
m_layerTreeView = new LayerTreeView();
|
||||
m_layerTreeView->setMenuProvider(new LayerTreeViewMenuProvider(m_layerTreeView));
|
||||
m_layerTreeView->setModel(m_LayerTreeModel);
|
||||
@ -1009,43 +1007,45 @@ void HPPA::initPanelToolbar()
|
||||
|
||||
void HPPA::initMapTools()
|
||||
{
|
||||
// Make the actions checkable
|
||||
ui.mActionPan->setCheckable(true);
|
||||
ui.mActionSpectral->setCheckable(true);
|
||||
|
||||
// Create tools (canvas will be set per-tab, tools are re-applied on tab switch)
|
||||
// We don't create per-canvas tools here; instead we create shared tool instances
|
||||
// and re-apply them when the tab changes.
|
||||
m_mapToolPan = nullptr;
|
||||
m_mapToolSpectral = nullptr;
|
||||
m_mapTools = new MapTools(this);
|
||||
m_mapTools->mapToolPan()->setAction(ui.mActionPan);
|
||||
m_mapTools->mapToolSpectral()->setAction(ui.mActionSpectral);
|
||||
|
||||
connect(m_mapTools->mapToolSpectral(), SIGNAL(spectralClicked(int,int,QVector<double>,QVector<double>)),
|
||||
this, SLOT(onLeftMouseButtonPressed(int,int,QVector<double>,QVector<double>)));
|
||||
|
||||
connect(ui.mActionPan, SIGNAL(triggered()), this, SLOT(onMapToolPanTriggered()));
|
||||
connect(ui.mActionSpectral, SIGNAL(triggered()), this, SLOT(onMapToolSpectralTriggered()));
|
||||
|
||||
// Default tool: pan
|
||||
ui.mActionPan->trigger();
|
||||
//ui.mActionPan->trigger();
|
||||
}
|
||||
|
||||
void HPPA::onMapToolPanTriggered()
|
||||
{
|
||||
// Find the current Mapcavas
|
||||
QWidget* currentWidget = m_imageViewerTabWidget->currentWidget();
|
||||
if (!currentWidget) return;
|
||||
if (!currentWidget)
|
||||
{
|
||||
ui.mActionPan->setChecked(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QList<Mapcavas*> canvases = currentWidget->findChildren<Mapcavas*>();
|
||||
if (canvases.isEmpty()) return;
|
||||
|
||||
Mapcavas* canvas = canvases[0];
|
||||
|
||||
// Clean up old tool
|
||||
delete m_mapToolPan;
|
||||
m_mapToolPan = new MapToolPan(canvas, this);
|
||||
m_mapToolPan->setAction(ui.mActionPan);
|
||||
// Set canvas on shared tool and activate
|
||||
m_mapTools->setMapcavas(canvas);
|
||||
|
||||
// Uncheck the other action
|
||||
ui.mActionSpectral->setChecked(false);
|
||||
|
||||
canvas->setMapTool(m_mapToolPan);
|
||||
canvas->setMapTool(m_mapTools->mapToolPan());
|
||||
}
|
||||
|
||||
void HPPA::onMapToolSpectralTriggered()
|
||||
@ -1059,19 +1059,13 @@ void HPPA::onMapToolSpectralTriggered()
|
||||
|
||||
Mapcavas* canvas = canvases[0];
|
||||
|
||||
// Clean up old tool
|
||||
delete m_mapToolSpectral;
|
||||
m_mapToolSpectral = new MapToolSpectral(canvas, this);
|
||||
m_mapToolSpectral->setAction(ui.mActionSpectral);
|
||||
// Set canvas on shared tool and activate
|
||||
m_mapTools->setMapcavas(canvas);
|
||||
|
||||
// Uncheck the other action
|
||||
ui.mActionPan->setChecked(false);
|
||||
|
||||
// Connect spectral signal to existing slot
|
||||
connect(m_mapToolSpectral, SIGNAL(spectralClicked(int,int,QVector<double>,QVector<double>)),
|
||||
this, SLOT(onLeftMouseButtonPressed(int,int,QVector<double>,QVector<double>)));
|
||||
|
||||
canvas->setMapTool(m_mapToolSpectral);
|
||||
canvas->setMapTool(m_mapTools->mapToolSpectral());
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
@ -1353,21 +1347,15 @@ void HPPA::onTabWidgetCurrentChanged(int index)//代码新建一个tab,会调
|
||||
|
||||
// Re-apply the current map tool to the new canvas
|
||||
Mapcavas* canvas = currentImageViewer[0];
|
||||
m_mapTools->setMapcavas(canvas);
|
||||
|
||||
if (ui.mActionPan->isChecked())
|
||||
{
|
||||
delete m_mapToolPan;
|
||||
m_mapToolPan = new MapToolPan(canvas, this);
|
||||
m_mapToolPan->setAction(ui.mActionPan);
|
||||
canvas->setMapTool(m_mapToolPan);
|
||||
canvas->setMapTool(m_mapTools->mapToolPan());
|
||||
}
|
||||
else if (ui.mActionSpectral->isChecked())
|
||||
{
|
||||
delete m_mapToolSpectral;
|
||||
m_mapToolSpectral = new MapToolSpectral(canvas, this);
|
||||
m_mapToolSpectral->setAction(ui.mActionSpectral);
|
||||
connect(m_mapToolSpectral, SIGNAL(spectralClicked(int,int,QVector<double>,QVector<double>)),
|
||||
this, SLOT(onLeftMouseButtonPressed(int,int,QVector<double>,QVector<double>)));
|
||||
canvas->setMapTool(m_mapToolSpectral);
|
||||
canvas->setMapTool(m_mapTools->mapToolSpectral());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1932,9 +1920,9 @@ void HPPA::onPlotHyperspectralImageRgbImage(int fileNumber, int frameNumber, QSt
|
||||
//cv::imwrite(rgbFilePathStrech, rgbImageStretched);
|
||||
|
||||
//创建需要显示的图像--qt版本
|
||||
//QRect CuttedRect = m_Imager->getRgbImage()->m_QRgbImage->rect();//先获取image整个rect
|
||||
//QRect CuttedRect = m_Imager->getRgbImage()->m_matRgbImage->rect();//先获取image整个rect
|
||||
//CuttedRect.setHeight(m_Imager->getFrameCounter() - 1);//裁剪rect
|
||||
//QImage CuttedImage = m_Imager->getRgbImage()->m_QRgbImage->copy(CuttedRect);
|
||||
//QImage CuttedImage = m_Imager->getRgbImage()->m_matRgbImage->copy(CuttedRect);
|
||||
|
||||
//currentImageViewer[0]->SetImage(&QPixmap::fromImage(CuttedImage));//绘制图像
|
||||
}
|
||||
|
||||
@ -65,6 +65,7 @@
|
||||
#include "MapTool.h"
|
||||
#include "MapToolPan.h"
|
||||
#include "MapToolSpectral.h"
|
||||
#include "MapTools.h"
|
||||
|
||||
#define PI 3.1415926
|
||||
|
||||
@ -279,8 +280,7 @@ private:
|
||||
MapLayerStore* m_MapLayerStore = nullptr;
|
||||
|
||||
// Map tools
|
||||
MapToolPan* m_mapToolPan = nullptr;
|
||||
MapToolSpectral* m_mapToolSpectral = nullptr;
|
||||
MapTools* m_mapTools = nullptr;
|
||||
void initMapTools();
|
||||
|
||||
public Q_SLOTS:
|
||||
|
||||
@ -818,7 +818,7 @@ QPushButton:pressed
|
||||
</widget>
|
||||
<widget class="QToolBar" name="mapToolBar">
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
<string>图像查看</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
|
||||
@ -126,6 +126,7 @@
|
||||
<ClCompile Include="MapLayerStore.cpp" />
|
||||
<ClCompile Include="MapTool.cpp" />
|
||||
<ClCompile Include="MapToolPan.cpp" />
|
||||
<ClCompile Include="MapTools.cpp" />
|
||||
<ClCompile Include="MapToolSpectral.cpp" />
|
||||
<ClCompile Include="OneMotorControl.cpp" />
|
||||
<ClCompile Include="path_tc.cpp" />
|
||||
@ -208,9 +209,10 @@
|
||||
<QtMoc Include="MapLayerStore.h" />
|
||||
<ClInclude Include="LayerTreeView.h" />
|
||||
<QtMoc Include="LayerTreeViewMenuProvider.h" />
|
||||
<ClInclude Include="MapTool.h" />
|
||||
<ClInclude Include="MapToolPan.h" />
|
||||
<ClInclude Include="MapToolSpectral.h" />
|
||||
<QtMoc Include="MapTool.h" />
|
||||
<QtMoc Include="MapToolPan.h" />
|
||||
<QtMoc Include="MapToolSpectral.h" />
|
||||
<QtMoc Include="MapTools.h" />
|
||||
<ClInclude Include="RasterDataProvider.h" />
|
||||
<ClInclude Include="RasterRenderer.h" />
|
||||
<ClInclude Include="utility_tc.h" />
|
||||
|
||||
@ -187,6 +187,9 @@
|
||||
<ClCompile Include="MapToolSpectral.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="MapTools.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="fileOperation.h">
|
||||
@ -291,6 +294,18 @@
|
||||
<QtMoc Include="imageControl.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapToolSpectral.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapToolPan.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapTool.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="MapTools.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="imageProcessor.h">
|
||||
@ -332,15 +347,6 @@
|
||||
<ClInclude Include="LayerTreeView.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MapTool.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MapToolPan.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="MapToolSpectral.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtUic Include="FocusDialog.ui">
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "MapTool.h"
|
||||
#include "ImageViewer.h"
|
||||
#include <QAction>
|
||||
|
||||
MapTool::MapTool(Mapcavas* canvas, QObject* parent)
|
||||
MapTool::MapTool(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_canvas(canvas)
|
||||
, m_cursor(Qt::ArrowCursor)
|
||||
{
|
||||
}
|
||||
@ -28,6 +27,19 @@ void MapTool::setAction(QAction* action)
|
||||
m_action = action;
|
||||
}
|
||||
|
||||
void MapTool::setMapcavas(Mapcavas* canvas)
|
||||
{
|
||||
if (m_canvas == canvas)
|
||||
return;
|
||||
|
||||
if (m_isActive && m_canvas)
|
||||
{
|
||||
deactivate();
|
||||
}
|
||||
|
||||
m_canvas = canvas;
|
||||
}
|
||||
|
||||
Mapcavas* MapTool::canvas() const
|
||||
{
|
||||
return m_canvas;
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
#ifndef MAPTOOL_H
|
||||
#ifndef MAPTOOL_H
|
||||
#define MAPTOOL_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QCursor>
|
||||
#include <QMouseEvent>
|
||||
#include <QAction>
|
||||
|
||||
class Mapcavas;
|
||||
class QAction;
|
||||
@ -20,28 +21,24 @@ public:
|
||||
};
|
||||
Q_DECLARE_FLAGS(Flags, Flag)
|
||||
|
||||
MapTool(Mapcavas* canvas, QObject* parent = nullptr);
|
||||
MapTool(QObject* parent = nullptr);
|
||||
virtual ~MapTool();
|
||||
|
||||
virtual Flags flags() const { return NoFlags; }
|
||||
|
||||
// Associated action <20>C used to auto-check / uncheck when tool is activated / deactivated
|
||||
QAction* action() const;
|
||||
void setAction(QAction* action);
|
||||
|
||||
// Canvas this tool operates on
|
||||
void setMapcavas(Mapcavas* canvas);
|
||||
Mapcavas* canvas() const;
|
||||
|
||||
// Cursor shown when tool is active
|
||||
virtual void setCursor(const QCursor& cursor);
|
||||
QCursor cursor() const;
|
||||
|
||||
// Lifecycle
|
||||
virtual void activate();
|
||||
virtual void deactivate();
|
||||
bool isActive() const;
|
||||
|
||||
// Mouse event handlers <20>C return true if event was handled
|
||||
virtual void canvasMousePressEvent(QMouseEvent* e);
|
||||
virtual void canvasMouseReleaseEvent(QMouseEvent* e);
|
||||
virtual void canvasMouseMoveEvent(QMouseEvent* e);
|
||||
@ -52,8 +49,10 @@ signals:
|
||||
void activated();
|
||||
void deactivated();
|
||||
|
||||
private:
|
||||
protected:
|
||||
Mapcavas* m_canvas = nullptr;
|
||||
|
||||
private:
|
||||
QAction* m_action = nullptr;
|
||||
QCursor m_cursor;
|
||||
bool m_isActive = false;
|
||||
|
||||
@ -1,15 +1,19 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "MapToolPan.h"
|
||||
#include "ImageViewer.h"
|
||||
#include <QMouseEvent>
|
||||
#include <QGraphicsView>
|
||||
|
||||
MapToolPan::MapToolPan(Mapcavas* canvas, QObject* parent)
|
||||
: MapTool(canvas, parent)
|
||||
MapToolPan::MapToolPan(QObject* parent)
|
||||
: MapTool(parent)
|
||||
{
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
||||
MapToolPan::~MapToolPan()
|
||||
{
|
||||
}
|
||||
|
||||
void MapToolPan::activate()
|
||||
{
|
||||
MapTool::activate();
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#ifndef MAPTOOLPAN_H
|
||||
#ifndef MAPTOOLPAN_H
|
||||
#define MAPTOOLPAN_H
|
||||
|
||||
#include "MapTool.h"
|
||||
@ -9,7 +9,8 @@ class MapToolPan : public MapTool
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapToolPan(Mapcavas* canvas, QObject* parent = nullptr);
|
||||
MapToolPan(QObject* parent = nullptr);
|
||||
~MapToolPan();
|
||||
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
|
||||
@ -1,16 +1,20 @@
|
||||
#include "stdafx.h"
|
||||
#include "stdafx.h"
|
||||
#include "MapToolSpectral.h"
|
||||
#include "ImageViewer.h"
|
||||
#include "RasterLayer.h"
|
||||
#include <QMouseEvent>
|
||||
#include <cmath>
|
||||
|
||||
MapToolSpectral::MapToolSpectral(Mapcavas* canvas, QObject* parent)
|
||||
: MapTool(canvas, parent)
|
||||
MapToolSpectral::MapToolSpectral(QObject* parent)
|
||||
: MapTool(parent)
|
||||
{
|
||||
setCursor(Qt::CrossCursor);
|
||||
}
|
||||
|
||||
MapToolSpectral::~MapToolSpectral()
|
||||
{
|
||||
}
|
||||
|
||||
void MapToolSpectral::canvasMousePressEvent(QMouseEvent* e)
|
||||
{
|
||||
if (e->button() != Qt::LeftButton)
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#ifndef MAPTOOLSPECTRAL_H
|
||||
#ifndef MAPTOOLSPECTRAL_H
|
||||
#define MAPTOOLSPECTRAL_H
|
||||
|
||||
#include "MapTool.h"
|
||||
@ -9,7 +9,8 @@ class MapToolSpectral : public MapTool
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MapToolSpectral(Mapcavas* canvas, QObject* parent = nullptr);
|
||||
MapToolSpectral(QObject* parent = nullptr);
|
||||
~MapToolSpectral();
|
||||
|
||||
void canvasMousePressEvent(QMouseEvent* e) override;
|
||||
|
||||
|
||||
44
HPPA/MapTools.cpp
Normal file
44
HPPA/MapTools.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
#include "stdafx.h"
|
||||
#include "MapTools.h"
|
||||
#include "MapToolPan.h"
|
||||
#include "MapToolSpectral.h"
|
||||
|
||||
MapTools::MapTools(QObject* parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
m_mapToolPan = new MapToolPan(this);
|
||||
m_mapToolSpectral = new MapToolSpectral(this);
|
||||
}
|
||||
|
||||
MapTools::~MapTools()
|
||||
{
|
||||
}
|
||||
|
||||
MapToolPan* MapTools::mapToolPan() const
|
||||
{
|
||||
return m_mapToolPan;
|
||||
}
|
||||
|
||||
MapToolSpectral* MapTools::mapToolSpectral() const
|
||||
{
|
||||
return m_mapToolSpectral;
|
||||
}
|
||||
|
||||
MapTool* MapTools::mapTool(Tool tool) const
|
||||
{
|
||||
switch (tool)
|
||||
{
|
||||
case Pan:
|
||||
return m_mapToolPan;
|
||||
case Spectral:
|
||||
return m_mapToolSpectral;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void MapTools::setMapcavas(Mapcavas* canvas)
|
||||
{
|
||||
m_mapToolPan->setMapcavas(canvas);
|
||||
m_mapToolSpectral->setMapcavas(canvas);
|
||||
}
|
||||
37
HPPA/MapTools.h
Normal file
37
HPPA/MapTools.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef MAPTOOLS_H
|
||||
#define MAPTOOLS_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class MapTool;
|
||||
class MapToolPan;
|
||||
class MapToolSpectral;
|
||||
class Mapcavas;
|
||||
|
||||
class MapTools : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Tool
|
||||
{
|
||||
Pan,
|
||||
Spectral,
|
||||
};
|
||||
|
||||
MapTools(QObject* parent = nullptr);
|
||||
~MapTools();
|
||||
|
||||
MapToolPan* mapToolPan() const;
|
||||
MapToolSpectral* mapToolSpectral() const;
|
||||
|
||||
MapTool* mapTool(Tool tool) const;
|
||||
|
||||
void setMapcavas(Mapcavas* canvas);
|
||||
|
||||
private:
|
||||
MapToolPan* m_mapToolPan = nullptr;
|
||||
MapToolSpectral* m_mapToolSpectral = nullptr;
|
||||
};
|
||||
|
||||
#endif // MAPTOOLS_H
|
||||
Reference in New Issue
Block a user