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

Merge branch 'develop'

......@@ -22,6 +22,7 @@ namespace QTVOSM{
{
bool needDo = false;
bool allFinished = false;
bool succeeded = false;
m_mutex_protect.lock();
if (m_map_pendingTasks.contains(rply)==true)
{
......@@ -39,6 +40,7 @@ namespace QTVOSM{
{
file.write(rply->readAll());
file.close();
succeeded = true;
}
}
else
......@@ -59,7 +61,7 @@ namespace QTVOSM{
m_mutex_protect.unlock();
if (needDo)
emit evt_doNextJob();
if (allFinished == true)
if (allFinished == true && succeeded)
emit evt_all_taskFinished();
}
......
......@@ -2,6 +2,7 @@
#include "geographicsscene.h"
#include "../qtviewer_planetosm/osmtiles/viewer_interface.h"
#include <QTextEdit>
#include <QCoreApplication>
namespace QTVP_GEOMARKER{
geoItemBase::geoItemBase(QString name,geo_item_type tp,QTVOSM::viewer_interface * pVi)
:m_pVi(pVi)
......@@ -68,7 +69,11 @@ namespace QTVP_GEOMARKER{
if (k=="LABEL" && pc)
{
if (!m_pLabelItem)
{
m_pLabelItem = new QGraphicsTextItem(v.toString(),pc);
m_pLabelItem->setDefaultTextColor(m_LabelTextColor);
m_pLabelItem->setFont(m_LabelTextFont);
}
else if (m_bPropVisible==false)
m_pLabelItem->setPlainText(v.toString());
m_pLabelItem->setPos(this->label_pos());
......@@ -109,7 +114,11 @@ namespace QTVP_GEOMARKER{
propValues.pop_front();
}
if (!m_pLabelItem)
{
m_pLabelItem = new QGraphicsTextItem(str,pc);
m_pLabelItem->setDefaultTextColor(m_LabelTextColor);
m_pLabelItem->setFont(m_LabelTextFont);
}
else
m_pLabelItem->setPlainText(str);
m_pLabelItem->setPos(this->label_pos());
......@@ -132,7 +141,11 @@ namespace QTVP_GEOMARKER{
else
{
if (!m_pLabelItem)
{
m_pLabelItem = new QGraphicsTextItem(v.toString(),pc);
m_pLabelItem->setDefaultTextColor(m_LabelTextColor);
m_pLabelItem->setFont(m_LabelTextFont);
}
m_pLabelItem->setPlainText(v.toString());
m_pLabelItem->setPos(this->label_pos());
}
......
......@@ -4,6 +4,8 @@
#include <QRectF>
#include <QMap>
#include <QVariant>
#include <QFont>
#include <QColor>
#include <QGraphicsTextItem>
namespace QTVOSM{
class viewer_interface;
......@@ -40,6 +42,8 @@ namespace QTVP_GEOMARKER{
void setViewInterface(QTVOSM::viewer_interface * pVi);
private:
QFont m_LabelTextFont;
QColor m_LabelTextColor;
bool m_bPropVisible;
int m_nCurrentLevel;
QGraphicsTextItem * m_pLabelItem;
......@@ -55,6 +59,10 @@ namespace QTVP_GEOMARKER{
void set_item_type (geo_item_type tp) {m_type = tp;}
QString item_name () const {return m_name;}
void set_item_name (QString na) {m_name = na;}
void setLabelFont (QFont font) {m_LabelTextFont = font;if (m_pLabelItem) m_pLabelItem->setFont(m_LabelTextFont);}
QFont labelFont () {return m_LabelTextFont;}
void setLabelColor (QColor col) {m_LabelTextColor = col;if (m_pLabelItem) m_pLabelItem->setDefaultTextColor(m_LabelTextColor);}
QColor labelColor () {return m_LabelTextColor;}
void adjustLabelPos ();
QStringList prop_names();
......
......@@ -122,7 +122,7 @@ layer_interface * qtvplugin_geomarker::load_initial_plugin(QString strSLibPath,v
assert(ret==instance);
return ret;
}
qDebug()<<QFont::substitutions();
return instance;
}
void qtvplugin_geomarker::loadTranslations()
......@@ -161,25 +161,35 @@ void qtvplugin_geomarker::cb_paintEvent( QPainter * pImage )
double leftcenx, topceny, rightcenx, bottomceny;
m_pVi->CV_DP2World(0,0,&leftcenx,&topceny);
m_pVi->CV_DP2World(rect.width()-1,rect.height()-1,&rightcenx,&bottomceny);
QRectF source(
leftcenx ,
topceny,
(rightcenx - leftcenx),
(bottomceny - topceny)
);
int winsz = 256 * (1<<m_pVi->level());
//Warpping 180, -180
for (int t = -1; t <=1;++t)
for (int p = -1; p<=1 ;++p)
{
QRectF destin(
0 + winsz * t ,
0,
rect.width(),
rect.height()
QRectF source(
leftcenx + p * winsz,
topceny,
(rightcenx - leftcenx),
(bottomceny - topceny)
);
if (destin.right() < 0 || destin.left() >= rect.width())
continue;
m_pScene->render(pImage,destin,source);
for (int t = -1; t <=1;++t)
{
if (abs(p-t)==2 || (p==t && p !=0))
continue;
if (abs(p-t)==1 && (p==0 || t ==1))
continue;
QRectF destin(
0 + winsz * t ,
0,
rect.width(),
rect.height()
);
if (destin.right() < 0 || destin.left() >= rect.width())
continue;
m_pScene->render(pImage,destin,source);
}
}
}
......@@ -382,8 +392,9 @@ void qtvplugin_geomarker::refreshMarks()
m_bNeedRefresh = true;
}
void qtvplugin_geomarker::update_line(const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen)
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_line(const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen)
{
QTVP_GEOMARKER::geoItemBase * res = 0;
//Get raw Item by name
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
//Get Props
......@@ -403,7 +414,9 @@ void qtvplugin_geomarker::update_line(const QString & name,double lat1, double l
pitem->setPen(pen);
if (false==this->m_pScene->addItem(pitem,0))
if (base == pitem)
pitem->setGeoLine(lat1,lon1,lat2,lon2);
else if (false==this->m_pScene->addItem(pitem,0))
{
if (base != pitem)
delete pitem;
......@@ -417,11 +430,13 @@ void qtvplugin_geomarker::update_line(const QString & name,double lat1, double l
propNames.pop_front();
propValues.pop_front();
}
res = pitem;
}
return res;
}
void qtvplugin_geomarker::update_region (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush)
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_region (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush)
{
QTVP_GEOMARKER::geoItemBase * res = 0;
//Get raw Item by name
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
//Get Props
......@@ -441,7 +456,9 @@ void qtvplugin_geomarker::update_region (const QString & name,const QPolygonF l
pitem->setPen(pen);
pitem->setBrush(brush);
if (false==this->m_pScene->addItem(pitem,0))
if (base == pitem)
pitem->setGeoPolygon(latlons);
else if (false==this->m_pScene->addItem(pitem,0))
{
if (base != pitem)
delete pitem;
......@@ -455,5 +472,7 @@ void qtvplugin_geomarker::update_region (const QString & name,const QPolygonF l
propNames.pop_front();
propValues.pop_front();
}
res = pitem;
}
return res;
}
......@@ -57,9 +57,9 @@ private:
QString color2string(const QColor & c);
template <class T>
void update_point (const QString & name,double lat, double lon, int width, int height, QPen pen, QBrush brush);
void update_line (const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen);
void update_region (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush);
QTVP_GEOMARKER::geoItemBase * update_point (const QString & name,double lat, double lon, int width, int height, QPen pen, QBrush brush);
QTVP_GEOMARKER::geoItemBase * update_line (const QString & name,double lat1, double lon1,double lat2, double lon2, QPen pen);
QTVP_GEOMARKER::geoItemBase * update_region (const QString & name,const QPolygonF latlons, QPen pen, QBrush brush);
protected:
layer_interface * load_initial_plugin(QString strSLibPath,viewer_interface * ptrviewer);
QWidget * load_prop_window();
......@@ -86,6 +86,7 @@ protected slots:
void on_radioButton_tool_polygon_toggled(bool);
void on_toolButton_selColorPen_clicked();
void on_toolButton_selColorFill_clicked();
void on_toolButton_selColorText_clicked();
void on_tableView_marks_doubleClicked(const QModelIndex & index);
void on_pushButton_prop_update_clicked();
void on_pushButton_prop_delete_clicked();
......@@ -96,8 +97,9 @@ protected slots:
};
template <class T>
void qtvplugin_geomarker::update_point(const QString & name,double lat, double lon, int width, int height, QPen pen, QBrush brush)
QTVP_GEOMARKER::geoItemBase * qtvplugin_geomarker::update_point(const QString & name,double lat, double lon, int width, int height, QPen pen, QBrush brush)
{
QTVP_GEOMARKER::geoItemBase * res = 0;
//Get raw Item by name
QTVP_GEOMARKER::geoItemBase * base = m_pScene->geoitem_by_name(name);
//Get Props
......@@ -118,6 +120,11 @@ void qtvplugin_geomarker::update_point(const QString & name,double lat, double l
pitem->setPen(pen);
pitem->setBrush(brush);
if (base == pitem)
{
pitem->setCenter(lat,lon);
pitem->setSize(width,height);
}
if (false==this->m_pScene->addItem(pitem,0))
{
if (base != pitem)
......@@ -132,8 +139,11 @@ void qtvplugin_geomarker::update_point(const QString & name,double lat, double l
propNames.pop_front();
propValues.pop_front();
}
res = pitem;
}
return res;
}
#endif // QTVPLUGIN_GEOMARKER_H
......
......@@ -6,14 +6,14 @@
<rect>
<x>0</x>
<y>0</y>
<width>612</width>
<height>534</height>
<width>461</width>
<height>497</height>
</rect>
</property>
<property name="windowTitle">
<string>Grid</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
......@@ -162,6 +162,9 @@
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QLabel" name="label_15">
<property name="text">
......@@ -361,7 +364,7 @@
<item>
<widget class="QGroupBox" name="groupBox_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......@@ -441,8 +444,53 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_14">
<property name="text">
<string>Text Color</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_TextColor"/>
</item>
<item>
<widget class="QToolButton" name="toolButton_selColorText">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_25">
<property name="text">
<string>weight</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_textWeight">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>99</number>
</property>
<property name="value">
<number>16</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<item>
<widget class="QLabel" name="label_21">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Fill Style</string>
</property>
......@@ -451,12 +499,32 @@
<item>
<widget class="QComboBox" name="comboBox_fillPad"/>
</item>
<item>
<widget class="QLabel" name="label_23">
<property name="text">
<string>Font Size</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinBox_fontSize">
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>720</number>
</property>
<property name="value">
<number>12</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTableView" name="tableView_props">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
......
......@@ -96,7 +96,14 @@ void qtvplugin_geomarker::on_toolButton_selColorFill_clicked()
if (col.isValid())
ui->lineEdit_FillColor->setText(color2string(col));
}
void qtvplugin_geomarker::on_toolButton_selColorText_clicked()
{
QString str = ui->lineEdit_TextColor->text();
QColor col = QColorDialog::getColor(string2color(str),this,tr("Select Color"),QColorDialog::ShowAlphaChannel|QColorDialog::DontUseNativeDialog);
if (col.isValid())
ui->lineEdit_TextColor->setText(color2string(col));
}
void qtvplugin_geomarker::on_pushButton_pickToLine1_clicked()
{
ui->lineEdit_lineLat1->setText(ui->lineEdit_point_lat->text());
......@@ -134,6 +141,7 @@ void qtvplugin_geomarker::SaveSettingsToIni()
settings.setValue("ui/lineEdit_PenColor",ui->lineEdit_PenColor->text());
settings.setValue("ui/lineEdit_FillColor",ui->lineEdit_FillColor->text());
settings.setValue("ui/lineEdit_TextColor",ui->lineEdit_TextColor->text());
settings.setValue("ui/lineEdit_prop_name",ui->lineEdit_prop_name->text());
settings.setValue("ui/lineEdit_prop_string",ui->lineEdit_prop_string->text());
settings.setValue("ui/lineEdit_lineLat1",ui->lineEdit_lineLat1->text());
......@@ -144,6 +152,10 @@ void qtvplugin_geomarker::SaveSettingsToIni()
settings.setValue("ui/comboBox_linePad",ui->comboBox_linePad->currentIndex());
settings.setValue("ui/comboBox_fillPad",ui->comboBox_fillPad->currentIndex());
settings.setValue("ui/plainTextEdit_corners",ui->plainTextEdit_corners->toPlainText());
settings.setValue("ui/spinBox_textWeight",ui->spinBox_textWeight->value());
settings.setValue("ui/spinBox_fontSize",ui->spinBox_fontSize->value());
}
void qtvplugin_geomarker::loadSettingsFromIni()
......@@ -180,6 +192,8 @@ void qtvplugin_geomarker::loadSettingsFromIni()
ui->lineEdit_PenColor->setText(lineEdit_PenColor);
QString lineEdit_FillColor = settings.value("ui/lineEdit_FillColor",color2string(QColor(255,255,255,128))).toString();
ui->lineEdit_FillColor->setText(lineEdit_FillColor);
QString lineEdit_TextColor = settings.value("ui/lineEdit_TextColor",color2string(QColor(0,0,0))).toString();
ui->lineEdit_TextColor->setText(lineEdit_TextColor);
int radioButton_PointRect = settings.value("ui/radioButton_PointRect",0).toInt();
switch (radioButton_PointRect)
{
......@@ -216,6 +230,11 @@ void qtvplugin_geomarker::loadSettingsFromIni()
QString plainTextEdit_corners = settings.value("ui/plainTextEdit_corners","0").toString();
ui->plainTextEdit_corners->setPlainText(plainTextEdit_corners);
int spinBox_fontSize = settings.value("ui/spinBox_fontSize",9).toInt();
ui->spinBox_fontSize->setValue(spinBox_fontSize);
int spinBox_textWeight = settings.value("ui/spinBox_textWeight",16).toInt();
ui->spinBox_textWeight->setValue(spinBox_textWeight);
}
void qtvplugin_geomarker::on_pushButton_update_clicked()
{
......@@ -271,6 +290,8 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
brush.setColor(brushColor);
brush.setStyle(bst[btdd]);
QTVP_GEOMARKER::geoItemBase * newitem = 0;
if (ui->radioButton_tool_point->isChecked())
{
double lat = ui->lineEdit_point_lat->text().toDouble();
......@@ -279,9 +300,9 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
int width = ui->spinBox_point_width->value();
int height = ui->spinBox_point_size_height->value();
if (tp==0)
update_point<QTVP_GEOMARKER::geoGraphicsRectItem>(name,lat,lon,width,height,pen,brush);
newitem = update_point<QTVP_GEOMARKER::geoGraphicsRectItem>(name,lat,lon,width,height,pen,brush);
else
update_point<QTVP_GEOMARKER::geoGraphicsEllipseItem>(name,lat,lon,width,height,pen,brush);
newitem = update_point<QTVP_GEOMARKER::geoGraphicsEllipseItem>(name,lat,lon,width,height,pen,brush);
}
else if (ui->radioButton_tool_line->isChecked())
{
......@@ -289,7 +310,7 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
double lat2 = ui->lineEdit_lineLat2->text().toDouble();
double lon1 = ui->lineEdit_lineLon1->text().toDouble();
double lon2 = ui->lineEdit_lineLon2->text().toDouble();
update_line(name,lat1,lon1,lat2,lon2,pen);
newitem = update_line(name,lat1,lon1,lat2,lon2,pen);
}
else if (ui->radioButton_tool_polygon->isChecked())
{
......@@ -313,12 +334,26 @@ void qtvplugin_geomarker::on_pushButton_update_clicked()
latlons.push_back(ll);
}
if (latlons.size())
update_region(name,latlons,pen,brush);
newitem = update_region(name,latlons,pen,brush);
}
else
return;
if (newitem)
{
int fontSz = ui->spinBox_fontSize->value();
int fontWeight = ui->spinBox_textWeight->value();
QColor textColor = string2color( ui->lineEdit_TextColor->text());
QFont f = newitem->labelFont();
f.setPointSize(fontSz);
f.setWeight(fontWeight);
newitem->setLabelFont(f);
newitem->setLabelColor(textColor);
}
refreshMarks();
m_pVi->UpdateWindow();
}
void qtvplugin_geomarker::on_pushButton_del_clicked()
......@@ -432,6 +467,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
ui->radioButton_PointRect->setChecked(true);
ui->spinBox_point_width->setValue(pitem->width());
ui->spinBox_point_size_height->setValue(pitem->height());
ui->radioButton_tool_point->setChecked(true);
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_ELLIPSE_POINT:
......@@ -446,6 +482,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
ui->radioButton_PointRound->setChecked(true);
ui->spinBox_point_width->setValue(pitem->width());
ui->spinBox_point_size_height->setValue(pitem->height());
ui->radioButton_tool_point->setChecked(true);
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_LINE:
......@@ -458,6 +495,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
ui->lineEdit_lineLat2->setText(QString("%1").arg(pitem->lat2(),0,'f',14));
ui->lineEdit_lineLon1->setText(QString("%1").arg(pitem->lon1(),0,'f',14));
ui->lineEdit_lineLon2->setText(QString("%1").arg(pitem->lon2(),0,'f',14));
ui->radioButton_tool_line->setChecked(true);
}
break;
case QTVP_GEOMARKER::ITEAMTYPE_REGION:
......@@ -472,6 +510,7 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
foreach (QPointF p, pol)
strPlainText += QString("%1,%2\n").arg(p.y(),0,'f',14).arg(p.x(),0,'f',14);
ui->plainTextEdit_corners->setPlainText(strPlainText);
ui->radioButton_tool_polygon->setChecked(true);
}
break;
default:
......@@ -493,6 +532,16 @@ void qtvplugin_geomarker::refreshItemUI(QString markname)
int nbs = int(bs);
if (nbs >=0 && nbs < ui->comboBox_fillPad->count())
ui->comboBox_fillPad->setCurrentIndex((int)nbs);
QColor colorText = item->labelColor();
ui->lineEdit_TextColor->setText(color2string(colorText));
int fsize = item->labelFont().pointSize();
ui->spinBox_fontSize->setValue(fsize);
int weight = item->labelFont().weight();
ui->spinBox_textWeight->setValue(weight);
refreshProps(item);
}//end if item
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册