Compare commits
3 Commits
63fd5665f8
...
74f4d658d1
Author | SHA1 | Date | |
---|---|---|---|
74f4d658d1 | |||
ca5df0f018 | |||
7d8e072bfe |
@ -103,7 +103,7 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
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")
|
||||
|
||||
foreach(var
|
||||
@ -185,7 +185,7 @@ endif()
|
||||
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ProjectDIR}/bin)
|
||||
|
||||
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}
|
||||
POST_BUILD
|
||||
|
@ -10,10 +10,12 @@
|
||||
#include <osg/Shader>
|
||||
#include <osg/Program>
|
||||
#include <osg/Uniform>
|
||||
#include <osg/Depth>
|
||||
#include <osgEarth/Registry>
|
||||
|
||||
|
||||
ConeWave::ConeWave() {
|
||||
|
||||
osgEarth::Registry::shaderGenerator().run(this);
|
||||
}
|
||||
|
||||
|
||||
@ -27,6 +29,10 @@ void ConeWave::Render(double dt) {
|
||||
|
||||
void ConeWave::InitGeode() {
|
||||
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() {
|
||||
@ -76,7 +82,15 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) {
|
||||
tesselate->setCreateBottom(false);
|
||||
tesselate->setCreateBackFace(false);
|
||||
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 = {
|
||||
"varying vec3 pos;\n"
|
||||
@ -128,6 +142,7 @@ void ConeWave::CreateTexturedCone(osg::Geode* geode) {
|
||||
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::ON);
|
||||
stateset->addUniform(baseColorUniform_);
|
||||
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_));
|
||||
levelHeightUniform_ = new osg::Uniform("height", levelHeight_);
|
||||
|
@ -67,7 +67,7 @@ void PathComponent::Begin() {
|
||||
int num = std::min(steps.size(), transforms.size());
|
||||
for (int index = 0; index < num; ++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());
|
||||
animationPath_->insert(steps[index], controlPoint);
|
||||
}
|
||||
|
@ -63,13 +63,11 @@ void OEScene::AttachView(OsgView* view) {
|
||||
view->GetView()->setSceneData(root_);
|
||||
|
||||
earthRootNode_ = osgDB::readNodeFile("triton.earth");
|
||||
if (!earthRootNode_) {
|
||||
LOG_ERROR("read earth node(triton.earth) failed");
|
||||
return;
|
||||
}
|
||||
dyt_check(nullptr != earthRootNode_);
|
||||
logarithmicDepthBuffer_ = std::make_unique<osgEarth::Util::LogarithmicDepthBuffer>();
|
||||
|
||||
earthMapNode_ = osgEarth::MapNode::get(earthRootNode_);
|
||||
dyt_check(nullptr != earthMapNode_);
|
||||
LOG_INFO("earth map node get success: {}", earthMapNode_.valid());
|
||||
g_srs_ = earthMapNode_->getMapSRS();
|
||||
|
||||
|
@ -28,9 +28,9 @@ void OESceneUI::InitUI(OsgViewUI* ui) {
|
||||
}
|
||||
|
||||
compositeWidgetManager_ = new CompositeWidgetManager();
|
||||
compositeWidgetManager_->AttachViewUI(ui);
|
||||
//compositeWidgetManager_->AttachViewUI(ui);
|
||||
zoomManager_ = new ZoomManager();
|
||||
zoomManager_->AttachViewUI(ui);
|
||||
//zoomManager_->AttachViewUI(ui);
|
||||
|
||||
queryElevationWidget_ = new QueryElevationWidget(oeScene_);
|
||||
queryElevationWidget_->AttachViewUI(ui);
|
||||
|
Binary file not shown.
@ -369,25 +369,28 @@
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="44"/>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="60"/>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="45"/>
|
||||
<source>Dyt (*.dyt)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="47"/>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="48"/>
|
||||
<source>open dyt file</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="48"/>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="64"/>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="49"/>
|
||||
<source>Dyt (*.dyt);;All files (*.*)</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="63"/>
|
||||
<source>save dyt file</source>
|
||||
<location filename="../ui/Menu/FileManagerMenu.cpp" line="65"/>
|
||||
<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>
|
||||
</message>
|
||||
</context>
|
||||
@ -1270,18 +1273,18 @@
|
||||
<context>
|
||||
<name>QtOsgViewWidget</name>
|
||||
<message>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="369"/>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="377"/>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="139"/>
|
||||
<source>warning</source>
|
||||
<translation type="unfinished">警告</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="369"/>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="131"/>
|
||||
<source>default workspace failed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="377"/>
|
||||
<location filename="../viewer/QtOsgViewWidget.cpp" line="139"/>
|
||||
<source>open dyt file failed</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
@ -1297,7 +1300,7 @@
|
||||
<message>
|
||||
<location filename="../ui/PropertyBrowser/qtpropertymanager.cpp" line="8683"/>
|
||||
<source>Path</source>
|
||||
<translation type="unfinished">路径</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -1516,12 +1519,12 @@
|
||||
<message>
|
||||
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="454"/>
|
||||
<source>Property</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>属性</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/PropertyBrowser/qttreepropertybrowser.cpp" line="455"/>
|
||||
<source>Value</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>值</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
@ -1764,53 +1767,51 @@
|
||||
<translation>新建空间</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="52"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="58"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="68"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="75"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="84"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="90"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="100"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="57"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="63"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="73"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="80"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="89"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="95"/>
|
||||
<source>warning</source>
|
||||
<translation>警告</translation>
|
||||
</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>
|
||||
<translation>名称或者路径为空</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="58"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="63"/>
|
||||
<source>save current workspace?</source>
|
||||
<translation>保存当前空间?</translation>
|
||||
</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>
|
||||
<translation>当前空间已存在,是否替换?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="75"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="80"/>
|
||||
<source>removeRecursively failed</source>
|
||||
<translation>删除失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="84"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="89"/>
|
||||
<source>mkpath failed</source>
|
||||
<translation>创建路径失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="90"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="95"/>
|
||||
<source>name is exits</source>
|
||||
<translation>名称已存在</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="100"/>
|
||||
<source>create workSpace failed</source>
|
||||
<translation>创建空间失败</translation>
|
||||
<translation type="vanished">创建空间失败</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="111"/>
|
||||
<location filename="../ui/WorkSpace/WorkSpaceDlg.cpp" line="110"/>
|
||||
<source>save spaceWork directory</source>
|
||||
<translation>保存空间目录</translation>
|
||||
</message>
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "common/SpdLogger.h"
|
||||
#include "workspace/WorkSpace.h"
|
||||
#include "workspace/WorkSpaceManager.h"
|
||||
#include "utils/FileUtils.h"
|
||||
|
||||
#include "ui_FileManagerMenu.h"
|
||||
|
||||
@ -57,23 +58,31 @@ void FileManagerMenu::OpenWorkSpace() {
|
||||
|
||||
void FileManagerMenu::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();
|
||||
if (nullptr == workspace) {
|
||||
LOG_WARN("workspace is nullptr");
|
||||
QMessageBox::warning(&MainFrame::Get(), tr("warning"), tr("workspace is nullptr"));
|
||||
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);
|
||||
LOG_INFO("save dyt: {}", success);
|
||||
}
|
||||
|
@ -751,12 +751,12 @@ void QFilePathEdit::onFileSelect() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!FileUtils::CopyFileToPath(filePath, filePath, true)) {
|
||||
if (!FileUtils::CopyFileToPath(filePath, savePath, true)) {
|
||||
LOG_ERROR("Failed to copy file to workspace");
|
||||
QMessageBox::critical(nullptr, "Error", "Failed to copy file to workspace");
|
||||
return;
|
||||
}
|
||||
LOG_INFO("PathComponent::SetPath: {}", workPath.toStdString().c_str());
|
||||
LOG_INFO("SetPath: {}", savePath.toLocal8Bit().constData());
|
||||
m_initialvalue = m_fileName;
|
||||
m_stringEdit->setText(m_fileName);
|
||||
}
|
||||
|
@ -26,8 +26,8 @@ WorkSpaceDlg::WorkSpaceDlg(QWidget* parent)
|
||||
|
||||
SetTitle(tr("new workspace"));
|
||||
|
||||
const QString path = qApp->applicationDirPath() + "/workspace";
|
||||
ui->lePath->setText(path);
|
||||
path_ = qApp->applicationDirPath() + "/workspace";
|
||||
ui->lePath->setText(path_);
|
||||
//setFixedHeight(500);
|
||||
}
|
||||
|
||||
@ -39,15 +39,20 @@ void WorkSpaceDlg::InitConnect() {
|
||||
connect(ui->pbSure, &QPushButton::clicked, this, &WorkSpaceDlg::OnSure);
|
||||
connect(ui->pbCancel, &QPushButton::clicked, this, &WorkSpaceDlg::reject);
|
||||
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);
|
||||
}
|
||||
|
||||
void WorkSpaceDlg::OnSure() {
|
||||
const QString name = ui->leName->text();
|
||||
const QString savePath = ui->lePath->text();
|
||||
|
||||
LOG_INFO("name:{}, save path:{}", name.toStdString(), savePath.toStdString());
|
||||
if (name.isEmpty() || savePath.isEmpty()) {
|
||||
LOG_INFO("name:{}, save path:{}", name.toLocal8Bit().constData(), path_.toLocal8Bit().constData());
|
||||
if (name.isEmpty() || path_.isEmpty()) {
|
||||
LOG_WARN("name or save path is empty");
|
||||
QMessageBox::warning(this, tr("warning"), tr("name or save path is empty, please check it"));
|
||||
return;
|
||||
@ -61,7 +66,7 @@ void WorkSpaceDlg::OnSure() {
|
||||
current->Unlaod();
|
||||
}
|
||||
|
||||
QString workspacePath = QString("%1/%2").arg(savePath).arg(name);
|
||||
QString workspacePath = QString("%1/%2").arg(path_).arg(name);
|
||||
QDir dir(workspacePath);
|
||||
if (dir.exists()) {
|
||||
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->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);
|
||||
accept();
|
||||
}
|
||||
@ -113,9 +112,9 @@ void WorkSpaceDlg::OnSelectSavePath() {
|
||||
LOG_WARN("save path is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lePath->setText(savePath);
|
||||
LOG_INFO("save path: {}", savePath.toStdString());
|
||||
path_ = savePath;
|
||||
ui->lePath->setText(QString("%1/%2").arg(path_).arg(ui->leName->text()));
|
||||
LOG_INFO("save path: {}", path_.toLocal8Bit().constData());
|
||||
}
|
||||
|
||||
void WorkSpaceDlg::InitFrame() {
|
||||
|
@ -23,4 +23,5 @@ protected:
|
||||
|
||||
private:
|
||||
Ui::WorkSpaceDlg* ui;
|
||||
QString path_;
|
||||
};
|
@ -22,6 +22,7 @@ TransformPath::~TransformPath() {
|
||||
}
|
||||
|
||||
TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent) {
|
||||
LOG_INFO("Loading transform path from file: {}", path.toLocal8Bit().constData());
|
||||
QFile file(path);
|
||||
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
@ -42,7 +43,7 @@ TransformPath* TransformPath::LoadFromFile(const QString& path, QObject* parent)
|
||||
bool ok;
|
||||
double value = line.toDouble(&ok);
|
||||
if (ok) {
|
||||
transform.GetLocation()[i] = value * 1.5;
|
||||
transform.GetLocation()[i] = value;
|
||||
} else {
|
||||
LOG_WARN("Failed to convert line to double: {}", line.toStdString());
|
||||
return {};
|
||||
|
@ -46,12 +46,16 @@ void OsgView::InitGraphiceWindow(int x, int y, int width, int height,
|
||||
#endif // _WIN32
|
||||
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
|
||||
osg::GraphicsContext::Traits* traits = new osg::GraphicsContext::Traits(ds);
|
||||
traits->windowDecoration = windowDecoration;
|
||||
traits->windowName = name;
|
||||
traits->x = x;
|
||||
traits->y = y;
|
||||
traits->width = width;
|
||||
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->sharedContext = nullptr;
|
||||
traits->setInheritedWindowPixelFormat = true;
|
||||
@ -59,10 +63,9 @@ void OsgView::InitGraphiceWindow(int x, int y, int width, int height,
|
||||
traits->inheritedWindowData = windata;
|
||||
#endif
|
||||
graphiceWindow_ = osg::GraphicsContext::createGraphicsContext(traits);
|
||||
|
||||
#if USE_OCEAN
|
||||
graphiceWindow_->getState()->setUseModelViewAndProjectionUniforms(false);
|
||||
graphiceWindow_->getState()->setUseVertexAttributeAliasing(false);
|
||||
graphiceWindow_->getState()->setUseVertexAttributeAliasing(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -33,142 +33,6 @@
|
||||
#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)
|
||||
: QWidget(parent) {
|
||||
LOG_INFO("actor, self={}", fmt::ptr(this));
|
||||
@ -196,108 +60,6 @@ void QtOsgViewWidget::keyReleaseEvent(QKeyEvent* 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) {
|
||||
if (view_) {
|
||||
LOG_INFO("view is created");
|
||||
|
@ -13,7 +13,7 @@ class QKeyEvent;
|
||||
class QInputEvent;
|
||||
class QResizeEvent;
|
||||
|
||||
class QtOsgViewWidget : public QWidget, public ScaleBarHandler::Delegate {
|
||||
class QtOsgViewWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QtOsgViewWidget(QWidget* parent = nullptr);
|
||||
@ -24,8 +24,6 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void OnComputeScale() override;
|
||||
|
||||
void Initialize(void);
|
||||
void Uninitialize(void);
|
||||
|
||||
|
@ -16,13 +16,13 @@ Timestep::Timestep(const std::vector<double>& steps, const QString& path, WorkSp
|
||||
maxTime_ = *steps_.rbegin();
|
||||
}
|
||||
|
||||
Timestep* Timestep::Load(const QString& path, WorkSpace* parent) {
|
||||
const QString filePath = QString("%1/%2").arg(RecourceHelper::Get().GetBasePath()).arg(path);
|
||||
Timestep* Timestep::Load(const QString& path, WorkSpace* workSpace) {
|
||||
const QString filePath = QString("%1/%2").arg(workSpace->GetDir()).arg(path);
|
||||
LOG_INFO("Load timestep: {}", filePath.toStdString());
|
||||
|
||||
QFile file(filePath);
|
||||
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;
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ Timestep* Timestep::Load(const QString& path, WorkSpace* parent) {
|
||||
|
||||
file.close();
|
||||
|
||||
Timestep* timestep = new Timestep(numbers, path, parent);
|
||||
Timestep* timestep = new Timestep(numbers, path, workSpace);
|
||||
return timestep;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ public:
|
||||
explicit Timestep(const std::vector<double>& steps, const QString& path, WorkSpace* parent = nullptr) noexcept;
|
||||
~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 {
|
||||
return steps_;
|
||||
|
@ -105,6 +105,19 @@ bool WorkSpaceManager::Remove(const QString& name) {
|
||||
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) {
|
||||
dyt_check(nullptr != scene_);
|
||||
LOG_INFO("load workspace name:{}", dyt.toLocal8Bit().constData());
|
||||
@ -126,7 +139,7 @@ WorkSpace* WorkSpaceManager::GetOrCreate(const QString& path, const QString& nam
|
||||
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->SetName(name);
|
||||
workSpaces_[path] = workspace;
|
||||
|
@ -26,6 +26,7 @@ public:
|
||||
bool Remove(const QString& name);
|
||||
WorkSpace* LoadDyt(const QString& dyt);
|
||||
WorkSpace* GetOrCreate(const QString& path, const QString& name);
|
||||
bool Remove(WorkSpace* workspace);
|
||||
void SetCurrent(WorkSpace* workspace);
|
||||
WorkSpace* GetCurrent() const { return current_; }
|
||||
|
||||
|
@ -178,7 +178,7 @@ bool WorkSpaceXMLParse::ParseReport(const tinyxml2::XMLElement* element)
|
||||
}
|
||||
|
||||
bool WorkSpaceXMLParse::Load(const QString& dyt) {
|
||||
std::string path = dyt.toStdString();
|
||||
std::string path = dyt.toLocal8Bit().constData();
|
||||
LOG_INFO("load path:{}", path);
|
||||
tinyxml2::XMLDocument xmlDocument;
|
||||
tinyxml2::XMLError error = xmlDocument.LoadFile(path.c_str());
|
||||
|
@ -16,7 +16,7 @@ WorkSpaceXMLWrite::WorkSpaceXMLWrite(WorkSpace* workspace, QObject* parent) noex
|
||||
, workSpace_(workspace) {}
|
||||
|
||||
bool WorkSpaceXMLWrite::Save(const QString& path) {
|
||||
LOG_INFO("save path: {}", path.toStdString());
|
||||
LOG_INFO("save path: {}", path.toLocal8Bit().constData());
|
||||
if (nullptr == workSpace_) {
|
||||
LOG_WARN("worksapce is nullptr");
|
||||
return false;
|
||||
@ -41,7 +41,7 @@ bool WorkSpaceXMLWrite::Save(const QString& path) {
|
||||
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) {
|
||||
LOG_WARN("worksapce is nullptr");
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user