Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--base/newtype.hpp17
-rw-r--r--openlr/CMakeLists.txt1
-rw-r--r--openlr/openlr_match_quality/CMakeLists.txt3
-rw-r--r--openlr/openlr_match_quality/assessment_tool/CMakeLists.txt78
-rw-r--r--openlr/openlr_match_quality/assessment_tool/Info.plist11
-rw-r--r--openlr/openlr_match_quality/assessment_tool/main.cpp35
-rw-r--r--openlr/openlr_match_quality/assessment_tool/mainwindow.cpp165
-rw-r--r--openlr/openlr_match_quality/assessment_tool/mainwindow.hpp41
-rw-r--r--openlr/openlr_match_quality/assessment_tool/traffic_mode.cpp (renamed from qt/traffic_mode.cpp)21
-rw-r--r--openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp (renamed from qt/traffic_mode.hpp)2
-rw-r--r--openlr/openlr_match_quality/assessment_tool/traffic_panel.cpp (renamed from qt/traffic_panel.cpp)4
-rw-r--r--openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp (renamed from qt/traffic_panel.hpp)0
-rw-r--r--openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.cpp (renamed from qt/trafficmodeinitdlg.cpp)2
-rw-r--r--openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h (renamed from qt/trafficmodeinitdlg.h)0
-rw-r--r--openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.ui (renamed from qt/trafficmodeinitdlg.ui)0
-rw-r--r--openlr/openlr_sample.hpp2
-rw-r--r--openlr/openlr_stat/openlr_stat.cpp11
-rw-r--r--platform/platform.cpp9
-rw-r--r--platform/platform.hpp1
-rw-r--r--qt/CMakeLists.txt7
-rw-r--r--qt/mainwindow.cpp128
-rw-r--r--qt/mainwindow.hpp22
-rw-r--r--qt/qt.pro11
24 files changed, 388 insertions, 190 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f014dee87d..21d3505f37 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -326,7 +326,12 @@ add_subdirectory(local_ads)
if (PLATFORM_DESKTOP)
add_subdirectory(openlr)
add_subdirectory(generator)
- add_subdirectory(skin_generator)
+ # TODO(rokuz): CMake can't create an executable with the same name as the name of
+ # the folder containing its source. This is because file system doesn't allow
+ # directories and files with same names.
+ # Designer tool wants it to be called 'skin_generator'. Either fix designer tool
+ # to make it more flexible or find the right configuration for skin_generator.
+ # add_subdirectory(skin_generator)
endif()
omim_add_test_subdirectory(qt_tstfrm)
diff --git a/base/newtype.hpp b/base/newtype.hpp
index 50f0cab9fc..5c047cbdff 100644
--- a/base/newtype.hpp
+++ b/base/newtype.hpp
@@ -156,12 +156,13 @@ std::string SimpleDebugPrint(NewType<Type, Tag> const & nt)
struct NAME ## _tag; \
using NAME = my::NewType<REPR, NAME ## _tag>
-#define NEWTYPE_SIMPLE_OUTPUT(NAME) \
- inline std::string DebugPrint(NAME const & nt) \
- { \
- return my::newtype_default_output::SimpleDebugPrint(nt); \
- } \
- inline std::ostream & operator<<(std::ostream & ost, NAME const & nt) \
- { \
- return ost << my::newtype_default_output::SimpleDebugPrint(nt); \
+
+#define NEWTYPE_SIMPLE_OUTPUT(NAME) \
+ inline std::string DebugPrint(NAME const & nt) \
+ { \
+ return my::newtype_default_output::SimpleDebugPrint(nt); \
+ } \
+ inline std::ostream & operator<<(std::ostream & ost, NAME const & nt) \
+ { \
+ return ost << my::newtype_default_output::SimpleDebugPrint(nt); \
}
diff --git a/openlr/CMakeLists.txt b/openlr/CMakeLists.txt
index 747ff52bba..01b97fd1f7 100644
--- a/openlr/CMakeLists.txt
+++ b/openlr/CMakeLists.txt
@@ -20,5 +20,6 @@ set(
)
add_library(${PROJECT_NAME} ${SRC})
+add_subdirectory(openlr_match_quality)
add_subdirectory(openlr_stat)
omim_add_test_subdirectory(openlr_tests)
diff --git a/openlr/openlr_match_quality/CMakeLists.txt b/openlr/openlr_match_quality/CMakeLists.txt
new file mode 100644
index 0000000000..b987e4646b
--- /dev/null
+++ b/openlr/openlr_match_quality/CMakeLists.txt
@@ -0,0 +1,3 @@
+project(openlr_match_quality)
+
+add_subdirectory(assessment_tool)
diff --git a/openlr/openlr_match_quality/assessment_tool/CMakeLists.txt b/openlr/openlr_match_quality/assessment_tool/CMakeLists.txt
new file mode 100644
index 0000000000..33dd282177
--- /dev/null
+++ b/openlr/openlr_match_quality/assessment_tool/CMakeLists.txt
@@ -0,0 +1,78 @@
+project(openlr_assessment_tool)
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+
+include_directories(
+ ${OMIM_ROOT}/3party/gflags/src
+ ${OMIM_ROOT}/3party/glm
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+set(
+ SRC
+ main.cpp
+ mainwindow.cpp
+ mainwindow.hpp
+ traffic_mode.cpp
+ traffic_mode.hpp
+ traffic_panel.cpp
+ traffic_panel.hpp
+ trafficmodeinitdlg.cpp
+ trafficmodeinitdlg.h
+)
+
+omim_add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${SRC})
+
+omim_link_libraries(
+ ${PROJECT_NAME}
+ qt_common
+ map
+ drape_frontend
+ routing
+ search_quality
+ search
+ storage
+ tracking
+ traffic
+ routing_common
+ indexer
+ drape
+ partners_api
+ local_ads
+ platform
+ editor
+ geometry
+ coding
+ base
+ expat
+ freetype
+ icu
+ gflags
+ jansson
+ minizip
+ oauthcpp
+ opening_hours
+ openlr
+ osrm
+ protobuf
+ pugixml
+ sdf_image
+ stats_client
+ stb_image
+ succinct
+ ${Qt5Widgets_LIBRARIES}
+ ${LIBZ}
+)
+
+link_opengl(${PROJECT_NAME})
+link_qt5_core(${PROJECT_NAME})
+link_qt5_network(${PROJECT_NAME})
+
+if (PLATFORM_MAC)
+ set_target_properties(
+ ${PROJECT_NAME}
+ PROPERTIES
+ MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/Info.plist
+ )
+endif()
diff --git a/openlr/openlr_match_quality/assessment_tool/Info.plist b/openlr/openlr_match_quality/assessment_tool/Info.plist
new file mode 100644
index 0000000000..384699b4be
--- /dev/null
+++ b/openlr/openlr_match_quality/assessment_tool/Info.plist
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plist>
+ <dict>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+
+ <key>NSHighResolutionCapable</key>
+ <string>True</string>
+ </dict>
+</plist>
diff --git a/openlr/openlr_match_quality/assessment_tool/main.cpp b/openlr/openlr_match_quality/assessment_tool/main.cpp
new file mode 100644
index 0000000000..c6ea7c8637
--- /dev/null
+++ b/openlr/openlr_match_quality/assessment_tool/main.cpp
@@ -0,0 +1,35 @@
+#include "map/framework.hpp"
+
+#include "openlr/openlr_match_quality/assessment_tool/mainwindow.hpp"
+
+#include "3party/gflags/src/gflags/gflags.h"
+
+#include <QApplication>
+
+DEFINE_string(resources_path, "", "Path to resources directory");
+DEFINE_string(data_path, "", "Path to data directory");
+
+int main(int argc, char * argv[])
+{
+ google::SetUsageMessage("Visualize and check matched routes.");
+ google::ParseCommandLineFlags(&argc, &argv, true);
+
+ Platform & platform = GetPlatform();
+ if (!FLAGS_resources_path.empty())
+ platform.SetResourceDir(FLAGS_resources_path);
+ if (!FLAGS_data_path.empty())
+ platform.SetWritableDirForTests(FLAGS_data_path);
+
+ Q_INIT_RESOURCE(resources_common);
+ QApplication app(argc, argv);
+
+ FrameworkParams params;
+ params.m_disableLocalAds = true;
+
+ Framework framework(params);
+ MainWindow mainWindow(framework);
+
+ mainWindow.showMaximized();
+
+ return app.exec();
+}
diff --git a/openlr/openlr_match_quality/assessment_tool/mainwindow.cpp b/openlr/openlr_match_quality/assessment_tool/mainwindow.cpp
new file mode 100644
index 0000000000..a0534443da
--- /dev/null
+++ b/openlr/openlr_match_quality/assessment_tool/mainwindow.cpp
@@ -0,0 +1,165 @@
+#include "openlr/openlr_match_quality/assessment_tool/mainwindow.hpp"
+
+#include "openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp"
+#include "openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h"
+
+#include "qt/qt_common/map_widget.hpp"
+
+#include "map/framework.hpp"
+
+#include "drape_frontend/drape_api.hpp"
+
+#include <QDockWidget>
+#include <QFileDialog>
+#include <QLayout>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QStandardPaths>
+
+#include <cerrno>
+#include <cstring>
+
+namespace
+{
+// TODO(mgsergio): Consider getting rid of this class: just put everything
+// in TrafficMode.
+class TrafficDrawerDelegate : public TrafficDrawerDelegateBase
+{
+public:
+ TrafficDrawerDelegate(Framework & framework)
+ : m_framework(framework)
+ , m_drapeApi(m_framework.GetDrapeApi())
+ {
+ }
+
+ void SetViewportCenter(m2::PointD const & center) override
+ {
+ m_framework.SetViewportCenter(center);
+ }
+
+ void DrawDecodedSegments(DecodedSample const & sample, int const sampleIndex) override
+ {
+ CHECK(!sample.GetItems().empty(), ("Sample must not be empty."));
+ auto const & points = sample.GetPoints(sampleIndex);
+
+ LOG(LINFO, ("Decoded segment", points));
+ m_drapeApi.AddLine(NextLineId(),
+ df::DrapeApiLineData(points, dp::Color(0, 0, 255, 255))
+ .Width(3.0f).ShowPoints(true /* markPoints */));
+ }
+
+ void DrawEncodedSegment(openlr::LinearSegment const & segment) override
+ {
+ auto const & points = segment.GetMercatorPoints();
+
+ LOG(LINFO, ("Encoded segment", points));
+ m_drapeApi.AddLine(NextLineId(),
+ df::DrapeApiLineData(points, dp::Color(255, 0, 0, 255))
+ .Width(3.0f).ShowPoints(true /* markPoints */));
+ }
+
+ void Clear() override
+ {
+ m_drapeApi.Clear();
+ }
+
+private:
+ string NextLineId() { return strings::to_string(m_lineId++); }
+
+ uint32_t m_lineId = 0;
+
+ Framework & m_framework;
+ df::DrapeApi & m_drapeApi;
+};
+} // namespace
+
+
+MainWindow::MainWindow(Framework & framework)
+ : m_framework(framework)
+{
+ auto * mapWidget = new qt::common::MapWidget(
+ m_framework, false /* apiOpenGLES3 */, this /* parent */
+ );
+ setCentralWidget(mapWidget);
+
+ // setWindowTitle(tr("MAPS.ME"));
+ // setWindowIcon(QIcon(":/ui/logo.png"));
+
+ QMenu * fileMenu = new QMenu(tr("File"), this);
+ menuBar()->addMenu(fileMenu);
+
+ fileMenu->addAction(tr("Open sample"), this, &MainWindow::OnOpenTrafficSample);
+
+ m_closeTrafficSampleAction = fileMenu->addAction(
+ tr("Close sample"), this, &MainWindow::OnCloseTrafficSample
+ );
+ m_closeTrafficSampleAction->setEnabled(false /* enabled */);
+
+ m_saveTrafficSampleAction = fileMenu->addAction(
+ tr("Save sample"), this, &MainWindow::OnSaveTrafficSample
+ );
+ m_saveTrafficSampleAction->setEnabled(false /* enabled */);
+}
+
+void MainWindow::CreateTrafficPanel(string const & dataFilePath, string const & sampleFilePath)
+{
+ m_docWidget = new QDockWidget(tr("Routes"), this);
+ addDockWidget(Qt::DockWidgetArea::RightDockWidgetArea, m_docWidget);
+
+ m_trafficMode = new TrafficMode(dataFilePath, sampleFilePath,
+ m_framework.GetIndex(),
+ make_unique<TrafficDrawerDelegate>(m_framework));
+ m_docWidget->setWidget(new TrafficPanel(m_trafficMode, m_docWidget));
+
+ m_docWidget->adjustSize();
+ m_docWidget->show();
+}
+
+void MainWindow::DestroyTrafficPanel()
+{
+ removeDockWidget(m_docWidget);
+ delete m_docWidget;
+ m_docWidget = nullptr;
+
+ delete m_trafficMode;
+ m_trafficMode = nullptr;
+}
+
+void MainWindow::OnOpenTrafficSample()
+{
+ TrafficModeInitDlg dlg;
+ dlg.exec();
+ if (dlg.result() != QDialog::DialogCode::Accepted)
+ return;
+
+ CreateTrafficPanel(dlg.GetDataFilePath(), dlg.GetSampleFilePath());
+ m_closeTrafficSampleAction->setEnabled(true /* enabled */);
+ m_saveTrafficSampleAction->setEnabled(true /* enabled */);
+}
+
+void MainWindow::OnCloseTrafficSample()
+{
+ // TODO(mgsergio):
+ // If not saved, ask a user if he/she wants to save.
+ // OnSaveTrafficSample()
+
+ m_saveTrafficSampleAction->setEnabled(false /* enabled */);
+ m_closeTrafficSampleAction->setEnabled(false /* enabled */);
+ DestroyTrafficPanel();
+}
+
+void MainWindow::OnSaveTrafficSample()
+{
+ // TODO(mgsergio): Add default filename.
+ auto const & fileName = QFileDialog::getSaveFileName(this, tr("Save sample"));
+ if (fileName.isEmpty())
+ return;
+
+ if (!m_trafficMode->SaveSampleAs(fileName.toStdString()))
+ {
+ QMessageBox::critical(
+ this, tr("Saving error"),
+ tr("Can't save file: ") + strerror(errno));
+ }
+}
diff --git a/openlr/openlr_match_quality/assessment_tool/mainwindow.hpp b/openlr/openlr_match_quality/assessment_tool/mainwindow.hpp
new file mode 100644
index 0000000000..9543c7f5ab
--- /dev/null
+++ b/openlr/openlr_match_quality/assessment_tool/mainwindow.hpp
@@ -0,0 +1,41 @@
+#pragma once
+
+#include "openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp"
+
+#include "base/string_utils.hpp"
+
+#include <QMainWindow>
+
+class Framework;
+class TrafficMode;
+
+namespace df
+{
+class DrapeApi;
+} // namespace df
+
+class QDockWidget;
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ MainWindow(Framework & framework);
+
+private:
+ void CreateTrafficPanel(string const & dataFilePath, string const & sampleFilePath);
+ void DestroyTrafficPanel();
+
+ void OnOpenTrafficSample();
+ void OnCloseTrafficSample();
+ void OnSaveTrafficSample();
+
+ Framework & m_framework;
+
+ TrafficMode * m_trafficMode = nullptr;
+ QDockWidget * m_docWidget = nullptr;
+
+ QAction * m_saveTrafficSampleAction = nullptr;
+ QAction * m_closeTrafficSampleAction = nullptr;
+};
diff --git a/qt/traffic_mode.cpp b/openlr/openlr_match_quality/assessment_tool/traffic_mode.cpp
index 198af76d02..1839f9f9ec 100644
--- a/qt/traffic_mode.cpp
+++ b/openlr/openlr_match_quality/assessment_tool/traffic_mode.cpp
@@ -1,4 +1,4 @@
-#include "qt/traffic_mode.hpp"
+#include "openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp"
#include "openlr/openlr_simple_parser.hpp"
@@ -11,6 +11,9 @@
#include <QtCore/QItemSelection>
+#include <fstream>
+
+
// DecodedSample -----------------------------------------------------------------------------------
DecodedSample::DecodedSample(Index const & index, openlr::SamplePool const & sample)
{
@@ -80,7 +83,9 @@ TrafficMode::TrafficMode(std::string const & dataFileName, std::string const & s
try
{
auto const & sample = openlr::LoadSamplePool(sampleFileName, index);
+ LOG(LINFO, ("Samples parsed:", sample.size()));
m_decodedSample = make_unique<DecodedSample>(index, sample);
+ LOG(LINFO, (m_decodedSample->GetItems().size(), "samples are loaded"));
}
catch (openlr::SamplePoolLoadError const & e)
{
@@ -106,7 +111,7 @@ TrafficMode::TrafficMode(std::string const & dataFileName, std::string const & s
CHECK(!segment.m_locationReference.m_points.empty(), ());
m_partnerSegments[segment.m_segmentId] = segment;
}
-
+ LOG(LINFO, (m_partnerSegments.size(), "segments are loaded"));
m_valid = true;
}
@@ -159,20 +164,24 @@ QVariant TrafficMode::data(const QModelIndex & index, int role) const
void TrafficMode::OnItemSelected(QItemSelection const & selected, QItemSelection const &)
{
- ASSERT(!selected.empty(), ("The selection should not be empty. RTFM for qt5."));
+ CHECK(!selected.empty(), ("The selection should not be empty. RTFM for qt5."));
+ CHECK(!m_decodedSample->Empty(), ("No samples are loaded, can't select."));
+
auto const row = selected.front().top();
// TODO(mgsergio): Use algo for center calculation.
// Now viewport is set to the first point of the first segment.
- auto const partnerSegmentId = m_decodedSample->m_decodedItems[row].m_partnerSegmentId;
+ auto & sampleItem = m_decodedSample->m_decodedItems[row];
+ auto const partnerSegmentId = sampleItem.m_partnerSegmentId;
+ LOG(LINFO, ("Partner segment id:", partnerSegmentId));
- if (m_decodedSample->m_decodedItems[row].m_segments.empty())
+ if (sampleItem.m_segments.empty())
{
LOG(LERROR, ("Empty mwm segments for partner id", partnerSegmentId.Get()));
return;
}
- auto const & firstSegment = m_decodedSample->m_decodedItems[row].m_segments[0];
+ auto const & firstSegment = sampleItem.m_segments[0];
auto const & firstSegmentFeatureId = firstSegment.m_fid;
auto const & firstSegmentFeature = m_decodedSample->m_points.at(firstSegmentFeatureId);
diff --git a/qt/traffic_mode.hpp b/openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp
index d8e8bfbacc..b6fa4fe1ee 100644
--- a/qt/traffic_mode.hpp
+++ b/openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp
@@ -18,6 +18,8 @@ struct DecodedSample
{
DecodedSample(Index const & index, openlr::SamplePool const & sample);
+ bool Empty() const { return m_decodedItems.empty(); }
+
openlr::SamplePool const & GetItems() const { return m_decodedItems; }
std::vector<m2::PointD> GetPoints(size_t const index) const;
diff --git a/qt/traffic_panel.cpp b/openlr/openlr_match_quality/assessment_tool/traffic_panel.cpp
index a073a777b9..b27b3cefd1 100644
--- a/qt/traffic_panel.cpp
+++ b/openlr/openlr_match_quality/assessment_tool/traffic_panel.cpp
@@ -1,5 +1,5 @@
-#include "qt/traffic_panel.hpp"
-#include "qt/traffic_mode.hpp"
+#include "openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp"
+#include "openlr/openlr_match_quality/assessment_tool/traffic_mode.hpp"
#include <QtCore/QAbstractTableModel>
#include <QtWidgets/QBoxLayout>
diff --git a/qt/traffic_panel.hpp b/openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp
index 0cf25e3357..0cf25e3357 100644
--- a/qt/traffic_panel.hpp
+++ b/openlr/openlr_match_quality/assessment_tool/traffic_panel.hpp
diff --git a/qt/trafficmodeinitdlg.cpp b/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.cpp
index 2484a2bd34..348a9ca708 100644
--- a/qt/trafficmodeinitdlg.cpp
+++ b/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.cpp
@@ -1,4 +1,4 @@
-#include "qt/trafficmodeinitdlg.h"
+#include "openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h"
#include "ui_trafficmodeinitdlg.h"
#include "platform/settings.hpp"
diff --git a/qt/trafficmodeinitdlg.h b/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h
index b790e626d7..b790e626d7 100644
--- a/qt/trafficmodeinitdlg.h
+++ b/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.h
diff --git a/qt/trafficmodeinitdlg.ui b/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.ui
index 1ce7c4fe58..1ce7c4fe58 100644
--- a/qt/trafficmodeinitdlg.ui
+++ b/openlr/openlr_match_quality/assessment_tool/trafficmodeinitdlg.ui
diff --git a/openlr/openlr_sample.hpp b/openlr/openlr_sample.hpp
index 8a8df36450..98efb17d9c 100644
--- a/openlr/openlr_sample.hpp
+++ b/openlr/openlr_sample.hpp
@@ -14,7 +14,7 @@ class Index;
namespace openlr
{
NEWTYPE(uint32_t, PartnerSegmentId);
-
+NEWTYPE_SIMPLE_OUTPUT(PartnerSegmentId);
enum class ItemEvaluation
{
Unevaluated,
diff --git a/openlr/openlr_stat/openlr_stat.cpp b/openlr/openlr_stat/openlr_stat.cpp
index d8c6024d4c..dc8bb5e108 100644
--- a/openlr/openlr_stat/openlr_stat.cpp
+++ b/openlr/openlr_stat/openlr_stat.cpp
@@ -15,8 +15,6 @@
#include <cstdio>
#include <vector>
-#include <sys/stat.h>
-
DEFINE_string(input, "", "Path to OpenLR file.");
DEFINE_string(output, "output.txt", "Path to output file");
DEFINE_string(mwms_path, "", "Path to a folder with mwms.");
@@ -32,16 +30,9 @@ namespace
const int32_t kMinNumThreads = 1;
const int32_t kMaxNumThreads = 128;
-bool IsDirectory(std::string const & path)
-{
- struct ::stat st;
- stat(path.data(), &st);
- return S_ISDIR(st.st_mode);
-}
-
void LoadIndexes(std::string const & pathToMWMFolder, std::vector<Index> & indexes)
{
- CHECK(IsDirectory(pathToMWMFolder), (pathToMWMFolder, "must be a directory."));
+ CHECK(Platform::IsDirectory(pathToMWMFolder), (pathToMWMFolder, "must be a directory."));
Platform::FilesList files;
Platform::GetFilesByRegExp(pathToMWMFolder, std::string(".*\\") + DATA_FILE_EXTENSION, files);
diff --git a/platform/platform.cpp b/platform/platform.cpp
index 6904fd4013..1746f3fd91 100644
--- a/platform/platform.cpp
+++ b/platform/platform.cpp
@@ -178,6 +178,15 @@ void Platform::GetFilesByType(string const & directory, unsigned typeMask,
}
}
+// static
+bool Platform::IsDirectory(string const & directory)
+{
+ EFileType fileType;
+ if (GetFileType(directory, fileType) != ERR_OK)
+ return false;
+ return fileType == FILE_TYPE_DIRECTORY;
+}
+
string Platform::DeviceName() const
{
return OMIM_OS_NAME;
diff --git a/platform/platform.hpp b/platform/platform.hpp
index d79201a10c..78fe9d76a1 100644
--- a/platform/platform.hpp
+++ b/platform/platform.hpp
@@ -165,6 +165,7 @@ public:
TFilesWithType & outFiles);
static bool IsDirectoryEmpty(string const & directory);
+ static bool IsDirectory(string const & directory);
static EError GetFileType(string const & path, EFileType & type);
diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt
index da92a04fa9..e997164c96 100644
--- a/qt/CMakeLists.txt
+++ b/qt/CMakeLists.txt
@@ -68,12 +68,6 @@ set(
preferences_dialog.hpp
search_panel.cpp
search_panel.hpp
- traffic_mode.cpp
- traffic_mode.hpp
- traffic_panel.cpp
- traffic_panel.hpp
- trafficmodeinitdlg.cpp
- trafficmodeinitdlg.h
update_dialog.cpp
update_dialog.hpp
)
@@ -113,7 +107,6 @@ omim_link_libraries(
pugixml
oauthcpp
opening_hours
- openlr
stb_image
sdf_image
${Qt5Gui_LIBRARIES}
diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp
index 49cdb7c552..a43ea17100 100644
--- a/qt/mainwindow.cpp
+++ b/qt/mainwindow.cpp
@@ -6,13 +6,6 @@
#include "qt/qt_common/helpers.hpp"
#include "qt/qt_common/scale_slider.hpp"
#include "qt/search_panel.hpp"
-#include "qt/traffic_mode.hpp"
-#include "qt/traffic_panel.hpp"
-#include "qt/trafficmodeinitdlg.h"
-
-#include "drape/debug_rect_renderer.hpp"
-
-#include "openlr/openlr_sample.hpp"
#include "platform/settings.hpp"
#include "platform/platform.hpp"
@@ -58,60 +51,6 @@
#endif // NO_DOWNLOADER
-namespace
-{
-// TODO(mgsergio): Consider getting rid of this class: just put everything
-// in TrafficMode.
-class TrafficDrawerDelegate : public TrafficDrawerDelegateBase
-{
-public:
- explicit TrafficDrawerDelegate(qt::DrawWidget & drawWidget)
- : m_framework(drawWidget.GetFramework())
- , m_drapeApi(m_framework.GetDrapeApi())
- {
- }
-
- void SetViewportCenter(m2::PointD const & center) override
- {
- m_framework.SetViewportCenter(center);
- }
-
- void DrawDecodedSegments(DecodedSample const & sample, int const sampleIndex) override
- {
- CHECK(!sample.GetItems().empty(), ("Sample must not be empty."));
- auto const & points = sample.GetPoints(sampleIndex);
-
- LOG(LINFO, ("Decoded segment", points));
- m_drapeApi.AddLine(NextLineId(),
- df::DrapeApiLineData(points, dp::Color(0, 0, 255, 255))
- .Width(3.0f).ShowPoints(true /* markPoints */));
- }
-
- void DrawEncodedSegment(openlr::LinearSegment const & segment) override
- {
- auto const & points = segment.GetMercatorPoints();
-
- LOG(LINFO, ("Encoded segment", points));
- m_drapeApi.AddLine(NextLineId(),
- df::DrapeApiLineData(points, dp::Color(255, 0, 0, 255))
- .Width(3.0f).ShowPoints(true /* markPoints */));
- }
-
- void Clear() override
- {
- m_drapeApi.Clear();
- }
-
-private:
- string NextLineId() { return strings::to_string(m_lineId++); }
-
- uint32_t m_lineId = 0;
-
- Framework & m_framework;
- df::DrapeApi & m_drapeApi;
-};
-} // namespace
-
namespace qt
{
// Defined in osm_auth_dialog.cpp.
@@ -147,21 +86,6 @@ MainWindow::MainWindow(Framework & framework, bool apiOpenGLES3, QString const &
setWindowTitle(caption);
setWindowIcon(QIcon(":/ui/logo.png"));
- QMenu * trafficMarkup = new QMenu(tr("Traffic"), this);
- menuBar()->addMenu(trafficMarkup);
- trafficMarkup->addAction(tr("Open sample"), this, SLOT(OnOpenTrafficSample()));
- m_saveTrafficSampleAction = trafficMarkup->addAction(tr("Save sample"), this,
- SLOT(OnSaveTrafficSample()));
- m_saveTrafficSampleAction->setEnabled(false);
-
- m_quitTrafficModeAction = new QAction(tr("Quit traffic mode"), this);
- // On macOS actions with names started with quit or exit are treated specially,
- // see QMenuBar documentation.
- m_quitTrafficModeAction->setMenuRole(QAction::MenuRole::NoRole);
- m_quitTrafficModeAction->setEnabled(false);
- connect(m_quitTrafficModeAction, SIGNAL(triggered()), this, SLOT(OnQuitTrafficMode()));
- trafficMarkup->addAction(m_quitTrafficModeAction);
-
#ifndef OMIM_OS_WINDOWS
QMenu * helpMenu = new QMenu(tr("Help"), this);
menuBar()->addMenu(helpMenu);
@@ -856,24 +780,6 @@ void MainWindow::CreatePanelImpl(size_t i, Qt::DockWidgetArea area, QString cons
}
}
-void MainWindow::CreateTrafficPanel(string const & dataFilePath, string const & sampleFilePath)
-{
- CreatePanelImpl(1, Qt::RightDockWidgetArea, tr("Traffic"), QKeySequence(), nullptr);
-
- m_trafficMode = new TrafficMode(dataFilePath, sampleFilePath,
- m_pDrawWidget->GetFramework().GetIndex(),
- make_unique<TrafficDrawerDelegate>(*m_pDrawWidget));
- m_Docks[1]->setWidget(new TrafficPanel(m_trafficMode, m_Docks[1]));
- m_Docks[1]->adjustSize();
-}
-
-void MainWindow::DestroyTrafficPanel()
-{
- removeDockWidget(m_Docks[1]);
- delete m_Docks[1];
- m_Docks[1] = nullptr;
-}
-
void MainWindow::closeEvent(QCloseEvent * e)
{
m_pDrawWidget->PrepareShutdown();
@@ -897,40 +803,6 @@ void MainWindow::OnTrafficEnabled()
m_pDrawWidget->GetFramework().SaveTrafficEnabled(enabled);
}
-void MainWindow::OnOpenTrafficSample()
-{
- TrafficModeInitDlg dlg;
- dlg.exec();
- if (dlg.result() != QDialog::DialogCode::Accepted)
- return;
-
- LOG(LDEBUG, ("Traffic mode enabled"));
- CreateTrafficPanel(dlg.GetDataFilePath(), dlg.GetSampleFilePath());
- m_quitTrafficModeAction->setEnabled(true);
- m_saveTrafficSampleAction->setEnabled(true);
- m_Docks[1]->show();
-}
-
-void MainWindow::OnSaveTrafficSample()
-{
- auto const & fileName = QFileDialog::getSaveFileName(this, tr("Save sample"));
- if (fileName.isEmpty())
- return;
-
- if (!m_trafficMode->SaveSampleAs(fileName.toStdString()))
- ;// TODO(mgsergio): Show error dlg;
-}
-
-void MainWindow::OnQuitTrafficMode()
-{
- // If not saved, ask a user if he/she wants to save.
- // OnSaveTrafficSample()
- m_quitTrafficModeAction->setEnabled(false);
- m_saveTrafficSampleAction->setEnabled(false);
- DestroyTrafficPanel();
- m_trafficMode = nullptr;
-}
-
void MainWindow::OnStartPointSelected()
{
m_routePointsToolButton->setIcon(m_selectStartRoutePoint->icon());
diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp
index 7fe028aef9..10fbfe076c 100644
--- a/qt/mainwindow.hpp
+++ b/qt/mainwindow.hpp
@@ -18,16 +18,18 @@ class QDockWidget;
class QLabel;
class QPushButton;
class QToolButton;
-class TrafficMode;
namespace search { class Result; }
namespace qt
{
+class DrawWidget;
+
class MainWindow : public QMainWindow, location::LocationObserver
{
- DrawWidget * m_pDrawWidget = nullptr; // TODO(mgsergio): Make indexing more informative.
- std::array<QDockWidget *, 2> m_Docks;
+ DrawWidget * m_pDrawWidget = nullptr;
+ // TODO(mgsergio): Make indexing more informative.
+ array<QDockWidget *, 1> m_Docks;
QPushButton * m_downloadButton = nullptr;
QPushButton * m_retryButton = nullptr;
@@ -37,17 +39,12 @@ class MainWindow : public QMainWindow, location::LocationObserver
std::unique_ptr<location::LocationService> const m_locationService;
- // This object is managed by Qt memory system.
- TrafficMode * m_trafficMode = nullptr;
-
QAction * m_pMyPositionAction = nullptr;
QAction * m_pCreateFeatureAction = nullptr;
QAction * m_selectionMode = nullptr;
QAction * m_clearSelection = nullptr;
QAction * m_pSearchAction = nullptr;
QAction * m_trafficEnableAction = nullptr;
- QAction * m_saveTrafficSampleAction = nullptr;
- QAction * m_quitTrafficModeAction = nullptr;
QToolButton * m_routePointsToolButton = nullptr;
QAction * m_selectStartRoutePoint = nullptr;
QAction * m_selectFinishRoutePoint = nullptr;
@@ -82,9 +79,6 @@ protected:
void CreateSearchBarAndPanel();
void CreateCountryStatusControls();
- void CreateTrafficPanel(string const & dataFilePath, string const & sampleFilePath);
- void DestroyTrafficPanel();
-
#if defined(Q_WS_WIN)
/// to handle menu messages
bool winEvent(MSG * msg, long * result) override;
@@ -114,16 +108,12 @@ protected Q_SLOTS:
void OnClearSelection();
void OnTrafficEnabled();
- void OnOpenTrafficSample();
- void OnSaveTrafficSample();
- void OnQuitTrafficMode();
-
void OnStartPointSelected();
void OnFinishPointSelected();
void OnIntermediatePointSelected();
void OnFollowRoute();
void OnClearRoute();
-
+
#ifdef BUILD_DESIGNER
void OnBuildStyle();
void OnRecalculateGeomIndex();
diff --git a/qt/qt.pro b/qt/qt.pro
index e6bc2ffa8e..31f27918ed 100644
--- a/qt/qt.pro
+++ b/qt/qt.pro
@@ -1,7 +1,7 @@
# Main application in qt.
ROOT_DIR = ..
-DEPENDENCIES = qt_common map drape_frontend openlr routing search storage tracking traffic routing_common \
+DEPENDENCIES = qt_common map drape_frontend routing search storage tracking traffic routing_common \
indexer drape partners_api local_ads platform editor geometry \
coding base freetype expat gflags jansson protobuf osrm stats_client \
minizip succinct pugixml oauthcpp stb_image sdf_image icu
@@ -203,9 +203,6 @@ SOURCES += \
place_page_dialog.cpp \
preferences_dialog.cpp \
search_panel.cpp \
- traffic_mode.cpp \
- traffic_panel.cpp \
- trafficmodeinitdlg.cpp \
update_dialog.cpp \
HEADERS += \
@@ -219,12 +216,6 @@ HEADERS += \
place_page_dialog.hpp \
preferences_dialog.hpp \
search_panel.hpp \
- traffic_mode.hpp \
- traffic_panel.hpp \
- trafficmodeinitdlg.h \
update_dialog.hpp \
RESOURCES += res/resources.qrc
-
-FORMS += \
- trafficmodeinitdlg.ui