modify osg view widget
This commit is contained in:
parent
95882dfee0
commit
ed758bc551
@ -3,6 +3,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "workspace/WorkSpace.h"
|
#include "workspace/WorkSpace.h"
|
||||||
|
#include "workspace/WorkSpaceManager.h"
|
||||||
#include "common/SpdLogger.h"
|
#include "common/SpdLogger.h"
|
||||||
#include "entities/Entity.h"
|
#include "entities/Entity.h"
|
||||||
#include "entities/ComponentFactory.h"
|
#include "entities/ComponentFactory.h"
|
||||||
@ -70,9 +71,10 @@ bool EntitiesManager::Parse(const tinyxml2::XMLElement* element, WorkSpace* work
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity* EntitiesManager::Create(const QString& name) {
|
Entity* EntitiesManager::Create(const QString& name) {
|
||||||
/* if (name == "Entity") {
|
if (name == "Entity") {
|
||||||
return new Entity(this);
|
//WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent();
|
||||||
}*/
|
return new Entity(name);
|
||||||
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,18 +1267,18 @@
|
|||||||
<context>
|
<context>
|
||||||
<name>QtOsgViewWidget</name>
|
<name>QtOsgViewWidget</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="389"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="366"/>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="397"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="374"/>
|
||||||
<source>warning</source>
|
<source>warning</source>
|
||||||
<translation>警告</translation>
|
<translation>警告</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="389"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="366"/>
|
||||||
<source>default workspace failed</source>
|
<source>default workspace failed</source>
|
||||||
<translation>加载默认空间失败</translation>
|
<translation>加载默认空间失败</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="397"/>
|
<location filename="../viewer/QtOsgViewWidget.cpp" line="374"/>
|
||||||
<source>open dyt file failed</source>
|
<source>open dyt file failed</source>
|
||||||
<translation>打开空间文件失败</translation>
|
<translation>打开空间文件失败</translation>
|
||||||
</message>
|
</message>
|
||||||
|
@ -204,12 +204,12 @@ void QtOsgViewWidget::OnComputeScale() {
|
|||||||
float x = 0.0f, y = 0.0f;
|
float x = 0.0f, y = 0.0f;
|
||||||
osg::Vec3d world1, world2;
|
osg::Vec3d world1, world2;
|
||||||
if (!mapNode->getTerrain()->getWorldCoordsUnderMouse(view_->GetView(), x, y, world1)) {
|
if (!mapNode->getTerrain()->getWorldCoordsUnderMouse(view_->GetView(), x, y, world1)) {
|
||||||
emit signalScaleBarInfo("");
|
emit signalScaleInfo("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
x += devicePixelRatio_;
|
x += devicePixelRatio_;
|
||||||
if (!mapNode->getTerrain()->getWorldCoordsUnderMouse(view_->GetView(), x, y, world2)) {
|
if (!mapNode->getTerrain()->getWorldCoordsUnderMouse(view_->GetView(), x, y, world2)) {
|
||||||
emit signalScaleBarInfo("");
|
emit signalScaleInfo("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,33 +253,23 @@ void QtOsgViewWidget::OnComputeScale() {
|
|||||||
#if 0
|
#if 0
|
||||||
TRACE("m: %g px: %g m/px: %g", meters, pixelWidth, scale);
|
TRACE("m: %g px: %g m/px: %g", meters, pixelWidth, scale);
|
||||||
#endif
|
#endif
|
||||||
/* switch (scaleUnits_) {
|
switch (scaleUnits_) {
|
||||||
case ScaleBarHandler::Delegate::Units::UNITS_NAUTICAL_MILES: {
|
case ScaleBarHandler::Delegate::Units::UNITS_NAUTICAL_MILES: {
|
||||||
double nmi = meters / 1852.0;
|
double nmi = meters / 1852.0;
|
||||||
scale = nmi / devicePixelRatio_;
|
scale = nmi / devicePixelRatio_;
|
||||||
nmi = normalizeScaleNauticalMiles(nmi);
|
nmi = normalizeScaleNauticalMiles(nmi);
|
||||||
pixelWidth = nmi / scale;
|
pixelWidth = nmi / scale;
|
||||||
if (_scaleLabel.valid()) {
|
emit signalScaleInfo(QString("%1 nmi").arg(nmi));
|
||||||
_scaleLabel->setText(osgEarth::Stringify()
|
|
||||||
<< nmi
|
|
||||||
<< " nmi");
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
case ScaleBarHandler::Delegate::Units::UNITS_US_SURVEY_FEET: {
|
case ScaleBarHandler::Delegate::Units::UNITS_US_SURVEY_FEET: {
|
||||||
double feet = meters * 3937.0 / 1200.0;
|
double feet = meters * 3937.0 / 1200.0;
|
||||||
scale = feet / pixelWidth;
|
scale = feet / pixelWidth;
|
||||||
feet = normalizeScaleFeet(feet);
|
feet = normalizeScaleFeet(feet);
|
||||||
pixelWidth = feet / scale;
|
pixelWidth = feet / scale;
|
||||||
if (_scaleLabel.valid()) {
|
if (feet >= 5280) {
|
||||||
if (feet >= 5280) {
|
emit signalScaleInfo(QString("%1 miUS").arg(feet / 5280.0));
|
||||||
_scaleLabel->setText(osgEarth::Stringify()
|
} else {
|
||||||
<< feet / 5280.0
|
emit signalScaleInfo(QString("%1 ftUS").arg(feet));
|
||||||
<< " miUS");
|
|
||||||
} else {
|
|
||||||
_scaleLabel->setText(osgEarth::Stringify()
|
|
||||||
<< feet
|
|
||||||
<< " ftUS");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case ScaleBarHandler::Delegate::Units::UNITS_INTL_FEET: {
|
case ScaleBarHandler::Delegate::Units::UNITS_INTL_FEET: {
|
||||||
@ -287,36 +277,23 @@ void QtOsgViewWidget::OnComputeScale() {
|
|||||||
scale = feet / pixelWidth;
|
scale = feet / pixelWidth;
|
||||||
feet = normalizeScaleFeet(feet);
|
feet = normalizeScaleFeet(feet);
|
||||||
pixelWidth = feet / scale;
|
pixelWidth = feet / scale;
|
||||||
if (_scaleLabel.valid()) {
|
if (feet >= 5280) {
|
||||||
if (feet >= 5280) {
|
emit signalScaleInfo(QString("%1 mi").arg(feet / 5280.0));
|
||||||
_scaleLabel->setText(osgEarth::Stringify()
|
} else {
|
||||||
<< feet / 5280.0
|
emit signalScaleInfo(QString("%1 ft").arg(feet));
|
||||||
<< " mi");
|
|
||||||
} else {
|
|
||||||
_scaleLabel->setText(osgEarth::Stringify()
|
|
||||||
<< feet
|
|
||||||
<< " ft");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case ScaleBarHandler::Delegate::Units::UNITS_METERS:
|
case ScaleBarHandler::Delegate::Units::UNITS_METERS:
|
||||||
default: {
|
default: {
|
||||||
meters = normalizeScaleMeters(meters);
|
meters = normalizeScaleMeters(meters);
|
||||||
pixelWidth = meters / scale;
|
pixelWidth = meters / scale;
|
||||||
if (_scaleLabel.valid()) {
|
if (meters >= 1000) {
|
||||||
if (meters >= 1000) {
|
emit signalScaleInfo(QString("%1 km").arg(meters * 0.001));
|
||||||
_scaleLabel->setText(osgEarth::Stringify()
|
} else {
|
||||||
<< meters / 1000.0
|
emit signalScaleInfo(QString("%1 m").arg(meters));
|
||||||
<< " km");
|
|
||||||
} else {
|
|
||||||
_scaleLabel->setText(osgEarth::Stringify()
|
|
||||||
<< meters
|
|
||||||
<< " m");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtOsgViewWidget::Initialize(void) {
|
void QtOsgViewWidget::Initialize(void) {
|
||||||
|
@ -36,7 +36,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalResetWorkSpace();
|
void signalResetWorkSpace();
|
||||||
void signalScaleBarInfo(const QString&);
|
void signalScaleInfo(const QString&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user