修复了世界坐标系坐标拾取错误
parent
c3a47c2789
commit
49781f86a8
|
|
@ -65,12 +65,14 @@
|
||||||
#include <vtkExtractSelectedPolyDataIds.h>
|
#include <vtkExtractSelectedPolyDataIds.h>
|
||||||
#include <vtkConnectivityFilter.h>
|
#include <vtkConnectivityFilter.h>
|
||||||
#include "Common/DebugLogger.h"
|
#include "Common/DebugLogger.h"
|
||||||
|
#include <vtkWorldPointPicker.h>
|
||||||
|
|
||||||
namespace ModuleBase
|
namespace ModuleBase
|
||||||
{
|
{
|
||||||
PropPickerInteractionStyle::PropPickerInteractionStyle()
|
PropPickerInteractionStyle::PropPickerInteractionStyle()
|
||||||
{
|
{
|
||||||
|
_worldPointPicker=vtkSmartPointer<vtkWorldPointPicker>::New();
|
||||||
|
_picked=new double[3];
|
||||||
_actor = nullptr;
|
_actor = nullptr;
|
||||||
_property = vtkProperty::New();
|
_property = vtkProperty::New();
|
||||||
// _selectItemIDs = vtkSmartPointer<vtkIdTypeArray>::New();
|
// _selectItemIDs = vtkSmartPointer<vtkIdTypeArray>::New();
|
||||||
|
|
@ -92,6 +94,12 @@ namespace ModuleBase
|
||||||
delete _dataProp;
|
delete _dataProp;
|
||||||
_property->Delete();
|
_property->Delete();
|
||||||
_coordinate->Delete();
|
_coordinate->Delete();
|
||||||
|
|
||||||
|
if(nullptr!=_picked){
|
||||||
|
delete[] _picked;
|
||||||
|
_picked=nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -287,6 +295,18 @@ namespace ModuleBase
|
||||||
*/
|
*/
|
||||||
void PropPickerInteractionStyle::OnMouseMove()
|
void PropPickerInteractionStyle::OnMouseMove()
|
||||||
{
|
{
|
||||||
|
// 获取坐标系
|
||||||
|
_worldPointPicker->Pick(this->Interactor->GetEventPosition()[0],
|
||||||
|
this->Interactor->GetEventPosition()[1],
|
||||||
|
0, // always zero.
|
||||||
|
this->Interactor->GetRenderWindow()
|
||||||
|
->GetRenderers()
|
||||||
|
->GetFirstRenderer());
|
||||||
|
_worldPointPicker->GetPickPosition(_picked);
|
||||||
|
emit MouseMoveInWorldPoint(_picked[0],_picked[1],_picked[2]);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
_mouseMoved = true;
|
_mouseMoved = true;
|
||||||
vtkInteractorStyleRubberBandPick::OnMouseMove();
|
vtkInteractorStyleRubberBandPick::OnMouseMove();
|
||||||
if ((_selectModel == BoxMeshCell) || (_selectModel == BoxMeshNode) || (_selectModel == DrawSketch) /*&& _leftButtonDown*/)
|
if ((_selectModel == BoxMeshCell) || (_selectModel == BoxMeshNode) || (_selectModel == DrawSketch) /*&& _leftButtonDown*/)
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include <vtkUnstructuredGrid.h>
|
#include <vtkUnstructuredGrid.h>
|
||||||
#include <vtkVertexGlyphFilter.h>
|
#include <vtkVertexGlyphFilter.h>
|
||||||
#include <vtkIdFilter.h>
|
#include <vtkIdFilter.h>
|
||||||
|
#include <vtkWorldPointPicker.h>
|
||||||
|
|
||||||
class vtkActor;
|
class vtkActor;
|
||||||
class vtkProperty;
|
class vtkProperty;
|
||||||
|
|
@ -97,7 +98,7 @@ namespace ModuleBase
|
||||||
void mouseWhellMove();
|
void mouseWhellMove();
|
||||||
void rightDownMenu();
|
void rightDownMenu();
|
||||||
void clearAllHighLight();
|
void clearAllHighLight();
|
||||||
|
void MouseMoveInWorldPoint(double x,double y,double z);
|
||||||
private:
|
private:
|
||||||
virtual void OnLeftButtonDown() override;
|
virtual void OnLeftButtonDown() override;
|
||||||
virtual void OnLeftButtonUp() override;
|
virtual void OnLeftButtonUp() override;
|
||||||
|
|
@ -154,8 +155,8 @@ namespace ModuleBase
|
||||||
bool _selected{false};
|
bool _selected{false};
|
||||||
vtkActor *_preGeoSeltctActor{};
|
vtkActor *_preGeoSeltctActor{};
|
||||||
vtkCoordinate *_coordinate{};
|
vtkCoordinate *_coordinate{};
|
||||||
|
double* _picked;
|
||||||
|
vtkSmartPointer<vtkWorldPointPicker> _worldPointPicker;
|
||||||
|
|
||||||
|
|
||||||
// QList<vtkActor*> _tempActorContainer{};
|
// QList<vtkActor*> _tempActorContainer{};
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@
|
||||||
#include "MeshData/meshSingleton.h"
|
#include "MeshData/meshSingleton.h"
|
||||||
#include "PreWindowInteractorStyle.h"
|
#include "PreWindowInteractorStyle.h"
|
||||||
#include <vtkVersionMacros.h>
|
#include <vtkVersionMacros.h>
|
||||||
|
#include <vtkWorldPointPicker.h>
|
||||||
|
|
||||||
namespace ModuleBase
|
namespace ModuleBase
|
||||||
{
|
{
|
||||||
|
|
@ -118,6 +119,11 @@ namespace ModuleBase
|
||||||
_cubeAxesActor = vtkSmartPointer<vtkCubeAxesActor>::New();
|
_cubeAxesActor = vtkSmartPointer<vtkCubeAxesActor>::New();
|
||||||
//createCubeAxes();
|
//createCubeAxes();
|
||||||
|
|
||||||
|
// // 世界坐标轴
|
||||||
|
_worldPointPicker=vtkSmartPointer<vtkWorldPointPicker>::New();
|
||||||
|
_interactor->SetPicker(_worldPointPicker);
|
||||||
|
|
||||||
|
|
||||||
if (_graphWindowType == PreWindows)
|
if (_graphWindowType == PreWindows)
|
||||||
{
|
{
|
||||||
PropPickerInteractionStyle *style = PropPickerInteractionStyle::New();
|
PropPickerInteractionStyle *style = PropPickerInteractionStyle::New();
|
||||||
|
|
@ -125,11 +131,15 @@ namespace ModuleBase
|
||||||
style->SetDefaultRenderer(_render);
|
style->SetDefaultRenderer(_render);
|
||||||
style->setRender(_render);
|
style->setRender(_render);
|
||||||
style->setRenderWindow(_renderWindow);
|
style->setRenderWindow(_renderWindow);
|
||||||
|
|
||||||
_interactor->SetInteractorStyle(style);
|
_interactor->SetInteractorStyle(style);
|
||||||
vtkSmartPointer<vtkAreaPicker> areaPicker = vtkSmartPointer<vtkAreaPicker>::New(); // 面积拾取器
|
vtkSmartPointer<vtkAreaPicker> areaPicker = vtkSmartPointer<vtkAreaPicker>::New(); // 面积拾取器
|
||||||
_interactor->SetPicker(areaPicker);
|
_interactor->SetPicker(areaPicker);
|
||||||
_interactionStyle = style;
|
_interactionStyle = style;
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
//关联信号
|
//关联信号
|
||||||
// connect(style, SIGNAL(selectGeometry(bool)), this, SIGNAL(selectGeometry(bool)));
|
// connect(style, SIGNAL(selectGeometry(bool)), this, SIGNAL(selectGeometry(bool)));
|
||||||
connect(style, SIGNAL(selectGeometry(bool, vtkActor *, int)), this, SIGNAL(selectGeometry(bool, vtkActor *, int)));
|
connect(style, SIGNAL(selectGeometry(bool, vtkActor *, int)), this, SIGNAL(selectGeometry(bool, vtkActor *, int)));
|
||||||
|
|
@ -145,7 +155,8 @@ namespace ModuleBase
|
||||||
connect(style, SIGNAL(mouseWhellMove()), this, SLOT(mouseWheelMove()));
|
connect(style, SIGNAL(mouseWhellMove()), this, SLOT(mouseWheelMove()));
|
||||||
connect(style, SIGNAL(rightDownMenu()), this, SIGNAL(rightDownMenuSig()));
|
connect(style, SIGNAL(rightDownMenu()), this, SIGNAL(rightDownMenuSig()));
|
||||||
|
|
||||||
// pointcloud
|
// 世界坐标系
|
||||||
|
connect(style, SIGNAL(MouseMoveInWorldPoint(double ,double ,double )),this, SIGNAL(WorldPointMouseMove(double ,double ,double )));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -551,14 +562,14 @@ namespace ModuleBase
|
||||||
}
|
}
|
||||||
void Graph3DWindow::mouseMoveEvent(QMouseEvent* event)
|
void Graph3DWindow::mouseMoveEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
// 获取鼠标当前位置
|
// // 获取鼠标当前位置
|
||||||
QPointF pos=event->pos();
|
// QPointF pos=event->pos();
|
||||||
double dispCoord[2] = {pos.x(), pos.y()};
|
// double dispCoord[2] = {pos.x(), pos.y()};
|
||||||
vtkSmartPointer<vtkCoordinate> pCoorPress = vtkSmartPointer<vtkCoordinate>::New();
|
// vtkSmartPointer<vtkCoordinate> pCoorPress = vtkSmartPointer<vtkCoordinate>::New();
|
||||||
pCoorPress->SetCoordinateSystemToDisplay();
|
// pCoorPress->SetCoordinateSystemToDisplay();
|
||||||
pCoorPress->SetValue(dispCoord);
|
// pCoorPress->SetValue(dispCoord);
|
||||||
double *worldCoord = pCoorPress->GetComputedWorldValue(_render);
|
// double *worldCoord = pCoorPress->GetComputedWorldValue(_render);
|
||||||
// qDebug() << worldCoord[0] << worldCoord[1] << worldCoord[2];
|
//// qDebug() << worldCoord[0] << worldCoord[1] << worldCoord[2];
|
||||||
emit this->WorldPointMouseMove(worldCoord[0],worldCoord[1],worldCoord[2]);
|
// emit this->WorldPointMouseMove(worldCoord[0],worldCoord[1],worldCoord[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,7 @@
|
||||||
// Boost
|
// Boost
|
||||||
#include <boost/math/special_functions/round.hpp>
|
#include <boost/math/special_functions/round.hpp>
|
||||||
#include <vtkCubeAxesActor.h>
|
#include <vtkCubeAxesActor.h>
|
||||||
|
#include <vtkWorldPointPicker.h>
|
||||||
|
|
||||||
VTK_MODULE_INIT(vtkRenderingOpenGL2);
|
VTK_MODULE_INIT(vtkRenderingOpenGL2);
|
||||||
VTK_MODULE_INIT(vtkInteractionStyle);
|
VTK_MODULE_INIT(vtkInteractionStyle);
|
||||||
|
|
@ -245,6 +246,8 @@ namespace ModuleBase
|
||||||
PropPickerInteractionStyle* _interactionStyle{};
|
PropPickerInteractionStyle* _interactionStyle{};
|
||||||
SelectModel _selectModel{ None };
|
SelectModel _selectModel{ None };
|
||||||
|
|
||||||
|
// 世界坐标系
|
||||||
|
vtkSmartPointer<vtkWorldPointPicker> _worldPointPicker;
|
||||||
/*** 点云处理***/
|
/*** 点云处理***/
|
||||||
pcl::visualization::PCLVisualizer::Ptr _viewer; // 点云显示共享指针
|
pcl::visualization::PCLVisualizer::Ptr _viewer; // 点云显示共享指针
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue