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:
authorr.kuznetsov <r.kuznetsov@corp.mail.ru>2016-08-10 01:33:12 +0300
committerIlya Zverev <ilya@zverev.info>2017-07-04 11:26:12 +0300
commitcfc5c6a7122c365a412162dd6804e39befd98d9e (patch)
treebe58193d7553c540a0f919f0f4646372a08d1d93
parent497c18a27dfd5acab6ee959f493c23e0780e242e (diff)
[designer tool] Added button for geom index regeneration and config in prefs
-rw-r--r--CMakeLists.txt33
-rw-r--r--indexer/map_style_reader.cpp4
-rw-r--r--qt/CMakeLists.txt12
-rw-r--r--qt/build_style/build_style.cpp19
-rw-r--r--qt/draw_widget.cpp2
-rw-r--r--qt/draw_widget.hpp1
-rw-r--r--qt/main.cpp4
-rw-r--r--qt/mainwindow.cpp56
-rw-r--r--qt/mainwindow.hpp16
-rw-r--r--qt/preferences_dialog.cpp26
-rw-r--r--qt/preferences_dialog.hpp9
-rw-r--r--qt/res/geom.pngbin0 -> 4443 bytes
-rw-r--r--qt/res/resources.qrc1
-rw-r--r--qt/update_dialog.cpp26
-rwxr-xr-xtools/unix/build_designer.sh6
15 files changed, 162 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 41eac49e6d..9a3eadd740 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,39 @@ cmake_minimum_required(VERSION 3.2)
project(omim C CXX)
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+# Set environment variables
+
+set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
+set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
+
+if ($ENV{QT_PATH})
+ set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} $ENV{QT_PATH})
+else()
+ set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} "/usr/local/opt/qt5")
+endif()
+
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release")
+endif()
+
+if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
+ add_definitions(-DDEBUG)
+endif()
+
+if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
+ add_definitions(-DRELEASE)
+endif()
+
+if (NOT SKIP_TESTS)
+ set(SKIP_TESTS FALSE)
+endif()
+
+add_definitions(-DBUILD_DESIGNER)
+
+# End of setting environment variables
+
# Set target platform:
function(omim_set_platform_var PLATFORM_VAR pattern)
set(${PLATFORM_VAR} FALSE PARENT_SCOPE)
diff --git a/indexer/map_style_reader.cpp b/indexer/map_style_reader.cpp
index c4a821bd6f..df9db9fb2a 100644
--- a/indexer/map_style_reader.cpp
+++ b/indexer/map_style_reader.cpp
@@ -38,10 +38,14 @@ std::string GetStyleRulesSuffix(MapStyle mapStyle)
}
LOG(LWARNING, ("Unknown map style", mapStyle));
return kSuffixClear;
+#endif // BUILD_DESIGNER
}
std::string GetStyleResourcesSuffix(MapStyle mapStyle)
{
+#ifdef BUILD_DESIGNER
+ return string();
+#else
// We use the same resources for default and vehicle styles
// to avoid textures duplication and package size increasing.
switch (mapStyle)
diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt
index 6471c3970b..30399a5868 100644
--- a/qt/CMakeLists.txt
+++ b/qt/CMakeLists.txt
@@ -22,6 +22,18 @@ set(
SRC
about.cpp
about.hpp
+ build_style/build_common.cpp
+ build_style/build_common.h
+ build_style/build_drules.cpp
+ build_style/build_drules.h
+ build_style/build_skins.cpp
+ build_style/build_skins.h
+ build_style/build_statistics.cpp
+ build_style/build_statistics.h
+ build_style/build_style.cpp
+ build_style/build_style.h
+ build_style/run_tests.cpp
+ build_style/run_tests.h
create_feature_dialog.cpp
create_feature_dialog.hpp
draw_widget.cpp
diff --git a/qt/build_style/build_style.cpp b/qt/build_style/build_style.cpp
index e0bb3f6057..ddfcfa0ea3 100644
--- a/qt/build_style/build_style.cpp
+++ b/qt/build_style/build_style.cpp
@@ -57,12 +57,21 @@ void BuildAndApply(QString const & mapcssFile)
if (!QDir().mkdir(outputDir))
throw runtime_error("Unable to make the output directory");
- auto future = std::async(BuildSkins, styleDir, outputDir);
- BuildDrawingRules(mapcssFile, outputDir);
- future.get(); // may rethrow exception from the BuildSkin
+ bool const hasSymbols = QDir(styleDir + "symbols/").exists();
+ if (hasSymbols)
+ {
+ auto future = std::async(BuildSkins, styleDir, outputDir);
+ BuildDrawingRules(mapcssFile, outputDir);
+ future.get(); // may rethrow exception from the BuildSkin
- ApplyDrawingRules(outputDir);
- ApplySkins(outputDir);
+ ApplyDrawingRules(outputDir);
+ ApplySkins(outputDir);
+ }
+ else
+ {
+ BuildDrawingRules(mapcssFile, outputDir);
+ ApplyDrawingRules(outputDir);
+ }
}
void RunRecalculationGeometryScript(QString const & mapcssFile)
diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp
index fdeaeba96a..69adde3a65 100644
--- a/qt/draw_widget.cpp
+++ b/qt/draw_widget.cpp
@@ -513,7 +513,7 @@ void DrawWidget::SetDefaultSurfaceFormat(bool apiOpenGLES3)
void DrawWidget::RefreshDrawingRules()
{
- SetMapStyle(MapStyleLight);
+ SetMapStyle(MapStyleClear);
}
}
diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp
index 9d54105771..189967799a 100644
--- a/qt/draw_widget.hpp
+++ b/qt/draw_widget.hpp
@@ -59,6 +59,7 @@ public:
void PrepareShutdown();
Framework & GetFramework() { return m_framework; }
+
void SetMapStyle(MapStyle mapStyle);
void SetRouter(routing::RouterType routerType);
diff --git a/qt/main.cpp b/qt/main.cpp
index 9cf1aa8d2f..46e7294621 100644
--- a/qt/main.cpp
+++ b/qt/main.cpp
@@ -173,7 +173,7 @@ int main(int argc, char * argv[])
{
build_style::RunRecalculationGeometryScript(mapcssFilePath);
}
- catch (exception & e)
+ catch (std::exception & e)
{
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
@@ -184,8 +184,6 @@ int main(int argc, char * argv[])
}
}
- dbg::ObjectTracker::PrintLeaks();
-
LOG_SHORT(LINFO, ("MapsWithMe finished with code", returnCode));
return returnCode;
}
diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp
index 76ea040d25..ae8dd98583 100644
--- a/qt/mainwindow.cpp
+++ b/qt/mainwindow.cpp
@@ -116,12 +116,15 @@ extern char const * kTokenSecretSetting;
MainWindow::MainWindow(Framework & framework, bool apiOpenGLES3, QString const & mapcssFilePath /*= QString()*/)
: m_Docks{}
+ , m_locationService(CreateDesktopLocationService(*this))
+#ifdef BUILD_DESIGNER
+ , m_mapcssFilePath(mapcssFilePath)
, m_pBuildStyleAction(nullptr)
+ , m_pRecalculateGeomIndex(nullptr)
, m_pDrawDebugRectAction(nullptr)
, m_pGetStatisticsAction(nullptr)
, m_pRunTestsAction(nullptr)
- , m_locationService(CreateDesktopLocationService(*this))
- , m_mapcssFilePath(mapcssFilePath)
+#endif
{
// Always runs on the first desktop
QDesktopWidget const * desktop(QApplication::desktop());
@@ -425,6 +428,13 @@ void MainWindow::CreateNavigationBar()
SLOT(OnBuildStyle()));
m_pBuildStyleAction->setCheckable(false);
m_pBuildStyleAction->setToolTip(tr("Build style"));
+
+ m_pRecalculateGeomIndex = pToolBar->addAction(QIcon(":/navig64/geom.png"),
+ tr("Recalculate geometry index"),
+ this,
+ SLOT(OnRecalculateGeomIndex()));
+ m_pRecalculateGeomIndex->setCheckable(false);
+ m_pRecalculateGeomIndex->setToolTip(tr("Recalculate geometry index"));
}
// Add "Debug style" button
@@ -666,10 +676,42 @@ void MainWindow::OnBuildStyle()
{
build_style::BuildAndApply(m_mapcssFilePath);
// m_pDrawWidget->RefreshDrawingRules();
- build_style::NeedRecalculate = true;
- QMainWindow::close();
+
+ bool enabled = false;
+ settings::Get(kEnabledAutoRegenGeomIndex, enabled);
+ if (enabled)
+ {
+ build_style::NeedRecalculate = true;
+ QMainWindow::close();
+ }
+ }
+ catch (std::exception & e)
+ {
+ QMessageBox msgBox;
+ msgBox.setWindowTitle("Error");
+ msgBox.setText(e.what());
+ msgBox.setStandardButtons(QMessageBox::Ok);
+ msgBox.setDefaultButton(QMessageBox::Ok);
+ msgBox.exec();
+ }
+}
+
+void MainWindow::OnRecalculateGeomIndex()
+{
+ try
+ {
+ QMessageBox msgBox;
+ msgBox.setWindowTitle("Warning");
+ msgBox.setText("Geometry index will be regenerated. It can take a while.\nApplication may be closed and reopened!");
+ msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+ msgBox.setDefaultButton(QMessageBox::Yes);
+ if (msgBox.exec() == QMessageBox::Yes)
+ {
+ build_style::NeedRecalculate = true;
+ QMainWindow::close();
+ }
}
- catch (exception & e)
+ catch (std::exception & e)
{
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
@@ -695,7 +737,7 @@ void MainWindow::OnGetStatistics()
InfoDialog dlg(QString("Style statistics"), text, NULL);
dlg.exec();
}
- catch (exception & e)
+ catch (std::exception & e)
{
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
@@ -714,7 +756,7 @@ void MainWindow::OnRunTests()
InfoDialog dlg(QString("Style tests: ") + (res.first ? "OK" : "FAILED"), res.second, NULL);
dlg.exec();
}
- catch (exception & e)
+ catch (std::exception & e)
{
QMessageBox msgBox;
msgBox.setWindowTitle("Error");
diff --git a/qt/mainwindow.hpp b/qt/mainwindow.hpp
index 5e8ab334d6..f9a30eec70 100644
--- a/qt/mainwindow.hpp
+++ b/qt/mainwindow.hpp
@@ -39,7 +39,9 @@ class MainWindow : public QMainWindow, location::LocationObserver
QAction * m_selectFinishRoutePoint;
QAction * m_selectIntermediateRoutePoint;
#ifdef BUILD_DESIGNER
+ QString const m_mapcssFilePath;
QAction * m_pBuildStyleAction;
+ QAction * m_pRecalculateGeomIndex;
QAction * m_pDrawDebugRectAction;
QAction * m_pGetStatisticsAction;
QAction * m_pRunTestsAction;
@@ -58,16 +60,13 @@ class MainWindow : public QMainWindow, location::LocationObserver
// This object is managed by Qt memory system.
TrafficMode * m_trafficMode = nullptr;
-
- QString const m_mapcssFilePath;
Q_OBJECT
public:
MainWindow(Framework & framework, bool apiOpenGLES3, QString const & mapcssFilePath = QString());
- virtual void OnLocationError(location::TLocationError errorCode);
- virtual void OnLocationUpdated(location::GpsInfo const & info);
+Q_OBJECT
static void SetDefaultSurfaceFormat(bool apiOpenGLES3);
@@ -126,10 +125,11 @@ protected Q_SLOTS:
void OnClearRoute();
#ifdef BUILD_DESIGNER
- void OnBuildStyle();
- void OnDebugStyle();
- void OnGetStatistics();
- void OnRunTests();
+ void OnBuildStyle();
+ void OnRecalculateGeomIndex();
+ void OnDebugStyle();
+ void OnGetStatistics();
+ void OnRunTests();
#endif // BUILD_DESIGNER
};
}
diff --git a/qt/preferences_dialog.cpp b/qt/preferences_dialog.cpp
index 7606ce0a0b..cce3e0bcde 100644
--- a/qt/preferences_dialog.cpp
+++ b/qt/preferences_dialog.cpp
@@ -29,6 +29,10 @@
using namespace measurement_utils;
+#ifdef BUILD_DESIGNER
+string const kEnabledAutoRegenGeomIndex = "EnabledAutoRegenGeomIndex";
+#endif
+
namespace qt
{
PreferencesDialog::PreferencesDialog(QWidget * parent)
@@ -67,6 +71,18 @@ namespace qt
connect(m_pUnits, SIGNAL(buttonClicked(int)), this, SLOT(OnUnitsChanged(int)));
}
+ #ifdef BUILD_DESIGNER
+ QCheckBox * checkBox = new QCheckBox("Enable auto regeneration of geometry index");
+ {
+ bool enabled = false;
+ if (!settings::Get(kEnabledAutoRegenGeomIndex, enabled))
+ {
+ settings::Set(kEnabledAutoRegenGeomIndex, false);
+ }
+ checkBox->setChecked(enabled);
+ connect(checkBox, SIGNAL(stateChanged(int)), this, SLOT(OnEnabledAutoRegenGeomIndex(int)));
+ }
+ #endif
QHBoxLayout * bottomLayout = new QHBoxLayout();
{
@@ -82,6 +98,9 @@ namespace qt
QVBoxLayout * finalLayout = new QVBoxLayout();
finalLayout->addWidget(radioBox);
+ #ifdef BUILD_DESIGNER
+ finalLayout->addWidget(checkBox);
+ #endif
finalLayout->addLayout(bottomLayout);
setLayout(finalLayout);
}
@@ -104,4 +123,11 @@ namespace qt
settings::Set(kMeasurementUnits, u);
}
+
+#ifdef BUILD_DESIGNER
+ void PreferencesDialog::OnEnabledAutoRegenGeomIndex(int i)
+ {
+ settings::Set(kEnabledAutoRegenGeomIndex, static_cast<bool>(i));
+ }
+#endif
}
diff --git a/qt/preferences_dialog.hpp b/qt/preferences_dialog.hpp
index 7347e9fd8a..3442344b4d 100644
--- a/qt/preferences_dialog.hpp
+++ b/qt/preferences_dialog.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "std/string.hpp"
+
#include <QtWidgets/QApplication>
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <QtGui/QDialog>
@@ -26,8 +28,15 @@ namespace qt
private slots:
void OnCloseClick();
void OnUnitsChanged(int i);
+#ifdef BUILD_DESIGNER
+ void OnEnabledAutoRegenGeomIndex(int i);
+#endif
private:
QButtonGroup * m_pUnits;
};
} // namespace qt
+
+#ifdef BUILD_DESIGNER
+extern string const kEnabledAutoRegenGeomIndex;
+#endif
diff --git a/qt/res/geom.png b/qt/res/geom.png
new file mode 100644
index 0000000000..6dd49d2203
--- /dev/null
+++ b/qt/res/geom.png
Binary files differ
diff --git a/qt/res/resources.qrc b/qt/res/resources.qrc
index a9f193dc4e..0bc39f9c81 100644
--- a/qt/res/resources.qrc
+++ b/qt/res/resources.qrc
@@ -22,6 +22,7 @@
<file>bug.png</file>
<file>chart.png</file>
<file>test.png</file>
+ <file>geom.png</file>
</qresource>
<qresource prefix="/ui">
<file>logo.png</file>
diff --git a/qt/update_dialog.cpp b/qt/update_dialog.cpp
index 1b9f3c32c0..4576a837e4 100644
--- a/qt/update_dialog.cpp
+++ b/qt/update_dialog.cpp
@@ -57,34 +57,8 @@ bool DeleteNotUploadedEditsConfirmation()
}
} // namespace
-namespace
-{
-MapOptions GetMapOptionsAvailableForDownload(Storage & st, TCountryId const & countryIndex)
-{
- platform::CountryFile const & countryFile = st.GetCountryFile(countryIndex);
- bool const hasCarRouting = (0 != countryFile.GetRemoteSize(MapOptions::CarRouting));
-
- MapOptions options = MapOptions::Map;
- if (hasCarRouting)
- options = SetOptions(options, MapOptions::CarRouting);
-
- return options;
-}
-} // namespace
-
namespace qt
{
- /// adds custom sorting for "Size" column
- class QTreeWidgetItemWithCustomSorting : public QTreeWidgetItem
- {
- public:
- virtual bool operator<(QTreeWidgetItem const & other) const
- {
- return data(KColumnIndexSize, Qt::UserRole).toULongLong() < other.data(KColumnIndexSize, Qt::UserRole).toULongLong();
- }
- };
-
-
UpdateDialog::UpdateDialog(QWidget * parent, Framework & framework)
: QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint),
m_framework(framework),
diff --git a/tools/unix/build_designer.sh b/tools/unix/build_designer.sh
index 091ee33d0f..164269d43b 100755
--- a/tools/unix/build_designer.sh
+++ b/tools/unix/build_designer.sh
@@ -44,10 +44,10 @@ cp "$OMIM_PATH/tools/python/recalculate_geom_index.py" "$MAC_RESOURCES/recalcula
# Copy all drules and resources (required for test environment)
rm -rf $MAC_RESOURCES/drules_proto*
rm -rf $MAC_RESOURCES/resources-*
-for i in ldpi mdpi hdpi xhdpi xxhdpi 6plus; do
- cp -r $OMIM_PATH/data/resources-${i}_legacy/ $MAC_RESOURCES/resources-$i/
+for i in mdpi hdpi xhdpi xxhdpi 6plus; do
+ cp -r $OMIM_PATH/data/resources-${i}_clear/ $MAC_RESOURCES/resources-$i/
done
-cp $OMIM_PATH/data/drules_proto_legacy.bin $MAC_RESOURCES/drules_proto.bin
+cp $OMIM_PATH/data/drules_proto_clear.bin $MAC_RESOURCES/drules_proto.bin
for i in resources-default countries-strings cuisine-strings WorldCoasts_obsolete.mwm countries.txt cuisines.txt countries_obsolete.txt packed_polygons.bin packed_polygons_obsolete.bin; do
cp -r $OMIM_PATH/data/$i $MAC_RESOURCES/
done