modify osg view widget

This commit is contained in:
jiegeaiai 2025-01-11 22:17:15 +08:00
parent 95882dfee0
commit ed758bc551
4 changed files with 26 additions and 47 deletions

View File

@ -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;
} }

View File

@ -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>

View File

@ -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) {
_scaleLabel->setText(osgEarth::Stringify() emit signalScaleInfo(QString("%1 miUS").arg(feet / 5280.0));
<< feet / 5280.0
<< " miUS");
} else { } else {
_scaleLabel->setText(osgEarth::Stringify() emit signalScaleInfo(QString("%1 ftUS").arg(feet));
<< 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) {
_scaleLabel->setText(osgEarth::Stringify() emit signalScaleInfo(QString("%1 mi").arg(feet / 5280.0));
<< feet / 5280.0
<< " mi");
} else { } else {
_scaleLabel->setText(osgEarth::Stringify() emit signalScaleInfo(QString("%1 ft").arg(feet));
<< 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) {
_scaleLabel->setText(osgEarth::Stringify() emit signalScaleInfo(QString("%1 km").arg(meters * 0.001));
<< meters / 1000.0
<< " km");
} else { } else {
_scaleLabel->setText(osgEarth::Stringify() emit signalScaleInfo(QString("%1 m").arg(meters));
<< meters
<< " m");
}
} }
} break; } break;
} }
*/
} }
void QtOsgViewWidget::Initialize(void) { void QtOsgViewWidget::Initialize(void) {

View File

@ -36,7 +36,7 @@ public:
signals: signals:
void signalResetWorkSpace(); void signalResetWorkSpace();
void signalScaleBarInfo(const QString&); void signalScaleInfo(const QString&);
protected: protected: