Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
colorEagleStdio
qplanetosm
提交
549d058b
qplanetosm
项目概览
colorEagleStdio
/
qplanetosm
通知
120
Star
10
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
qplanetosm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
549d058b
编写于
1月 08, 2016
作者:
丁劲犇
😸
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add comments
上级
f01a84d2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
71 addition
and
22 deletion
+71
-22
qtvplugin_geomarker/qtvplugin_geomarker.cpp
qtvplugin_geomarker/qtvplugin_geomarker.cpp
+71
-22
未找到文件。
qtvplugin_geomarker/qtvplugin_geomarker.cpp
浏览文件 @
549d058b
...
...
@@ -84,24 +84,39 @@ void qtvplugin_geomarker::load_retranslate_UI()
{
ui
->
retranslateUi
(
this
);
}
/*! load_initial_plugin will be called when this plug in being loaded.
* Please notice that a global parament "map_instances" is introduced, for multi-instance situation
* in windows OCX usage. A Brave new instance of "qtvplugin_geomarker" will be created for each different viewer_interface.
*
* @param strSLibPath the absolute path of this dll.
* @param ptrviewer the pointer to main view.
* @return return the instance pointer to the instance belong to ptrviewer
*/
layer_interface
*
qtvplugin_geomarker
::
load_initial_plugin
(
QString
strSLibPath
,
viewer_interface
*
ptrviewer
)
{
//!In this instance, we will see how to create a new instance for each ptrviewer
qtvplugin_geomarker
*
instance
=
0
;
//!1.Check whether there is already a instance for ptrviewer( viewer_interface)
mutex_instances
.
lock
();
//!1.1 situation 1: map_instances is empty, which means no instance exists. We just save this pointer to map_instances
if
(
map_instances
.
empty
()
==
true
)
{
map_instances
[
ptrviewer
]
=
this
;
instance
=
this
;
}
/*! 1.2 situation 2: map_instances dose not contain ptrviewer, which is the normal situation when a second ocx ctrl is initializing.
* we just allocate a new qtvplugin_geomarker, and save key-value in map_instances.
*/
else
if
(
map_instances
.
contains
(
ptrviewer
)
==
false
)
{
instance
=
new
qtvplugin_geomarker
;
map_instances
[
ptrviewer
]
=
instance
;
}
//! 1.3 situation 3: a ABNORMAL situation. load_initial_plugin is called again.
else
instance
=
map_instances
[
ptrviewer
];
mutex_instances
.
unlock
();
//2. if the instance is just this object, we do real init code.
if
(
instance
==
this
)
{
QFileInfo
info
(
strSLibPath
);
...
...
@@ -116,6 +131,7 @@ layer_interface * qtvplugin_geomarker::load_initial_plugin(QString strSLibPath,v
loadTranslations
();
loadSettingsFromIni
();
}
//3. elseif, we call the instance's load_initial_plugin method instead
else
{
layer_interface
*
ret
=
instance
->
load_initial_plugin
(
strSLibPath
,
ptrviewer
);
...
...
@@ -125,6 +141,7 @@ layer_interface * qtvplugin_geomarker::load_initial_plugin(QString strSLibPath,v
qDebug
()
<<
QFont
::
substitutions
();
return
instance
;
}
void
qtvplugin_geomarker
::
loadTranslations
()
{
//Trans
...
...
@@ -163,7 +180,16 @@ void qtvplugin_geomarker::cb_paintEvent( QPainter * pImage )
m_pVi
->
CV_DP2World
(
rect
.
width
()
-
1
,
rect
.
height
()
-
1
,
&
rightcenx
,
&
bottomceny
);
int
winsz
=
256
*
(
1
<<
m_pVi
->
level
());
//Warpping 180, -180
QRectF
destin
(
0
,
0
,
rect
.
width
(),
rect
.
height
()
);
//Warpping 180, -180. because longitude +180 and -180 is the same point,
// but the map is plat, -180 and + 180 is quite different positions, we
// should draw 3 times, to slove cross 180 drawing problems.
for
(
int
p
=
-
1
;
p
<=
1
;
++
p
)
{
QRectF
source
(
...
...
@@ -172,24 +198,9 @@ void qtvplugin_geomarker::cb_paintEvent( QPainter * pImage )
(
rightcenx
-
leftcenx
),
(
bottomceny
-
topceny
)
);
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
);
}
m_pScene
->
render
(
pImage
,
destin
,
source
);
}
}
...
...
@@ -236,6 +247,15 @@ bool qtvplugin_geomarker::cb_event(const QMap<QString, QVariant> para)
return
false
;
}
/*! qtvplugin_geomarker::cb_mouseXXXEvent tranfer mouse events from main view to
* QGraphicsItem based classes, so that these items will recieve mouse events.
* For qt's graphics-view framework, this approach is done inside QGraphicsView class.
* however, our main view is a simple widget, which means mouse events should be dealed manually.
*
* @fn qtvplugin_geomarker::cb_mouseDoubleClickEvent(QMouseEvent * e)
* @param e the mouse event.
* @return bool event acception.
*/
bool
qtvplugin_geomarker
::
cb_mouseDoubleClickEvent
(
QMouseEvent
*
e
)
{
if
(
!
m_pVi
)
...
...
@@ -279,7 +299,15 @@ bool qtvplugin_geomarker::cb_mouseDoubleClickEvent(QMouseEvent * e)
}
return
false
;
}
/*! qtvplugin_geomarker::cb_mouseXXXEvent tranfer mouse events from main view to
* QGraphicsItem based classes, so that these items will recieve mouse events.
* For qt's graphics-view framework, this approach is done inside QGraphicsView class.
* however, our main view is a simple widget, which means mouse events should be dealed manually.
*
* @fn qtvplugin_geomarker::cb_mousePressEvent(QMouseEvent * e)
* @param e the mouse event.
* @return bool event acception.
*/
bool
qtvplugin_geomarker
::
cb_mousePressEvent
(
QMouseEvent
*
e
)
{
if
(
!
m_pVi
)
...
...
@@ -321,7 +349,15 @@ bool qtvplugin_geomarker::cb_mousePressEvent(QMouseEvent * e)
return
false
;
}
/*! for convenience, color is stored in plain text in XML and UI.
* the plain text color is 5 sub value , which stands for r,g,b,alpha.
* the fifth value is a integer, equals to
* (col.alpha()<<24) +(col.blue()<<16) + (col.green()<<8) + (col.red());
*
* @fn qtvplugin_geomarker::string2color(const QString & s)
* @param s the string color.
* @return QColor is the color object.
*/
QColor
qtvplugin_geomarker
::
string2color
(
const
QString
&
s
)
{
QStringList
lst
=
s
.
split
(
","
,
QString
::
SkipEmptyParts
);
...
...
@@ -332,6 +368,15 @@ QColor qtvplugin_geomarker::string2color(const QString & s)
if
(
lst
.
empty
()
==
false
)
{
a
=
lst
.
first
().
toInt
();
lst
.
pop_front
();}
return
QColor
(
r
,
g
,
b
,
a
);
}
/*! for convenience, color is stored in plain text in XML and UI.
* the plain text color is 5 sub value , which stands for r,g,b,alpha.
* the fifth value is a integer, equals to
* (col.alpha()<<24) +(col.blue()<<16) + (col.green()<<8) + (col.red());
*
* @fn qtvplugin_geomarker::color2string(const QColor & col)
* @param col the color object.
* @return QString is the color string.
*/
QString
qtvplugin_geomarker
::
color2string
(
const
QColor
&
col
)
{
quint32
cv
=
(
col
.
alpha
()
<<
24
)
+
(
col
.
blue
()
<<
16
)
+
(
col
.
green
()
<<
8
)
+
(
col
.
red
());
...
...
@@ -346,10 +391,14 @@ QString qtvplugin_geomarker::inifile()
else
return
QCoreApplication
::
applicationFilePath
()
+
QString
(
"/geomarker%1.ini"
).
arg
(
m_nInstance
);
}
void
qtvplugin_geomarker
::
refreshMarks
()
{
if
(
!
m_pVi
||
!
m_pScene
)
return
;
//We do not refresh UI immediately after each mark-insert, for these inserts is very dense ,
//BAD performence will arise if so.
//We will set a flag and refresh the ui in timerEvent Instead.
m_bNeedRefresh
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录