Compare commits

...

3 Commits

Author SHA1 Message Date
74f4d658d1 modiyf workspace creat and save, set timestep bug 2025-01-22 02:42:57 +08:00
ca5df0f018 remove notharrow 2025-01-21 23:35:37 +08:00
7d8e072bfe remove qtosgviewwidget 2025-01-21 23:15:01 +08:00
21 changed files with 124 additions and 323 deletions

View File

@ -103,7 +103,7 @@ INCLUDE_DIRECTORIES(
if(MSVC) if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi /Od") #/Od set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi") #/Od
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF") set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
foreach(var foreach(var
@ -185,7 +185,7 @@ endif()
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}) TARGET_LINK_LIBRARIES(${PROJECT_NAME})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE") #SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:CONSOLE")
add_custom_command(TARGET ${PROJECT_NAME} add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD POST_BUILD

View File

@ -10,10 +10,12 @@
#include <osg/Shader> #include <osg/Shader>
#include <osg/Program> #include <osg/Program>
#include <osg/Uniform> #include <osg/Uniform>
#include <osg/Depth>
#include <osgEarth/Registry>
ConeWave::ConeWave() { ConeWave::ConeWave() {
osgEarth::Registry::shaderGenerator().run(this);
} }
@ -27,6 +29,10 @@ void ConeWave::Render(double dt) {
void ConeWave::InitGeode() { void ConeWave::InitGeode() {
CreateTexturedCone(this); CreateTexturedCone(this);
//getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
//getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
//getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
//setCullingActive(false);
} }
void ConeWave::Destory() { void ConeWave::Destory() {
@ -76,7 +82,15 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) {
tesselate->setCreateBottom(false); tesselate->setCreateBottom(false);
tesselate->setCreateBackFace(false); tesselate->setCreateBackFace(false);
coneDrawable_ = new osg::ShapeDrawable(cone_, tesselate); coneDrawable_ = new osg::ShapeDrawable(cone_, tesselate);
addDrawable(coneDrawable_); geode->addDrawable(coneDrawable_);
//coneDrawable_->setColor(baseColor_);
//osg::StateSet* ss = coneDrawable_->getOrCreateStateSet();
////stateset->setRenderBinDetails(120, "OSGEARTH_SCREEN_SPACE_LAYOUT_BIN");
//ss->setRenderBinDetails(120, "RenderBin");
//osg::ref_ptr<osg::BlendFunc> bf = new osg::BlendFunc();
//ss->setAttributeAndModes(bf, osg::StateAttribute::ON);
//ss->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
//return;
static const char* vertSource = { static const char* vertSource = {
"varying vec3 pos;\n" "varying vec3 pos;\n"
@ -128,6 +142,7 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) {
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON); stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
stateset->addUniform(baseColorUniform_); stateset->addUniform(baseColorUniform_);
stateset->setAttributeAndModes(program, osg::StateAttribute::ON); stateset->setAttributeAndModes(program, osg::StateAttribute::ON);
stateset->setAttributeAndModes(new osg::Depth(osg::Depth::LESS, 0.0, 1.0, false));
levelCountUniform_ = new osg::Uniform("num", float(levelCount_)); levelCountUniform_ = new osg::Uniform("num", float(levelCount_));
levelHeightUniform_ = new osg::Uniform("height", levelHeight_); levelHeightUniform_ = new osg::Uniform("height", levelHeight_);

View File

@ -67,7 +67,7 @@ void PathComponent::Begin() {
int num = std::min(steps.size(), transforms.size()); int num = std::min(steps.size(), transforms.size());
for (int index = 0; index < num; ++index) { for (int index = 0; index < num; ++index) {
const Transform& transform = transforms[index]; const Transform& transform = transforms[index];
osg::AnimationPath::ControlPoint controlPoint(transform.GetLocation() + osg::Vec3(index * 10, 0, 0), osg::AnimationPath::ControlPoint controlPoint(transform.GetLocation() /*+ osg::Vec3(index * 10, 0, 0)*/,
OsgUtils::HPRToQuat(transform.GetRotation() + osg::Vec3(0, 0, -90.0)), transform.GetScale()); OsgUtils::HPRToQuat(transform.GetRotation() + osg::Vec3(0, 0, -90.0)), transform.GetScale());
animationPath_->insert(steps[index], controlPoint); animationPath_->insert(steps[index], controlPoint);
} }

View File

@ -63,13 +63,11 @@ void OEScene::AttachView(OsgView* view) {
view->GetView()->setSceneData(root_); view->GetView()->setSceneData(root_);
earthRootNode_ = osgDB::readNodeFile("triton.earth"); earthRootNode_ = osgDB::readNodeFile("triton.earth");
if (!earthRootNode_) { dyt_check(nullptr != earthRootNode_);
LOG_ERROR("read earth node(triton.earth) failed");
return;
}
logarithmicDepthBuffer_ = std::make_unique<osgEarth::Util::LogarithmicDepthBuffer>(); logarithmicDepthBuffer_ = std::make_unique<osgEarth::Util::LogarithmicDepthBuffer>();
earthMapNode_ = osgEarth::MapNode::get(earthRootNode_); earthMapNode_ = osgEarth::MapNode::get(earthRootNode_);
dyt_check(nullptr != earthMapNode_);
LOG_INFO("earth map node get success: {}", earthMapNode_.valid()); LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
g_srs_ = earthMapNode_->getMapSRS(); g_srs_ = earthMapNode_->getMapSRS();

View File

@ -28,9 +28,9 @@ void OESceneUI::InitUI(OsgViewUI* ui) {
} }
compositeWidgetManager_ = new CompositeWidgetManager(); compositeWidgetManager_ = new CompositeWidgetManager();
compositeWidgetManager_->AttachViewUI(ui); //compositeWidgetManager_->AttachViewUI(ui);
zoomManager_ = new ZoomManager(); zoomManager_ = new ZoomManager();
zoomManager_->AttachViewUI(ui); //zoomManager_->AttachViewUI(ui);
queryElevationWidget_ = new QueryElevationWidget(oeScene_); queryElevationWidget_ = new QueryElevationWidget(oeScene_);
queryElevationWidget_->AttachViewUI(ui); queryElevationWidget_->AttachViewUI(ui);

Binary file not shown.

View File

@ -369,25 +369,28 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/Menu/FileManagerMenu.cpp" line="44"/> <location filename="../ui/Menu/FileManagerMenu.cpp" line="45"/>
<location filename="../ui/Menu/FileManagerMenu.cpp" line="60"/>
<source>Dyt (*.dyt)</source> <source>Dyt (*.dyt)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/Menu/FileManagerMenu.cpp" line="47"/> <location filename="../ui/Menu/FileManagerMenu.cpp" line="48"/>
<source>open dyt file</source> <source>open dyt file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/Menu/FileManagerMenu.cpp" line="48"/> <location filename="../ui/Menu/FileManagerMenu.cpp" line="49"/>
<location filename="../ui/Menu/FileManagerMenu.cpp" line="64"/>
<source>Dyt (*.dyt);;All files (*.*)</source> <source>Dyt (*.dyt);;All files (*.*)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/Menu/FileManagerMenu.cpp" line="63"/> <location filename="../ui/Menu/FileManagerMenu.cpp" line="65"/>
<source>save dyt file</source> <source>warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../ui/Menu/FileManagerMenu.cpp" line="65"/>
<source>workspace is nullptr</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
@ -1270,18 +1273,18 @@
<context> <context>
<name>QtOsgViewWidget</name> <name>QtOsgViewWidget</name>
<message> <message>
<location filename="../viewer/QtOsgViewWidget.cpp" line="369"/> <location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
<location filename="../viewer/QtOsgViewWidget.cpp" line="377"/> <location filename="../viewer/QtOsgViewWidget.cpp" line="139"/>
<source>warning</source> <source>warning</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../viewer/QtOsgViewWidget.cpp" line="369"/> <location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
<source>default workspace failed</source> <source>default workspace failed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../viewer/QtOsgViewWidget.cpp" line="377"/> <location filename="../viewer/QtOsgViewWidget.cpp" line="139"/>
<source>open dyt file failed</source> <source>open dyt file failed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -1297,7 +1300,7 @@
<message> <message>
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8683"/> <location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8683"/>
<source>Path</source> <source>Path</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context> <context>
@ -1516,12 +1519,12 @@
<message> <message>
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="454"/> <location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="454"/>
<source>Property</source> <source>Property</source>
<translation type="unfinished"></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="455"/> <location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="455"/>
<source>Value</source> <source>Value</source>
<translation type="unfinished"></translation> <translation></translation>
</message> </message>
</context> </context>
<context> <context>
@ -1764,53 +1767,51 @@
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="52"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="58"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="63"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="68"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="75"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="80"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="84"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="89"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="90"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="95"/>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="100"/>
<source>warning</source> <source>warning</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="52"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
<source>name or save path is empty, please check it</source> <source>name or save path is empty, please check it</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="58"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="63"/>
<source>save current workspace?</source> <source>save current workspace?</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="68"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
<source>current path is contains current folder, do you want to overwrite it?</source> <source>current path is contains current folder, do you want to overwrite it?</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="75"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="80"/>
<source>removeRecursively failed</source> <source>removeRecursively failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="84"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="89"/>
<source>mkpath failed</source> <source>mkpath failed</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="90"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="95"/>
<source>name is exits</source> <source>name is exits</source>
<translation></translation> <translation></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="100"/>
<source>create workSpace failed</source> <source>create workSpace failed</source>
<translation></translation> <translation type="vanished"></translation>
</message> </message>
<message> <message>
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="111"/> <location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="110"/>
<source>save spaceWork directory</source> <source>save spaceWork directory</source>
<translation></translation> <translation></translation>
</message> </message>

View File

@ -12,6 +12,7 @@
#include "common/SpdLogger.h" #include "common/SpdLogger.h"
#include "workspace/WorkSpace.h" #include "workspace/WorkSpace.h"
#include "workspace/WorkSpaceManager.h" #include "workspace/WorkSpaceManager.h"
#include "utils/FileUtils.h"
#include "ui_FileManagerMenu.h" #include "ui_FileManagerMenu.h"
@ -57,23 +58,31 @@ void FileManagerMenu::OpenWorkSpace() {
void FileManagerMenu::SaveWorkSpace() { void FileManagerMenu::SaveWorkSpace() {
LOG_INFO("click SaveWorkSpace"); LOG_INFO("click SaveWorkSpace");
QString selfilter = tr("Dyt (*.dyt)");
const QString workspacePath = Application::GetWorkSpacePath();
QString dytFile = QFileDialog::getSaveFileName(&MainFrame::Get(), tr("save dyt file"), workspacePath,
tr("Dyt (*.dyt);;All files (*.*)"),
&selfilter);
LOG_INFO("user select file: {}", dytFile.toStdString());
if (dytFile.isEmpty()) {
return;
}
WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent(); WorkSpace* workspace = WorkSpaceManager::Get().GetCurrent();
if (nullptr == workspace) { if (nullptr == workspace) {
LOG_WARN("workspace is nullptr"); LOG_WARN("workspace is nullptr");
QMessageBox::warning(&MainFrame::Get(), tr("warning"), tr("workspace is nullptr"));
return; return;
} }
const QString name = workspace->GetName();
QString dytFile = workspace->GetPath();
LOG_INFO("save {} dyt file: {}", name.toLocal8Bit().constData(),
dytFile.toLocal8Bit().constData());
/* if (!FileUtils::IsExist(dytFile)) {
QString selfilter = tr("Dyt (*.dyt)");
const QString workspacePath = Application::GetWorkSpacePath();
dytFile = QFileDialog::getSaveFileName(&MainFrame::Get(), tr("save dyt file"), workspacePath,
tr("Dyt (*.dyt);;All files (*.*)"),
&selfilter);
LOG_INFO("user select file: {}", dytFile.toLocal8Bit().constData());
if (dytFile.isEmpty()) {
return;
}
}*/
bool success = workspace->Save(dytFile); bool success = workspace->Save(dytFile);
LOG_INFO("save dyt: {}", success); LOG_INFO("save dyt: {}", success);
} }

View File

@ -751,12 +751,12 @@ void QFilePathEdit::onFileSelect() {
return; return;
} }
} }
if (!FileUtils::CopyFileToPath(filePath, filePath, true)) { if (!FileUtils::CopyFileToPath(filePath, savePath, true)) {
LOG_ERROR("Failed to copy file to workspace"); LOG_ERROR("Failed to copy file to workspace");
QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace"); QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace");
return; return;
} }
LOG_INFO("PathComponent::SetPath: {}", workPath.toStdString().c_str()); LOG_INFO("SetPath: {}", savePath.toLocal8Bit().constData());
m_initialvalue = m_fileName; m_initialvalue = m_fileName;
m_stringEdit->setText(m_fileName); m_stringEdit->setText(m_fileName);
} }

View File

@ -26,8 +26,8 @@ WorkSpaceDlg::WorkSpaceDlg(QWidget* parent)
SetTitle(tr("new workspace")); SetTitle(tr("new workspace"));
const QString path = qApp->applicationDirPath() + "/workspace"; path_ = qApp->applicationDirPath() + "/workspace";
ui->lePath->setText(path); ui->lePath->setText(path_);
//setFixedHeight(500); //setFixedHeight(500);
} }
@ -39,15 +39,20 @@ void WorkSpaceDlg::InitConnect() {
connect(ui->pbSure, &QPushButton::clicked, this, &WorkSpaceDlg::OnSure); connect(ui->pbSure, &QPushButton::clicked, this, &WorkSpaceDlg::OnSure);
connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject); connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject);
connect(ui->tbPath, &QPushButton::clicked, this, &WorkSpaceDlg::OnSelectSavePath); connect(ui->tbPath, &QPushButton::clicked, this, &WorkSpaceDlg::OnSelectSavePath);
connect(ui->leName, &QLineEdit::textChanged, [this](const QString& txt) {
QString path = QString("%1/%2").arg(path_).arg(txt);
ui->lePath->setText(path);
}
);
//connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject); //connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject);
} }
void WorkSpaceDlg::OnSure() { void WorkSpaceDlg::OnSure() {
const QString name = ui->leName->text(); const QString name = ui->leName->text();
const QString savePath = ui->lePath->text();
LOG_INFO("name:{}, save path:{}", name.toStdString(), savePath.toStdString()); LOG_INFO("name:{}, save path:{}", name.toLocal8Bit().constData(), path_.toLocal8Bit().constData());
if (name.isEmpty() || savePath.isEmpty()) { if (name.isEmpty() || path_.isEmpty()) {
LOG_WARN("name or save path is empty"); LOG_WARN("name or save path is empty");
QMessageBox::warning(this, tr("warning"), tr("name or save path is empty, please check it")); QMessageBox::warning(this, tr("warning"), tr("name or save path is empty, please check it"));
return; return;
@ -61,7 +66,7 @@ void WorkSpaceDlg::OnSure() {
current->Unlaod(); current->Unlaod();
} }
QString workspacePath = QString("%1/%2").arg(savePath).arg(name); QString workspacePath = QString("%1/%2").arg(path_).arg(name);
QDir dir(workspacePath); QDir dir(workspacePath);
if (dir.exists()) { if (dir.exists()) {
LOG_WARN("current path is contains current folder, {}", workspacePath.toStdString()); LOG_WARN("current path is contains current folder, {}", workspacePath.toStdString());
@ -95,12 +100,6 @@ void WorkSpaceDlg::OnSure() {
WorkSpace* workSpace = WorkSpaceManager::Get().GetOrCreate(workspacePath, name); WorkSpace* workSpace = WorkSpaceManager::Get().GetOrCreate(workspacePath, name);
workSpace->SetDescribe(ui->etDescribe->toPlainText()); workSpace->SetDescribe(ui->etDescribe->toPlainText());
if (!workSpace->Save(workspacePath)) {
LOG_ERROR("save workSpace failed");
QMessageBox::warning(this, tr("warning"), tr("create workSpace failed"));
return;
}
WorkSpaceManager::Get().SetCurrent(workSpace); WorkSpaceManager::Get().SetCurrent(workSpace);
accept(); accept();
} }
@ -113,9 +112,9 @@ void WorkSpaceDlg::OnSelectSavePath() {
LOG_WARN("save path is empty"); LOG_WARN("save path is empty");
return; return;
} }
path_ = savePath;
ui->lePath->setText(savePath); ui->lePath->setText(QString("%1/%2").arg(path_).arg(ui->leName->text()));
LOG_INFO("save path: {}", savePath.toStdString()); LOG_INFO("save path: {}", path_.toLocal8Bit().constData());
} }
void WorkSpaceDlg::InitFrame() { void WorkSpaceDlg::InitFrame() {

View File

@ -23,4 +23,5 @@ protected:
private: private:
Ui::WorkSpaceDlg* ui; Ui::WorkSpaceDlg* ui;
QString path_;
}; };

View File

@ -22,6 +22,7 @@ TransformPath::~TransformPath() {
} }
TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) { TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) {
LOG_INFO("Loading transform path from file: {}", path.toLocal8Bit().constData());
QFile file(path); QFile file(path);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
@ -42,7 +43,7 @@ TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent)
bool ok; bool ok;
double value = line.toDouble(&ok); double value = line.toDouble(&ok);
if (ok) { if (ok) {
transform.GetLocation()[i] = value * 1.5; transform.GetLocation()[i] = value;
} else { } else {
LOG_WARN("Failed to convert line to double: {}", line.toStdString()); LOG_WARN("Failed to convert line to double: {}", line.toStdString());
return {}; return {};

View File

@ -46,12 +46,16 @@ void OsgView::InitGraphiceWindow(int x, int y, int width, int height,
#endif // _WIN32 #endif // _WIN32
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
osg::GraphicsContext::Traits* traits = new osg::GraphicsContext::Traits(ds); osg::GraphicsContext::Traits* traits = new osg::GraphicsContext::Traits(ds);
traits->windowDecoration = windowDecoration;
traits->windowName = name; traits->windowName = name;
traits->x = x; traits->x = x;
traits->y = y; traits->y = y;
traits->width = width; traits->width = width;
traits->height = height; traits->height = height;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
traits->sampleBuffers = ds->getMultiSamples();
traits->samples = ds->getNumMultiSamples();
traits->windowDecoration = windowDecoration;
traits->doubleBuffer = true; traits->doubleBuffer = true;
traits->sharedContext = nullptr; traits->sharedContext = nullptr;
traits->setInheritedWindowPixelFormat = true; traits->setInheritedWindowPixelFormat = true;
@ -59,10 +63,9 @@ void OsgView::InitGraphiceWindow(int x, int y, int width, int height,
traits->inheritedWindowData = windata; traits->inheritedWindowData = windata;
#endif #endif
graphiceWindow_ = osg::GraphicsContext::createGraphicsContext(traits); graphiceWindow_ = osg::GraphicsContext::createGraphicsContext(traits);
#if USE_OCEAN #if USE_OCEAN
graphiceWindow_->getState()->setUseModelViewAndProjectionUniforms(false); graphiceWindow_->getState()->setUseModelViewAndProjectionUniforms(false);
graphiceWindow_->getState()->setUseVertexAttributeAliasing(false); graphiceWindow_->getState()->setUseVertexAttributeAliasing(true);
#endif #endif
} }

View File

@ -33,142 +33,6 @@
#include "ui/MainFrame.h" #include "ui/MainFrame.h"
double normalizeScaleMeters(double meters) {
if (meters <= 3) {
meters = 1;
} else if (meters <= 7.5) {
meters = 5;
} else if (meters <= 15) {
meters = 10;
} else if (meters <= 35) {
meters = 20;
} else if (meters <= 75) {
meters = 50;
} else if (meters <= 150) {
meters = 100;
} else if (meters <= 350) {
meters = 200;
} else if (meters <= 750) {
meters = 500;
} else if (meters <= 1500) {
meters = 1000;
} else if (meters <= 3500) {
meters = 2000;
} else if (meters <= 7500) {
meters = 5000;
} else if (meters <= 15000) {
meters = 10000;
} else if (meters <= 35000) {
meters = 20000;
} else if (meters <= 55000) {
meters = 50000;
} else if (meters <= 150000) {
meters = 100000;
} else if (meters <= 350000) {
meters = 200000;
} else if (meters <= 750000) {
meters = 500000;
} else if (meters <= 1500000) {
meters = 1000000;
} else {
meters = 2000000;
}
return meters;
}
double normalizeScaleFeet(double feet) {
double feetPerMile = 5280.0;
if (feet <= 7.5) {
feet = 5;
} else if (feet <= 15) {
feet = 10;
} else if (feet <= 35) {
feet = 20;
} else if (feet <= 75) {
feet = 50;
} else if (feet <= 150) {
feet = 100;
} else if (feet <= 350) {
feet = 200;
} else if (feet <= 750) {
feet = 500;
} else if (feet <= 1500) {
feet = 1000;
} else if (feet <= 3640) {
feet = 2000;
} else if (feet <= 1.5 * feetPerMile) {
feet = 1 * feetPerMile;
} else if (feet <= 3.5 * feetPerMile) {
feet = 2 * feetPerMile;
} else if (feet <= 7.5 * feetPerMile) {
feet = 5 * feetPerMile;
} else if (feet <= 15 * feetPerMile) {
feet = 10 * feetPerMile;
} else if (feet <= 35 * feetPerMile) {
feet = 20 * feetPerMile;
} else if (feet <= 75 * feetPerMile) {
feet = 50 * feetPerMile;
} else if (feet <= 150 * feetPerMile) {
feet = 100 * feetPerMile;
} else if (feet <= 350 * feetPerMile) {
feet = 200 * feetPerMile;
} else if (feet <= 750 * feetPerMile) {
feet = 500 * feetPerMile;
} else if (feet <= 1500 * feetPerMile) {
feet = 1000 * feetPerMile;
} else {
feet = 2000 * feetPerMile;
}
return feet;
}
double normalizeScaleNauticalMiles(double nmi) {
//double feetPerMile = 6076.12;
if (nmi <= 0.0015) {
nmi = 0.001;
} else if (nmi <= 0.0035) {
nmi = 0.002;
} else if (nmi <= 0.0075) {
nmi = 0.005;
} else if (nmi <= 0.015) {
nmi = 0.01;
} else if (nmi <= 0.035) {
nmi = 0.02;
} else if (nmi <= 0.075) {
nmi = 0.05;
} else if (nmi <= 0.15) {
nmi = 0.1;
} else if (nmi <= 0.35) {
nmi = 0.2;
} else if (nmi <= 0.75) {
nmi = 0.5;
} else if (nmi <= 1.5) {
nmi = 1;
} else if (nmi <= 3.5) {
nmi = 2;
} else if (nmi <= 7.5) {
nmi = 5;
} else if (nmi <= 15) {
nmi = 10;
} else if (nmi <= 35) {
nmi = 20;
} else if (nmi <= 75) {
nmi = 50;
} else if (nmi <= 150) {
nmi = 100;
} else if (nmi <= 350) {
nmi = 200;
} else if (nmi <= 750) {
nmi = 500;
} else if (nmi <= 1500) {
nmi = 1000;
} else {
nmi = 2000;
}
return nmi;
}
QtOsgViewWidget::QtOsgViewWidget(QWidget* parent) QtOsgViewWidget::QtOsgViewWidget(QWidget* parent)
: QWidget(parent) { : QWidget(parent) {
LOG_INFO("actor, self={}", fmt::ptr(this)); LOG_INFO("actor, self={}", fmt::ptr(this));
@ -196,108 +60,6 @@ void QtOsgViewWidget::keyReleaseEvent(QKeyEvent* event) {
view_->KeyRelease(event); view_->KeyRelease(event);
} }
void QtOsgViewWidget::OnComputeScale() {
osgEarth::MapNode* mapNode = activeScene_->GetMapNode();
if (nullptr == mapNode || nullptr == mapNode->getTerrain()) {
return;
}
dyt_check(nullptr != view_);
float x = 0.0f, y = 0.0f;
osg::Vec3d world1, world2;
if (!mapNode->getTerrain()->getWorldCoordsUnderMouse(view_->GetView(), x, y, world1)) {
emit signalScaleInfo("");
return;
}
x += devicePixelRatio_;
if (!mapNode->getTerrain()->getWorldCoordsUnderMouse(view_->GetView(), x, y, world2)) {
emit signalScaleInfo("");
return;
}
#if 0
TRACE("w1: %g %g %g w2: %g %g %g",
world1.x(), world1.y(), world1.z(),
world2.x(), world2.y(), world2.z());
#endif
double meters;
double radius = 6378137.0;
dyt_check(nullptr != g_srs_);
radius = g_srs_->getEllipsoid().getRadiusEquator();
if (!g_srs_->isGeocentric() ) {
// TRACE("Map is geographic");
// World cords are already lat/long
// Compute great circle distance
meters = osgEarth::GeoMath::distance(world1, world2, g_srs_);
} else {
osgEarth::GeoPoint mapPoint1, mapPoint2;
mapPoint1.fromWorld(g_srs_, world1);
mapPoint1.makeGeographic();
mapPoint2.fromWorld(g_srs_, world2);
mapPoint2.makeGeographic();
// Compute great circle distance
meters = osgEarth::GeoMath::distance(osg::DegreesToRadians(mapPoint1.y()),
osg::DegreesToRadians(mapPoint1.x()),
osg::DegreesToRadians(mapPoint2.y()),
osg::DegreesToRadians(mapPoint2.x()),
radius);
}
double scale = meters / devicePixelRatio_;
double pixelWidth = devicePixelRatio_ * 2.0;
// 1mi = 5280 feet
//double scaleMiles = scale / 1609.344; // International mile = 1609.344m
//double scaleNauticalMiles = scale / 1852.0; // nautical mile = 1852m
//double scaleUSSurveyMiles = scale / 1609.347218694; // US survey mile = 5280 US survey feet
//double scaleUSSurveyFeet = scale * 3937.0/1200.0; // US survey foot = 1200/3937 m
#if 0
TRACE("m: %g px: %g m/px: %g", meters, pixelWidth, scale);
#endif
switch (scaleUnits_) {
case ScaleBarHandler::Delegate::Units::UNITS_NAUTICAL_MILES: {
double nmi = meters / 1852.0;
scale = nmi / devicePixelRatio_;
nmi = normalizeScaleNauticalMiles(nmi);
pixelWidth = nmi / scale;
emit signalScaleInfo(QString("%1 nmi").arg(nmi));
} break;
case ScaleBarHandler::Delegate::Units::UNITS_US_SURVEY_FEET: {
double feet = meters * 3937.0 / 1200.0;
scale = feet / pixelWidth;
feet = normalizeScaleFeet(feet);
pixelWidth = feet / scale;
if (feet >= 5280) {
emit signalScaleInfo(QString("%1 miUS").arg(feet / 5280.0));
} else {
emit signalScaleInfo(QString("%1 ftUS").arg(feet));
}
} break;
case ScaleBarHandler::Delegate::Units::UNITS_INTL_FEET: {
double feet = 5280.0 * meters / 1609.344;
scale = feet / pixelWidth;
feet = normalizeScaleFeet(feet);
pixelWidth = feet / scale;
if (feet >= 5280) {
emit signalScaleInfo(QString("%1 mi").arg(feet / 5280.0));
} else {
emit signalScaleInfo(QString("%1 ft").arg(feet));
}
} break;
case ScaleBarHandler::Delegate::Units::UNITS_METERS:
default: {
meters = normalizeScaleMeters(meters);
pixelWidth = meters / scale;
if (meters >= 1000) {
emit signalScaleInfo(QString("%1 km").arg(meters * 0.001));
} else {
emit signalScaleInfo(QString("%1 m").arg(meters));
}
} break;
}
}
void QtOsgViewWidget::Initialize(void) { void QtOsgViewWidget::Initialize(void) {
if (view_) { if (view_) {
LOG_INFO("view is created"); LOG_INFO("view is created");

View File

@ -13,7 +13,7 @@ class QKeyEvent;
class QInputEvent; class QInputEvent;
class QResizeEvent; class QResizeEvent;
class QtOsgViewWidget : public QWidget, public ScaleBarHandler::Delegate { class QtOsgViewWidget : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit QtOsgViewWidget(QWidget* parent = nullptr); explicit QtOsgViewWidget(QWidget* parent = nullptr);
@ -24,8 +24,6 @@ public:
return nullptr; return nullptr;
} }
void OnComputeScale() override;
void Initialize(void); void Initialize(void);
void Uninitialize(void); void Uninitialize(void);

View File

@ -16,13 +16,13 @@ Timestep::Timestep(const std::vector<double>& steps, const QString& path, WorkSp
maxTime_ = *steps_.rbegin(); maxTime_ = *steps_.rbegin();
} }
Timestep* Timestep::Load(const QString& path, WorkSpace* parent) { Timestep* Timestep::Load(const QString& path, WorkSpace* workSpace) {
const QString filePath = QString("%1/%2").arg(RecourceHelper::Get().GetBasePath()).arg(path); const QString filePath = QString("%1/%2").arg(workSpace->GetDir()).arg(path);
LOG_INFO("Load timestep: {}", filePath.toStdString()); LOG_INFO("Load timestep: {}", filePath.toStdString());
QFile file(filePath); QFile file(filePath);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
LOG_WARN("Cannot open file for reading: {}", file.errorString().toStdString()); LOG_WARN("Cannot open file for reading: {}", file.errorString().toLocal8Bit().constData());
return nullptr; return nullptr;
} }
@ -42,7 +42,7 @@ Timestep* Timestep::Load(const QString& path, WorkSpace* parent) {
file.close(); file.close();
Timestep* timestep = new Timestep(numbers, path, parent); Timestep* timestep = new Timestep(numbers, path, workSpace);
return timestep; return timestep;
} }

View File

@ -20,7 +20,7 @@ public:
explicit Timestep(const std::vector<double>& steps, const QString& path, WorkSpace* parent = nullptr) noexcept; explicit Timestep(const std::vector<double>& steps, const QString& path, WorkSpace* parent = nullptr) noexcept;
~Timestep() override = default; ~Timestep() override = default;
static Timestep* Load(const QString& path, WorkSpace* parent = nullptr); static Timestep* Load(const QString& path, WorkSpace* workSpace = nullptr);
const std::vector<double>& GetSteps() const { const std::vector<double>& GetSteps() const {
return steps_; return steps_;

View File

@ -105,6 +105,19 @@ bool WorkSpaceManager::Remove(const QString& name) {
return true; return true;
} }
bool WorkSpaceManager::Remove(WorkSpace* workspace) {
if (nullptr == workspace) {
LOG_ERROR("workspace is nullptr");
return true;
}
auto itor = workSpaces_.find(workspace->GetPath());
if (workSpaces_.end() == itor) {
return true;
}
workSpaces_.erase(itor);
}
WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) { WorkSpace* WorkSpaceManager::LoadDyt(const QString& dyt) {
dyt_check(nullptr != scene_); dyt_check(nullptr != scene_);
LOG_INFO("load workspace name:{}", dyt.toLocal8Bit().constData()); LOG_INFO("load workspace name:{}", dyt.toLocal8Bit().constData());
@ -126,7 +139,7 @@ WorkSpace* WorkSpaceManager::GetOrCreate(const QString& path, const QString& nam
return itor->second; return itor->second;
} }
LOG_INFO("create workspace name:{}", path.toStdString()); LOG_INFO("create workspace name:{}", path.toLocal8Bit().constData());
WorkSpace* workspace = new WorkSpace(path, this); WorkSpace* workspace = new WorkSpace(path, this);
workspace->SetName(name); workspace->SetName(name);
workSpaces_[path] = workspace; workSpaces_[path] = workspace;

View File

@ -26,6 +26,7 @@ public:
bool Remove(const QString& name); bool Remove(const QString& name);
WorkSpace* LoadDyt(const QString& dyt); WorkSpace* LoadDyt(const QString& dyt);
WorkSpace* GetOrCreate(const QString& path, const QString& name); WorkSpace* GetOrCreate(const QString& path, const QString& name);
bool Remove(WorkSpace* workspace);
void SetCurrent(WorkSpace* workspace); void SetCurrent(WorkSpace* workspace);
WorkSpace* GetCurrent() const { return current_; } WorkSpace* GetCurrent() const { return current_; }

View File

@ -178,7 +178,7 @@ bool WorkSpaceXMLParse::ParseReport(const tinyxml2::XMLElement* element)
} }
bool WorkSpaceXMLParse::Load(const QString& dyt) { bool WorkSpaceXMLParse::Load(const QString& dyt) {
std::string path = dyt.toStdString(); std::string path = dyt.toLocal8Bit().constData();
LOG_INFO("load path:{}", path); LOG_INFO("load path:{}", path);
tinyxml2::XMLDocument xmlDocument; tinyxml2::XMLDocument xmlDocument;
tinyxml2::XMLError error = xmlDocument.LoadFile(path.c_str()); tinyxml2::XMLError error = xmlDocument.LoadFile(path.c_str());

View File

@ -16,7 +16,7 @@ WorkSpaceXMLWrite::WorkSpaceXMLWrite(WorkSpace* workspace, QObject* parent) noex
, workSpace_(workspace) {} , workSpace_(workspace) {}
bool WorkSpaceXMLWrite::Save(const QString& path) { bool WorkSpaceXMLWrite::Save(const QString& path) {
LOG_INFO("save path: {}", path.toStdString()); LOG_INFO("save path: {}", path.toLocal8Bit().constData());
if (nullptr == workSpace_) { if (nullptr == workSpace_) {
LOG_WARN("worksapce is nullptr"); LOG_WARN("worksapce is nullptr");
return false; return false;
@ -41,7 +41,7 @@ bool WorkSpaceXMLWrite::Save(const QString& path) {
entity->UnSerialize(entitiesXml); entity->UnSerialize(entitiesXml);
} }
tinyxml2::XMLError xmlError = doc.SaveFile(path.toStdString().c_str(), false); tinyxml2::XMLError xmlError = doc.SaveFile(path.toLocal8Bit().constData(), false);
if (tinyxml2::XML_SUCCESS != xmlError) { if (tinyxml2::XML_SUCCESS != xmlError) {
LOG_WARN("worksapce is nullptr"); LOG_WARN("worksapce is nullptr");
return false; return false;