提交 e560434c 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add selection method to geomarker

上级 7f81d651
......@@ -22,7 +22,10 @@ QMap<viewer_interface *, qtvplugin_geomarker * > map_instances;
QMap<QString, int > count_instances;
qtvplugin_geomarker::qtvplugin_geomarker(QWidget *parent) :
QWidget(parent),
ui(new Ui::qtvplugin_geomarker)
ui(new Ui::qtvplugin_geomarker),
m_currentTools(qtvplugin_geomarker::TOOLS_DISPLAY_ONLY),
m_sel_ptStart_World(0,0),
m_sel_ptEnd_World(0,0)
{
m_nInstance = 0;
ui->setupUi(this);
......@@ -41,6 +44,12 @@ qtvplugin_geomarker::qtvplugin_geomarker(QWidget *parent) :
m_pGeoItemModel->setHeaderData(2,Qt::Horizontal,tr("Props"));
ui->tableView_marks->setModel(m_pGeoItemModel);
m_pSelItemNameModel = new QStandardItemModel(this);
m_pSelItemNameModel->setColumnCount(1);
m_pSelItemNameModel->setHeaderData(0,Qt::Horizontal,tr("Name"));
ui->tableView_marks_sel->setModel(m_pSelItemNameModel);
m_pGeoPropModel = new QStandardItemModel(this);
m_pGeoPropModel->setColumnCount(2);
m_pGeoPropModel->setHeaderData(0,Qt::Horizontal,tr("Name"));
......@@ -94,6 +103,8 @@ qtvplugin_geomarker::qtvplugin_geomarker(QWidget *parent) :
m_nTimerID_refreshUI = startTimer(2000);
m_nTimerID_refreshMap = startTimer(100);
m_nTimerID_levelQueue = startTimer(100);
ui->radioButton_display->setChecked(true);
}
qtvplugin_geomarker::~qtvplugin_geomarker()
......@@ -271,12 +282,65 @@ void qtvplugin_geomarker::cb_paintEvent( QPainter * pImage )
QString strmsg= tr("Level Re-Coord %1 %%").arg(pc*100);
pImage->drawText(left+32,top+16,strmsg);
}
//draw current tools
switch (m_currentTools)
{
case qtvplugin_geomarker::TOOLS_RECT_SELECTION:
{
QPen pen_sel(QColor(128,64,0,128));
pen_sel.setWidth(3);
pen_sel.setStyle(Qt::DashLine);
pImage->setPen(pen_sel);
pImage->drawText(32,32,"GEO MARKER Rect-Selection Tools Actived.");
QRectF wrct = current_sel_RectWorld();
if (wrct.isValid())
{
double x1 = wrct.left();
double y1 = wrct.top();
double x2 = wrct.right();
double y2 = wrct.bottom();
qint32 nx1,ny1,nx2,ny2;
m_pVi->CV_World2DP(x1,y1,&nx1,&ny1);
m_pVi->CV_World2DP(x2,y2,&nx2,&ny2);
for (int i = -1;i<=1;++i)
{
pImage->drawLine(nx1 + i * winsz,ny1,nx1 + i * winsz,ny2);
pImage->drawLine(nx1 + i * winsz,ny2,nx2 + i * winsz,ny2);
pImage->drawLine(nx2 + i * winsz,ny2,nx2 + i * winsz,ny1);
pImage->drawLine(nx2 + i * winsz,ny1,nx1 + i * winsz,ny1);
}
}
}
break;
default:
break;
}
if (m_sel_rects_merkator.empty()==false)
{
QPen pen_sel(QColor(0,64,255,128));
pen_sel.setWidth(2);
pen_sel.setStyle(Qt::DotLine);
pImage->setPen(pen_sel);
//draw select regions
foreach (QRectF wr, m_sel_rects_merkator)
{
double wx1,wy1,wx2,wy2;
qint32 nx1,ny1,nx2,ny2;
m_pVi->CV_MK2World(wr.left(),wr.top(),&wx1,&wy1);
m_pVi->CV_MK2World(wr.right(),wr.bottom(),&wx2,&wy2);
m_pVi->CV_World2DP(wx1,wy1,&nx1,&ny1);
m_pVi->CV_World2DP(wx2,wy2,&nx2,&ny2);
for (int i = -1;i<=1;++i)
pImage->drawRect(QRectF(QPointF(nx1 + i * winsz,ny1),QPointF(nx2 + i * winsz,ny2)));
}
}
}
void qtvplugin_geomarker::cb_levelChanged(int level)
{
if (!m_pVi)
return ;
m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
//Adjust new Scene rect
QRectF rect(0,0,256*(1<<level),256*(1<<level));
this->set_visible(false);
......@@ -294,6 +358,23 @@ void qtvplugin_geomarker::set_visible(bool vb)
{
m_bVisible = vb;
}
void qtvplugin_geomarker::set_active(bool ab)
{
if (ab==true)
{
if (m_currentTools==qtvplugin_geomarker::TOOLS_DISPLAY_ONLY)
{
ui->radioButton_rect_selection->setChecked(true);
m_currentTools = qtvplugin_geomarker::TOOLS_RECT_SELECTION;
}
}
else
{
m_currentTools = qtvplugin_geomarker::TOOLS_DISPLAY_ONLY;
ui->radioButton_display->setChecked(true);
}
}
QString qtvplugin_geomarker::get_name()
{
......@@ -311,6 +392,82 @@ void qtvplugin_geomarker::set_name(QString /*vb*/)
if (!m_pVi)
return ;
}
QRectF qtvplugin_geomarker::CV_RectWrold2Mkt(QRectF world)
{
if (!m_pVi) return QRectF();
double mx1,my1,mx2,my2;
m_pVi->CV_World2MK(world.left(),world.top(),&mx1,&my1);
m_pVi->CV_World2MK(world.right(),world.bottom(),&mx2,&my2);
return QRectF(QPointF(mx1,my1),QPointF(mx2,my2));
}
QRectF qtvplugin_geomarker::current_sel_RectWorld()
{
if (!m_pVi) return QRectF();
if (m_currentTools!=qtvplugin_geomarker::TOOLS_RECT_SELECTION)
return QRectF();
if (m_sel_ptEnd_World.isNull() || m_sel_ptStart_World.isNull())
return QRectF();
qint32 wsz = 256*(1<<m_pVi->level());
int wx1 = m_sel_ptStart_World.x(),wx2 = m_sel_ptEnd_World.x(),
wy1 = m_sel_ptStart_World.y(), wy2 = m_sel_ptEnd_World.y();
while (wx2 - wx1 > wsz/2)
wx1+=wsz;
while (wx2 - wx1 < -wsz/2)
wx2+=wsz;
if (wx1 > wx2)
{
float tp = wx1;
wx1 = wx2;
wx2 = tp;
}
if (wy1 > wy2)
{
float tp = wy1;
wy1 = wy2;
wy2 = tp;
}
return QRectF(QPointF(wx1,wy1),QPointF(wx2,wy2));
}
void qtvplugin_geomarker::clearSelection()
{
m_set_itemNameSelected.clear();
m_sel_rects_merkator.clear();
refresh_selection_listview();
m_pVi->UpdateWindow();
}
void qtvplugin_geomarker::addSelection(QRectF rectWorld)
{
qint32 wsz = 256*(1<<m_pVi->level());
int oldsz = m_set_itemNameSelected.size();
for (int i=-1;i<=1;++i)
{
double x1 = rectWorld.left()+i * wsz,
y1 = rectWorld.top(),
x2 = rectWorld.right()+i * wsz,
y2 = rectWorld.bottom();
QList<QGraphicsItem *> itmesel = m_pScene->items(QRectF(QPointF(x1,y1),QPointF(x2,y2)));
foreach (QGraphicsItem * it, itmesel)
{
QTVP_GEOMARKER::geoItemBase *
gi = dynamic_cast<QTVP_GEOMARKER::geoItemBase *>(it);
if (gi)
{
m_set_itemNameSelected.insert(gi->item_name());
}
}
}
int newsz = m_set_itemNameSelected.size();
if (newsz>oldsz)
{
m_sel_rects_merkator.push_back(CV_RectWrold2Mkt(rectWorld));
refresh_selection_listview();
scheduleUpdateMap();
}
}
bool qtvplugin_geomarker::cb_event(const QMap<QString, QVariant> para)
......@@ -421,9 +578,98 @@ bool qtvplugin_geomarker::cb_mousePressEvent(QMouseEvent * e)
QApplication::postEvent(m_pScene, &mouseEvent);
scheduleUpdateMap();
}
//tools
switch (m_currentTools)
{
case qtvplugin_geomarker::TOOLS_RECT_SELECTION:
{
if (e->button()==Qt::LeftButton)
{
m_sel_ptStart_World = m_sel_ptEnd_World = QPointF(wx,wy);
}
}
break;
default:
break;
}
return false;
}
bool qtvplugin_geomarker::cb_mouseMoveEvent ( QMouseEvent * e )
{
if (!m_pVi)
return false;
if (m_bVisible==false)
return false;
QPoint mouse_view_pt = e->pos();
int winsz = 256 * (1<<m_pVi->level());
double wx,wy;
m_pVi->CV_DP2World(mouse_view_pt.x(),mouse_view_pt.y(),&wx,&wy);
//Warp
while (wx < 0) wx += winsz;
while (wx > winsz-1) wx -= winsz;
//tools
switch (m_currentTools)
{
case qtvplugin_geomarker::TOOLS_RECT_SELECTION:
{
if (e->buttons()==Qt::LeftButton)
{
m_sel_ptEnd_World = QPointF(wx,wy);
scheduleUpdateMap();
}
}
break;
default:
break;
}
return false;
}
bool qtvplugin_geomarker::cb_mouseReleaseEvent ( QMouseEvent * e )
{
if (!m_pVi)
return false;
if (m_bVisible==false)
return false;
QPoint mouse_view_pt = e->pos();
int winsz = 256 * (1<<m_pVi->level());
double wx,wy;
m_pVi->CV_DP2World(mouse_view_pt.x(),mouse_view_pt.y(),&wx,&wy);
//Warp
while (wx < 0) wx += winsz;
while (wx > winsz-1) wx -= winsz;
//tools
switch (m_currentTools)
{
case qtvplugin_geomarker::TOOLS_RECT_SELECTION:
{
if (e->button()==Qt::LeftButton)
{
m_sel_ptEnd_World = QPointF(wx,wy);
QRectF rectSel = current_sel_RectWorld();
m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
addSelection(rectSel);
scheduleUpdateMap();
}
}
break;
default:
break;
}
return false;
}
/*! for convenience, color is stored in plain text in XML and UI.
* the plain text color is 4 sub value , which stands for r,g,b,alpha.
*
......@@ -481,6 +727,17 @@ void qtvplugin_geomarker::scheduleUpdateMap()
//We will set a flag and refresh the ui in timerEvent Instead.
m_bNeedUpdateView = true;
}
void qtvplugin_geomarker::refresh_selection_listview()
{
if (!m_pVi || !m_pScene)
return;
//refersh
this->m_pSelItemNameModel->removeRows(0,this->m_pSelItemNameModel->rowCount());
foreach (QString name, m_set_itemNameSelected)
{
m_pSelItemNameModel->appendRow(new QStandardItem(name));
}
}
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_line(const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen)
{
......@@ -675,7 +932,3 @@ QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_icon(const QString & n
}
return res;
}
void qtvplugin_geomarker::on_pushButton_refresh_list_clicked()
{
this->scheduleRefreshMarks();
}
......@@ -16,6 +16,7 @@ namespace Ui {
class qtvplugin_geomarker;
}
using namespace QTVOSM;
/*!
\brief qtvplugin_geomarker introduces QGraphicesView system, established a common approach for geo marking.
GEO marker is a vector symbol that will be displayed on the background OSM raster map. there are 3 different mark types supported by this plugin.
......@@ -53,7 +54,11 @@ private:
};
//The global icon map
QMap<QString,QTVP_GEOMARKER::tag_icon> m_map_icons;
//Enum tools
enum enum_tools_selection{
TOOLS_DISPLAY_ONLY = 0,
TOOLS_RECT_SELECTION = 1
};
public:
qtvplugin_geomarker(QWidget *parent = 0);
~qtvplugin_geomarker();
......@@ -67,7 +72,6 @@ public:
QTVP_GEOMARKER::geoGraphicsScene * scene(){return m_pScene;}
private:
int m_nInstance;
QTVP_GEOMARKER::geoGraphicsScene * m_pScene; //! the graphics scene object pointer.
QTranslator pluginTranslator;
Ui::qtvplugin_geomarker *ui;
......@@ -75,6 +79,19 @@ private:
bool m_bVisible;
QString m_SLLibName;
QString m_SLLibPath;
//selections
private:
//current tools here
enum_tools_selection m_currentTools;
//selection tool
QPointF m_sel_ptStart_World;
QPointF m_sel_ptEnd_World;
QSet<QString> m_set_itemNameSelected;
QList<QRectF> m_sel_rects_merkator;
QRectF CV_RectWrold2Mkt(QRectF world);
QRectF current_sel_RectWorld();
void addSelection(QRectF rectWorld);
void clearSelection();
private:
/*! a timer provides timing ui-refresh , instead of immediately refresh when item has been updated.
* This timer is just affects UI widgets, Map will be updated immediately otherwise.
......@@ -91,6 +108,7 @@ private:
QStandardItemModel * m_pGeoItemModel;
QStandardItemModel * m_pGeoPropModel;
QStandardItemModel * m_pIconsModel;
QStandardItemModel * m_pSelItemNameModel;
//persistent functions
private:
......@@ -113,6 +131,7 @@ private:
QList<QString> m_items_to_insert;
void scheduleRefreshMarks();
void scheduleUpdateMap();
void refresh_selection_listview();
void refreshItemUI(QString markname);
void refreshProps(QTVP_GEOMARKER::geoItemBase * itm);
QColor string2color(const QString & s);
......@@ -154,6 +173,13 @@ private:
QMap<QString, QVariant> func_load_resources (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_props_vis (const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_show_props (const QMap<QString, QVariant> &);
private:
//tools methods
QMap<QString, QVariant> func_set_mod (const QMap<QString, QVariant> &);
//selection methods
QMap<QString, QVariant> func_selection_clear(const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_selection_delete(const QMap<QString, QVariant> &);
QMap<QString, QVariant> func_selected_items (const QMap<QString, QVariant> &);
//overloaded virtual funtions
protected:
......@@ -163,11 +189,16 @@ protected:
bool is_visible();
void set_visible(bool vb);
bool is_active(){return m_currentTools==qtvplugin_geomarker::TOOLS_DISPLAY_ONLY?false:true;}
void set_active(bool ab);
void set_name(QString vb);
bool is_exclusive(){return true;}
void cb_paintEvent( QPainter * pImage );
void cb_levelChanged(int);
bool cb_mouseMoveEvent(QMouseEvent *);
bool cb_mousePressEvent(QMouseEvent *);
bool cb_mouseReleaseEvent ( QMouseEvent * /*event*/ );
bool cb_mouseDoubleClickEvent(QMouseEvent *);
bool cb_event(const QMap<QString, QVariant>);
......@@ -197,6 +228,10 @@ protected slots:
void on_pushButton_save_icons_clicked();
void on_pushButton_refresh_list_clicked();
void on_pushButton_collaps_all_clicked();
void on_radioButton_display_clicked();
void on_radioButton_rect_selection_clicked();
void on_pushButton_sel_clear_clicked();
void on_pushButton_sel_delselected_clicked();
};
template <class T>
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>458</width>
<height>444</height>
<width>469</width>
<height>483</height>
</rect>
</property>
<property name="windowTitle">
......@@ -38,7 +38,7 @@
<property name="title">
<string>Marks</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<layout class="QVBoxLayout" name="verticalLayout_11">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
......@@ -71,13 +71,155 @@
</layout>
</item>
<item>
<widget class="QTableView" name="tableView_marks">
<widget class="QGroupBox" name="groupBox_operation">
<property name="title">
<string>Map Operation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<widget class="QRadioButton" name="radioButton_display">
<property name="text">
<string>Display Only</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_rect_selection">
<property name="text">
<string>Rect Selection</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QToolBox" name="toolBox_marks">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="tabSpacing">
<number>1</number>
</property>
<widget class="QWidget" name="page">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>169</width>
<height>194</height>
</rect>
</property>
<attribute name="label">
<string>All marks</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_10">
<property name="spacing">
<number>1</number>
</property>
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QTableView" name="tableView_marks">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>166</width>
<height>272</height>
</rect>
</property>
<attribute name="label">
<string>Selected marks</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<item>
<widget class="QPushButton" name="pushButton_sel_clear">
<property name="text">
<string>Clear Sel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_22">
<item>
<widget class="QPushButton" name="pushButton_sel_delselected">
<property name="text">
<string>Delete Selected Items</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QTableView" name="tableView_marks_sel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
......@@ -154,20 +296,6 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>ID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_currentID"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
......@@ -176,6 +304,20 @@
<property name="spacing">
<number>1</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>ID</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_currentID"/>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget_marks">
<property name="sizePolicy">
......
......@@ -31,6 +31,10 @@
* 16 sava_xml save marks to diskette in xml format
* 17 props_vis(ibiliuty) collapse detail display for items.
* 18 show_props show_details
* 19 set_mod set current mod.0=display, 1 = rect selection
* 20 selection_clear clear all selected items' status.
* 21 selection_delete delete all selected items.
* 22 selected_items return all selected item names
* @param paras the key-value style paraments.
* @return QMap<QString, QVariant> the key-value style return values.
*/
......@@ -74,6 +78,10 @@ void qtvplugin_geomarker::initialBindPluginFuntions()
m_map_pluginFunctions["load_resources"] = std::bind(&qtvplugin_geomarker::func_load_resources, this,std::placeholders::_1);
m_map_pluginFunctions["props_vis"] = std::bind(&qtvplugin_geomarker::func_props_vis, this,std::placeholders::_1);
m_map_pluginFunctions["show_props"] = std::bind(&qtvplugin_geomarker::func_show_props, this,std::placeholders::_1);
m_map_pluginFunctions["set_mod"] = std::bind(&qtvplugin_geomarker::func_set_mod, this,std::placeholders::_1);
m_map_pluginFunctions["selection_clear"]= std::bind(&qtvplugin_geomarker::func_selection_clear, this,std::placeholders::_1);
m_map_pluginFunctions["selection_delete"]=std::bind(&qtvplugin_geomarker::func_selection_delete,this,std::placeholders::_1);
m_map_pluginFunctions["selected_items"] = std::bind(&qtvplugin_geomarker::func_selected_items, this,std::placeholders::_1);
}
......@@ -1334,3 +1342,109 @@ QMap<QString, QVariant> qtvplugin_geomarker::func_show_props (const QMap<QStr
//! the return value is "name=v;" serials, v=0 means props are collapsed, otherwise means props is visible.
return std::move(res);
}
//tools methods
/**
* @brief func_set_mod is a internal function for plugin call_func "set_mod"
*
* the paraments used by paras is listed below.
* function=set_mod;
* @param paras The key-value style paraments.
* @return QMap<QString, QVariant> if error happens, a property called "error" will store the most possible reason.
*/
QMap<QString, QVariant> qtvplugin_geomarker::func_set_mod (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
//! the current mod can be set using the UI tools "radio button".
//!
//! all other props will be hidden.
if (paras.contains("mod")==false)
{
res["error"] = tr("mod must exist in paraments.");
return std::move(res);
}
int mod = paras["mod"].toInt();
if (mod==0)
{
ui->radioButton_display->setChecked(true);
ui->toolBox_marks->setCurrentIndex(0);
m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
m_currentTools = qtvplugin_geomarker::TOOLS_DISPLAY_ONLY;
layer_interface * pOSM = m_pVi->layer("OSM");
if (pOSM)
{
pOSM->set_active(true);
m_pVi->adjust_layers(pOSM);
}
m_pVi->UpdateWindow();
m_pVi->updateLayerGridView();
}
else if (mod==1)
{
ui->radioButton_rect_selection->setChecked(true);
ui->toolBox_marks->setCurrentIndex(1);
m_currentTools = qtvplugin_geomarker::TOOLS_RECT_SELECTION;
m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
m_pVi->adjust_layers(this);
m_pVi->UpdateWindow();
m_pVi->updateLayerGridView();
}
else
{
res["error"] = tr("mod is not valid in paraments. 0=display, 1=rect selection");
return std::move(res);
}
return std::move(res);
}
//selection methods
/**
* @brief func_set_mod is a internal function for plugin call_func "selection_clear"
*
* the paraments used by paras is listed below.
* function=selection_clear;
* @param paras The key-value style paraments.
* @return QMap<QString, QVariant> if error happens, a property called "error" will store the most possible reason.
*/
QMap<QString, QVariant> qtvplugin_geomarker::func_selection_clear(const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
this->on_pushButton_sel_clear_clicked();
return std::move(res);
}
/**
* @brief func_set_mod is a internal function for plugin call_func "selection_delete"
*
* the paraments used by paras is listed below.
* function=selection_delete;
* @param paras The key-value style paraments.
* @return QMap<QString, QVariant> if error happens, a property called "error" will store the most possible reason.
*/
QMap<QString, QVariant> qtvplugin_geomarker::func_selection_delete(const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
this->on_pushButton_sel_delselected_clicked();
return std::move(res);
}
/**
* @brief func_set_mod is a internal function for plugin call_func "selected_items"
*
* the paraments used by paras is listed below.
* function=selected_items;
* @param paras The key-value style paraments.
* @return QMap<QString, QVariant> if error happens, a property called "error" will store the most possible reason.
* the return value is stored in pairs, name0=??;name1=??;name2=??...namen-1=??...;
*/
QMap<QString, QVariant> qtvplugin_geomarker::func_selected_items (const QMap<QString, QVariant> & paras)
{
QMap<QString, QVariant> res;
int ct = 0;
foreach (QString namestr,m_set_itemNameSelected)
{
QString keystr = QString("name%1").arg(ct++);
res[keystr] = namestr;
}
//! the mark names will be stored in key-value pairs, with
//! name0=??;name1=??;name2=??...namen-1=??
return std::move(res);
}
......@@ -771,3 +771,50 @@ void qtvplugin_geomarker::on_pushButton_collaps_all_clicked()
scheduleUpdateMap();
}
}
void qtvplugin_geomarker::on_pushButton_refresh_list_clicked()
{
this->scheduleRefreshMarks();
}
void qtvplugin_geomarker::on_radioButton_display_clicked()
{
if (!m_pVi) return ;
m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
m_currentTools = qtvplugin_geomarker::TOOLS_DISPLAY_ONLY;
layer_interface * pOSM = m_pVi->layer("OSM");
if (pOSM)
{
pOSM->set_active(true);
m_pVi->adjust_layers(pOSM);
}
m_pVi->UpdateWindow();
m_pVi->updateLayerGridView();
ui->toolBox_marks->setCurrentIndex(0);
}
void qtvplugin_geomarker::on_radioButton_rect_selection_clicked()
{
if (!m_pVi) return ;
m_currentTools = qtvplugin_geomarker::TOOLS_RECT_SELECTION;
m_sel_ptStart_World = m_sel_ptEnd_World = QPointF();
m_pVi->adjust_layers(this);
m_pVi->UpdateWindow();
m_pVi->updateLayerGridView();
ui->toolBox_marks->setCurrentIndex(1);
}
void qtvplugin_geomarker::on_pushButton_sel_clear_clicked()
{
clearSelection();
}
void qtvplugin_geomarker::on_pushButton_sel_delselected_clicked()
{
foreach (QString namep,m_set_itemNameSelected)
{
QTVP_GEOMARKER::geoItemBase * b = m_pScene->geoitem_by_name(namep);
if (b)
m_pScene->removeItem(b,0);
}
clearSelection();
scheduleRefreshMarks();
}
......@@ -397,17 +397,21 @@ void qtvplugin_grid::CalArea()
//Length
double dTotalDis = 0;
double dPreLat,dPreLon;
QString str_Polygon,str_LineString;
QString str_Polygon,str_LineString,str_QuickMark;
str_Polygon = ("ST_Transform(ST_GeomFromText('POLYGON(\n(");
str_LineString = ("ST_Transform(ST_GeomFromText('LINESTRING(\n(");
QString strLLASets;
bool bLatFirst = ui->radioButton_latfirst->isChecked();
for (int i=0;i<Count;i++)
{
double dLatCurr = m_list_points[i].x(),dLonCurr = m_list_points[i].y();
strLLASets += QString ("%1 , %2 \015\012")
.arg(dLatCurr,0,'f',7)
.arg(dLonCurr,0,'f',7);
if (bLatFirst)
str_QuickMark += QString("%1 , %2\n").arg(dLatCurr,0,'f',7).arg(dLonCurr,0,'f',7);
else
str_QuickMark += QString("%2 , %1\n").arg(dLatCurr,0,'f',7).arg(dLonCurr,0,'f',7);
if (i>0)
{
double sita;
......@@ -453,7 +457,7 @@ void qtvplugin_grid::CalArea()
delete [] buffertmp;
ui->plainTextEdit_RES->setPlainText(strMsg);
ui->plainTextEdit_markcmd->setPlainText(strLLASets);
ui->plainTextEdit_markcmd->setPlainText(str_QuickMark);
}
/**
......@@ -730,6 +734,7 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
QString strAll = ui->plainTextEdit_markcmd->toPlainText();
QStringList strLines = strAll.split("\n",QString::SkipEmptyParts);
int c = 0;
bool bLatFirst = ui->radioButton_latfirst->isChecked();
QMap<QString, QVariant> map_multi;
foreach (QString str, strLines)
{
......@@ -771,10 +776,16 @@ void qtvplugin_grid::on_pushButton_add_mark_clicked()
QMessageBox::warning(
this,
tr("Error LLA formar"),
tr("Lat will be first, lon will be last, lat lon must have same element nums.")
tr("lat lon must have same element nums.")
);
break;
}
if (bLatFirst==false)
{
double tmp = lat;
lat = lon;
lon = tmp;
}
lat *= latNG;
lon *= lonNG;
......@@ -870,6 +881,11 @@ void qtvplugin_grid::load_ini()
ui->lineEdit_west_spliter->setText(settings.value("settings/lineEdit_west_spliter","W").toString());
ui->plainTextEdit_markcmd->setPlainText(settings.value("settings/plainTextEdit_markcmd","").toString());
ui->combox_type->setCurrentIndex(settings.value("settings/combox_type",0).toInt());
bool bLatFirst = settings.value("settings/latfirst",true).toBool();
if (bLatFirst)
ui->radioButton_latfirst->setChecked(true);
else
ui->radioButton_lonfirst->setChecked(true);
}
void qtvplugin_grid::save_ini()
......@@ -879,4 +895,6 @@ void qtvplugin_grid::save_ini()
settings.setValue("settings/lineEdit_west_spliter",ui->lineEdit_west_spliter->text());
settings.setValue("settings/plainTextEdit_markcmd",ui->plainTextEdit_markcmd->toPlainText());
settings.setValue("settings/combox_type",ui->combox_type->currentIndex());
bool bLatFirst = ui->radioButton_latfirst->isChecked();
settings.setValue("settings/latfirst",bLatFirst);
}
......@@ -64,10 +64,27 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QRadioButton" name="radioButton_latfirst">
<property name="text">
<string>LatLon</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="radioButton_lonfirst">
<property name="text">
<string>LonLat</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>West spliter</string>
<string>,West spliter</string>
</property>
</widget>
</item>
......
......@@ -533,3 +533,44 @@ void testcontainer::on_osmmap_map_event(QMap<QString, QVariant> p)
ui->tableView_msg->scrollToBottom();
}
}
void testcontainer::on_pushButton_test_geo_displayMod_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)",m_str_markerLayerName,
"function=set_mod;mod=0;").toString();
if (res.contains("error"))
QMessageBox::information(this,"geomarker::set_mod",res);
}
void testcontainer::on_pushButton_test_geo_selectionMod_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)",m_str_markerLayerName,
"function=set_mod;mod=1;").toString();
if (res.contains("error"))
QMessageBox::information(this,"geomarker::set_mod",res);
}
void testcontainer::on_pushButton_test_geo_selected_marks_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)",m_str_markerLayerName,
"function=selected_items;").toString();
QMessageBox::information(this,"geomarker::selected_items",res);
}
void testcontainer::on_pushButton_test_geo_clear_sel_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)",m_str_markerLayerName,
"function=selection_clear;").toString();
if (res.contains("error"))
QMessageBox::information(this,"geomarker::selection_clear",res);
}
void testcontainer::on_pushButton_test_geo_del_sel_clicked()
{
QString res = ui->axWidget_map1->dynamicCall("osm_layer_call_function(QString,QString)",m_str_markerLayerName,
"function=selection_delete;").toString();
if (res.contains("error"))
QMessageBox::information(this,"geomarker::selection_delete",res);
}
......@@ -27,7 +27,7 @@ private:
QString m_str_markerLayerName;
void confirmLayerNames();
void show_message(QString);
#ifdef WIN32
#ifdef _WIN32
protected slots:
void slot_message(QString);
#endif
......@@ -46,7 +46,13 @@ protected slots:
void on_pushButton_test_request_clicked();
void on_pushButton_test_xml_clicked();
void on_pushButton_test_resource_clicked();
void on_pushButton_test_geo_displayMod_clicked();
void on_pushButton_test_geo_selectionMod_clicked();
void on_pushButton_test_geo_selected_marks_clicked();
void on_pushButton_test_geo_clear_sel_clicked();
void on_pushButton_test_geo_del_sel_clicked();
void on_osmmap_map_event(QMap<QString, QVariant> p);
};
#endif // TESTCONTAINER_H
......@@ -16,94 +16,101 @@
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_test_cache">
<property name="text">
<string>Layer control</string>
<string>cache Folder</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QPushButton" name="pushButton_test_navigate">
<item row="13" column="0">
<widget class="QPushButton" name="pushButton_test_polygon">
<property name="text">
<string>navigate</string>
<string>add a polygon</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QPushButton" name="pushButton_test_cache">
<item row="16" column="0">
<widget class="QPushButton" name="pushButton_test_geo_selected_marks">
<property name="text">
<string>cache Folder</string>
<string>selected_marks</string>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QPushButton" name="pushButton_test_xml">
<item row="9" column="0">
<widget class="QPushButton" name="pushButton_test_grid_enable">
<property name="text">
<string>marks save/load</string>
<string>measure on/off</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QPushButton" name="pushButton_test_mark">
<item row="8" column="1">
<widget class="QLabel" name="label_5">
<property name="text">
<string>add marks</string>
<string>Grid measure</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="label_4">
<item row="6" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Plugin test:</string>
<string>Layer control</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<item row="11" column="1">
<widget class="QPushButton" name="pushButton_test_line">
<property name="text">
<string>background osm conn</string>
<string>add a line</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_test_autodl">
<item row="5" column="0">
<widget class="QPushButton" name="pushButton_test_navigate">
<property name="text">
<string>connect</string>
<string>navigate</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QPushButton" name="pushButton_test_grid_getPolygon">
<item row="13" column="1">
<widget class="QPushButton" name="pushButton_test_request">
<property name="text">
<string>get polygon</string>
<string>get info</string>
</property>
</widget>
</item>
<item row="14" column="0">
<widget class="QPushButton" name="pushButton_test_resource">
<item row="10" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>res save/load</string>
<string>Plugin test:</string>
</property>
</widget>
</item>
<item row="9" column="0">
<widget class="QPushButton" name="pushButton_test_grid_enable">
<item row="1" column="1">
<widget class="QPushButton" name="pushButton_test_autodl">
<property name="text">
<string>measure on/off</string>
<string>connect</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_test_adds">
<item row="14" column="0">
<widget class="QPushButton" name="pushButton_test_resource">
<property name="text">
<string>address</string>
<string>res save/load</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QPushButton" name="pushButton_test_layers">
<item row="15" column="0">
<widget class="QPushButton" name="pushButton_test_geo_displayMod">
<property name="text">
<string>enum layers</string>
<string>display mod</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QPushButton" name="pushButton_test_geo_selectionMod">
<property name="text">
<string>selection mod</string>
</property>
</widget>
</item>
......@@ -121,17 +128,17 @@
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_5">
<item row="8" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Grid measure</string>
<string>Plugin test:</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="label_6">
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_test_adds">
<property name="text">
<string>Plugin test:</string>
<string>address</string>
</property>
</widget>
</item>
......@@ -142,7 +149,7 @@
</property>
</widget>
</item>
<item row="16" column="0">
<item row="18" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -155,24 +162,52 @@
</property>
</spacer>
</item>
<item row="13" column="0">
<widget class="QPushButton" name="pushButton_test_polygon">
<item row="9" column="1">
<widget class="QPushButton" name="pushButton_test_grid_getPolygon">
<property name="text">
<string>add a polygon</string>
<string>get polygon</string>
</property>
</widget>
</item>
<item row="13" column="1">
<widget class="QPushButton" name="pushButton_test_request">
<item row="7" column="0">
<widget class="QPushButton" name="pushButton_test_layers">
<property name="text">
<string>get info</string>
<string>enum layers</string>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QPushButton" name="pushButton_test_line">
<item row="16" column="1">
<widget class="QPushButton" name="pushButton_test_geo_clear_sel">
<property name="text">
<string>add a line</string>
<string>clear selection</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QPushButton" name="pushButton_test_mark">
<property name="text">
<string>add marks</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>background osm conn</string>
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QPushButton" name="pushButton_test_xml">
<property name="text">
<string>marks save/load</string>
</property>
</widget>
</item>
<item row="17" column="0">
<widget class="QPushButton" name="pushButton_test_geo_del_sel">
<property name="text">
<string>delete selection</string>
</property>
</widget>
</item>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册