You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
267 lines
7.7 KiB
C++
267 lines
7.7 KiB
C++
#include "SceneView.h"
|
|
|
|
void UGSTDCALL Action3DChangedCallBack(UGlong pWnd, UGSceneUserAction oldAction,UGSceneUserAction newAction)
|
|
{
|
|
// qDebug()<<"****************oldAction:"<<oldAction;
|
|
// qDebug()<<"****************newAction:"<<newAction;
|
|
// qDebug()<<"****************newAction:"<<newAction;
|
|
|
|
// SceneView* pSceneView = (SceneView*)pWnd;
|
|
// if(newAction==UGSceneUserAction::suaCreatePolyline)
|
|
// {
|
|
//// pSceneView->showSettingFlightPoint = true;
|
|
// emit pSceneView->showSettingFlightPointDialg();
|
|
// }
|
|
|
|
// qDebug()<<"****************Edit3DCursorShape:"<<pSceneControl->GetSceneEditWnd()->Get3DCursorShape();
|
|
// qDebug()<<"****************3DCursorShape:"<<pSceneControl->GetSceneEditWnd()->m_SceneWindow.Get3DCursorShape();
|
|
}
|
|
|
|
void UGSTDCALL Tracking3DCallBack(UGlong pWnd, UGdouble &dx, UGdouble &dy, UGdouble &dz,
|
|
UGint nButtonClicked, UGdouble dCurrentLength, UGdouble dCurrentAngle,
|
|
UGdouble dTotalLength, UGdouble dTotalArea, UGdouble dHeight, UGdouble dAngle,
|
|
UGdouble dAzimuth, UGGeometry *pGeometry)
|
|
{
|
|
qDebug()<<"****************Tracking3DCallBack:";
|
|
SceneView* pSceneView = (SceneView*)pWnd;
|
|
if(pSceneView->startTrackingFlag)
|
|
{
|
|
emit pSceneView->sendTrackingGeometry(pGeometry);
|
|
pSceneView->startTrackingFlag = false;
|
|
}
|
|
}
|
|
|
|
void UGSTDCALL Tracked3DCallBack(UGlong pWnd, UGGeometry *pGeometry, UGdouble dLength,
|
|
UGdouble dArea, UGdouble dHeight,UGdouble dAngle, UGdouble dAzimuth)
|
|
{
|
|
SceneView* pSceneView = (SceneView*)pWnd;
|
|
qDebug()<<"****************Tracked3DCallBack:";
|
|
// qDebug()<<"****************UserAction:"<<pSceneView->GetSceneControl()->GetSceneEditWnd()->GetUserAction();
|
|
// qDebug()<<"***************GeometryType:"<<pGeometry->GetType();
|
|
// if(pGeometry==NULL) return;
|
|
qDebug()<<"****************Length:"<<dLength;
|
|
if(pGeometry!=NULL)
|
|
{
|
|
if(pGeometry->GetType()==UGGeometry::GeoLine3D)
|
|
emit pSceneView->sendTrackedGeometry(pGeometry);
|
|
}
|
|
|
|
pSceneView->GetSceneControl()->GetSceneEditWnd()->SetUserAction(UGSceneUserAction::suaPanSelect);
|
|
qDebug()<<"****************UserAction1:"<<pSceneView->GetSceneControl()->GetSceneEditWnd()->GetUserAction();
|
|
// pSceneView->GetSceneControl()->Refresh();
|
|
/*
|
|
qDebug()<<"****************SubPntCount:"<<pGeometry->GetSubPntCount(0);
|
|
UGGeoLine3D* l = (UGGeoLine3D*)pGeometry;
|
|
const UGPoint3D* p = NULL;
|
|
p = l->GetPoints();
|
|
for(int i =0;i<pGeometry->GetSubPntCount(0);i++)
|
|
{
|
|
qDebug()<<"****************x:"<<p->x;
|
|
qDebug()<<"****************y:"<<p->y;
|
|
qDebug()<<"****************z:"<<p->z;
|
|
qDebug()<<"*********************";
|
|
p++;
|
|
}
|
|
*/
|
|
}
|
|
|
|
|
|
SceneView::SceneView(QWidget *parent) : QWidget(parent)
|
|
{
|
|
m_pSceneControl = NULL;
|
|
|
|
QDesktopWidget* desktop = QApplication::desktop();
|
|
int logicalDpiX = desktop->logicalDpiX();
|
|
int logicalDpiY = desktop->logicalDpiY();
|
|
m_pSceneControl = new SceneControl((HWND)winId(), logicalDpiX, logicalDpiX);
|
|
|
|
renderTimer = new QTimer();
|
|
connect(renderTimer, SIGNAL(timeout()), this, SLOT(RenderInTimer()));
|
|
// renderTimer->start(30);
|
|
|
|
isRenderTimerStarted = false;
|
|
|
|
this->setMouseTracking(true);
|
|
|
|
m_pSceneControl->GetSceneEditWnd()->m_SceneWindow.SetTracking3DFunc(Tracking3DCallBack,(UGlong)this);
|
|
m_pSceneControl->GetSceneEditWnd()->m_SceneWindow.SetTracked3DFunc(Tracked3DCallBack,(UGlong)this);
|
|
m_pSceneControl->GetSceneEditWnd()->m_SceneWindow.SetAction3DChangedFunc(Action3DChangedCallBack,(UGlong)this);
|
|
// pSceneLayersView = new SceneLayersView();
|
|
|
|
isEditStateFlag = false;
|
|
}
|
|
|
|
SceneView::~SceneView()
|
|
{
|
|
renderTimer->stop();
|
|
delete renderTimer;
|
|
|
|
/*pSceneLayersView->setParent(NULL);
|
|
delete pSceneLayersView;*/
|
|
|
|
delete m_pSceneControl;
|
|
}
|
|
|
|
unsigned int SceneView::getMouseOrKeyFlag(QMouseEvent* event)
|
|
{
|
|
unsigned int flag = 0;
|
|
|
|
if (event->modifiers() & Qt::ShiftModifier)
|
|
{
|
|
flag = flag | UG_VK_SHIFT;
|
|
}
|
|
if ((event->modifiers() & Qt::ControlModifier))
|
|
{
|
|
flag = flag | UG_VK_CONTROL;
|
|
}
|
|
if (event->modifiers()&Qt::MetaModifier)
|
|
{
|
|
flag = flag | UG_VK_MENU;
|
|
}
|
|
return flag;
|
|
}
|
|
|
|
void SceneView::paintEvent(QPaintEvent* event)
|
|
{
|
|
|
|
}
|
|
|
|
void SceneView::wheelEvent(QWheelEvent* event)
|
|
{
|
|
if (m_pSceneControl != NULL)
|
|
{
|
|
m_pSceneControl->OnMouseWheel(0, event->delta(), event->x(), event->y());
|
|
}
|
|
}
|
|
|
|
void SceneView::mousePressEvent(QMouseEvent* event)
|
|
{
|
|
if (m_pSceneControl == NULL)
|
|
{
|
|
return;
|
|
}
|
|
int flag = getMouseOrKeyFlag(event);
|
|
|
|
if (event->button() == Qt::LeftButton)
|
|
{// LeftButton
|
|
m_pSceneControl->OnLMouseDown(flag, event->x(), event->y());
|
|
if(m_pSceneControl->GetSceneEditWnd()->GetUserAction()==UGSceneUserAction::suaCreatePolyline)
|
|
this->startTrackingFlag = true;
|
|
// //发送显示航高设置对话框
|
|
// if(this->showSettingFlightPoint)
|
|
// {
|
|
// emit showSettingFlightPointDialg();
|
|
// this->showSettingFlightPoint = false;
|
|
// qDebug()<<"*******************showSettingFlightPointDialg:";
|
|
// }
|
|
}
|
|
else if (event->button() == Qt::RightButton)
|
|
{// RightButton
|
|
m_pSceneControl->OnRMouseDown(flag, event->x(), event->y());
|
|
}
|
|
else if (event->button() == Qt::MidButton)
|
|
{// MidButton
|
|
m_pSceneControl->OnMidMouseDown(flag, event->x(), event->y());
|
|
}
|
|
}
|
|
|
|
void SceneView::mouseReleaseEvent(QMouseEvent* event)
|
|
{
|
|
if (m_pSceneControl == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
int flag = getMouseOrKeyFlag(event);
|
|
|
|
if (event->button() == Qt::LeftButton)
|
|
{// LeftButton
|
|
m_pSceneControl->OnLMouseUp(flag, event->x(), event->y());
|
|
}
|
|
else if (event->button() == Qt::RightButton)
|
|
{// RightButton
|
|
m_pSceneControl->OnRMouseUp(flag, event->x(), event->y());
|
|
if(m_pSceneControl->GetGeoSelections()!=NULL)
|
|
{//当前有选中状态,则右键弹出属性菜单
|
|
// qDebug()<<"********************右键菜单被调用了";
|
|
emit showAttributeMenu();
|
|
}
|
|
}
|
|
else if (event->button() == Qt::MidButton)
|
|
{// MidButton
|
|
m_pSceneControl->OnMidMouseUp(flag, event->x(), event->y());
|
|
}
|
|
}
|
|
|
|
void SceneView::mouseMoveEvent(QMouseEvent* event)
|
|
{
|
|
// qDebug()<<"******************SceneView-mouseMoveEvent:";
|
|
if (m_pSceneControl != NULL)
|
|
{
|
|
m_pSceneControl->OnMouseMove(getMouseOrKeyFlag(event), event->x(), event->y());
|
|
}
|
|
}
|
|
|
|
void SceneView::resizeEvent(QResizeEvent* event)
|
|
{
|
|
QWidget::resizeEvent(event);
|
|
int width = this->width();
|
|
int height = this->height();
|
|
// if (!isRenderTimerStarted && width > 0 & height > 0) {
|
|
// QDesktopWidget* desktop = QApplication::desktop();
|
|
// int logicalDpiX = desktop->logicalDpiX();
|
|
// int logicalDpiY = desktop->logicalDpiY();
|
|
|
|
// m_pSceneControl = new SceneControl((HWND)winId(), logicalDpiX, logicalDpiX);
|
|
|
|
// renderTimer->start(30);
|
|
// isRenderTimerStarted = true;
|
|
// }
|
|
|
|
qDebug() << "SceneView width: " << width << " height: " << height << endl;
|
|
if (m_pSceneControl != NULL && width > 0 & height > 0)
|
|
{
|
|
m_pSceneControl->OnSizeChanged(width, height);
|
|
}
|
|
}
|
|
|
|
void SceneView::keyPressEvent(QKeyEvent* event)
|
|
{
|
|
|
|
}
|
|
|
|
void SceneView::mouseDoubleClickEvent(QMouseEvent *event)
|
|
{
|
|
|
|
}
|
|
|
|
SceneControl* SceneView::GetSceneControl()
|
|
{
|
|
return m_pSceneControl;
|
|
}
|
|
|
|
void SceneView::startRender(int ms)
|
|
{
|
|
renderTimer->start(ms);
|
|
}
|
|
|
|
void SceneView::stopRender()
|
|
{
|
|
renderTimer->stop();
|
|
}
|
|
|
|
void SceneView::RenderInTimer()
|
|
{
|
|
if (NULL != m_pSceneControl)
|
|
{
|
|
if (isVisible()) {
|
|
m_pSceneControl->RenderInTimer();
|
|
}
|
|
}
|
|
}
|
|
|
|
//SceneLayersView* SceneView::getSceneLayersView()
|
|
//{
|
|
//// return pSceneLayersView;
|
|
//}
|