Skip to content
GitLab
探索
项目
群组
代码片段
项目
群组
代码片段
/
帮助
帮助
支持
社区论坛
快捷键
?
提交反馈
登录
切换导航
菜单
打开侧边栏
ExternalRepo
implot
提交
50f4e948
提交
50f4e948
编辑于
5年前
作者:
Evan Pezent
浏览文件
操作
下载
电子邮件补丁
差异文件
add ozlb's legend highlighting
上级
d372e1a1
master
backends
features/buffer
features/legend-scroll
features/neg-time
features/prevplot
features/spec
features/tooltips
v0.16
v0.15
v0.14
v0.13
v0.12
v0.11
v0.10
v0.9
v0.8
v0.7
v0.6
v0.5
v0.4
v0.3
v0.2
v0.1
无相关合并请求
变更
2
Hide whitespace changes
Inline
Side-by-side
显示
2 个更改的文件
implot.cpp
+26
-5
implot.cpp
implot.h
+7
-6
implot.h
有
33 个添加
和
11 个删除
+33
-11
implot.cpp
+
26
-
5
浏览文件 @
50f4e948
...
...
@@ -192,6 +192,7 @@ struct ImPlotItem {
ImPlotItem
();
~
ImPlotItem
()
{
ID
=
0
;
}
bool
Show
;
bool
Highlight
;
ImVec4
Color
;
int
NameOffset
;
bool
Active
;
...
...
@@ -402,7 +403,14 @@ struct ImPlotContext {
/// Global plot context
static
ImPlotContext
gp
;
ImPlotItem
::
ImPlotItem
()
{
Show
=
true
;
Color
=
gp
.
NextColor
();
NameOffset
=
-
1
;
Active
=
true
;
ID
=
0
;
}
ImPlotItem
::
ImPlotItem
()
{
Show
=
true
;
Highlight
=
false
;
Color
=
gp
.
NextColor
();
NameOffset
=
-
1
;
Active
=
true
;
ID
=
0
;
}
//=============================================================================
// Tick Utils
...
...
@@ -1034,6 +1042,16 @@ void EndPlot() {
ImRect
icon_bb
;
icon_bb
.
Min
=
legend_content_bb
.
Min
+
legend_padding
+
ImVec2
(
0
,
i
*
txt_ht
)
+
ImVec2
(
2
,
2
);
icon_bb
.
Max
=
legend_content_bb
.
Min
+
legend_padding
+
ImVec2
(
0
,
i
*
txt_ht
)
+
ImVec2
(
legend_icon_size
-
2
,
legend_icon_size
-
2
);
ImRect
label_bb
;
label_bb
.
Min
=
legend_content_bb
.
Min
+
legend_padding
+
ImVec2
(
0
,
i
*
txt_ht
)
+
ImVec2
(
2
,
2
);
label_bb
.
Max
=
legend_content_bb
.
Min
+
legend_padding
+
ImVec2
(
0
,
i
*
txt_ht
)
+
ImVec2
(
legend_content_bb
.
Max
.
x
,
legend_icon_size
-
2
);
ImU32
col_hl_txt
;
if
(
HasFlag
(
plot
.
Flags
,
ImPlotFlags_Highlight
)
&&
hov_legend
&&
(
icon_bb
.
Contains
(
IO
.
MousePos
)
||
label_bb
.
Contains
(
IO
.
MousePos
)))
{
item
->
Highlight
=
true
;
col_hl_txt
=
GetColorU32
(
ImLerp
(
G
.
Style
.
Colors
[
ImGuiCol_Text
],
item
->
Color
,
0.25
f
));
}
else
item
->
Highlight
=
false
;
ImU32
iconColor
;
if
(
hov_legend
&&
icon_bb
.
Contains
(
IO
.
MousePos
))
{
auto
colAlpha
=
item
->
Color
;
...
...
@@ -1049,7 +1067,8 @@ void EndPlot() {
const
char
*
label
=
gp
.
GetLegendLabel
(
i
);
const
char
*
text_display_end
=
FindRenderedTextEnd
(
label
,
NULL
);
if
(
label
!=
text_display_end
)
DrawList
.
AddText
(
legend_content_bb
.
Min
+
legend_padding
+
ImVec2
(
legend_icon_size
,
i
*
txt_ht
),
item
->
Show
?
gp
.
Col_Txt
:
gp
.
Col_TxtDis
,
label
,
text_display_end
);
DrawList
.
AddText
(
legend_content_bb
.
Min
+
legend_padding
+
ImVec2
(
legend_icon_size
,
i
*
txt_ht
),
item
->
Show
?
(
item
->
Highlight
?
col_hl_txt
:
gp
.
Col_Txt
)
:
gp
.
Col_TxtDis
,
label
,
text_display_end
);
}
}
...
...
@@ -1541,6 +1560,8 @@ void Plot(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* dat
ImGui
::
PushClipRect
(
gp
.
BB_Grid
.
Min
,
gp
.
BB_Grid
.
Max
,
true
);
bool
cull
=
HasFlag
(
gp
.
CurrentPlot
->
Flags
,
ImPlotFlags_CullData
);
const
float
line_weight
=
item
->
Highlight
?
gp
.
Style
.
LineWeight
*
2
:
gp
.
Style
.
LineWeight
;
// render line segments
if
(
count
>
1
&&
rend_line
)
{
const
int
segments
=
count
-
1
;
...
...
@@ -1553,7 +1574,7 @@ void Plot(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* dat
p2
=
gp
.
ToPixels
(
getter
(
data
,
i2
));
i1
=
i2
;
if
(
!
cull
||
gp
.
BB_Grid
.
Contains
(
p1
)
||
gp
.
BB_Grid
.
Contains
(
p2
))
DrawList
.
AddLine
(
p1
,
p2
,
col_line
,
gp
.
Style
.
L
ine
W
eight
);
DrawList
.
AddLine
(
p1
,
p2
,
col_line
,
l
ine
_w
eight
);
}
}
else
{
...
...
@@ -1571,8 +1592,8 @@ void Plot(const char* label_id, ImVec2 (*getter)(void* data, int idx), void* dat
float
dx
=
p2
.
x
-
p1
.
x
;
float
dy
=
p2
.
y
-
p1
.
y
;
IM_NORMALIZE2F_OVER_ZERO
(
dx
,
dy
);
dx
*=
(
gp
.
Style
.
L
ine
W
eight
*
0.5
f
);
dy
*=
(
gp
.
Style
.
L
ine
W
eight
*
0.5
f
);
dx
*=
(
l
ine
_w
eight
*
0.5
f
);
dy
*=
(
l
ine
_w
eight
*
0.5
f
);
DrawList
.
_VtxWritePtr
[
0
].
pos
.
x
=
p1
.
x
+
dy
;
DrawList
.
_VtxWritePtr
[
0
].
pos
.
y
=
p1
.
y
-
dx
;
DrawList
.
_VtxWritePtr
[
0
].
uv
=
uv
;
...
...
This diff is collapsed.
Click to expand it.
implot.h
+
7
-
6
浏览文件 @
50f4e948
...
...
@@ -39,12 +39,13 @@ typedef int ImMarker;
enum
ImPlotFlags_
{
ImPlotFlags_MousePos
=
1
<<
0
,
// the mouse position, in plot coordinates, will be displayed in the bottom-right
ImPlotFlags_Legend
=
1
<<
1
,
// a legend will be displayed in the top-left
ImPlotFlags_Selection
=
1
<<
2
,
// the user will be able to box-select with right-mouse
ImPlotFlags_ContextMenu
=
1
<<
3
,
// the user will be able to open a context menu with double-right click
ImPlotFlags_Crosshairs
=
1
<<
4
,
// the default mouse cursor will be replaced with a crosshair when hovered
ImPlotFlags_CullData
=
1
<<
5
,
// plot data outside the plot area will be culled from rendering
ImPlotFlags_AntiAliased
=
1
<<
6
,
// lines and fills will be anti-aliased (not recommended)
ImPlotFlags_Default
=
ImPlotFlags_MousePos
|
ImPlotFlags_Legend
|
ImPlotFlags_Selection
|
ImPlotFlags_ContextMenu
|
ImPlotFlags_CullData
ImPlotFlags_Highlight
=
1
<<
2
,
// plot items will be highlighted when their legend entry is hovered
ImPlotFlags_Selection
=
1
<<
3
,
// the user will be able to box-select with right-mouse
ImPlotFlags_ContextMenu
=
1
<<
4
,
// the user will be able to open a context menu with double-right click
ImPlotFlags_Crosshairs
=
1
<<
5
,
// the default mouse cursor will be replaced with a crosshair when hovered
ImPlotFlags_CullData
=
1
<<
6
,
// plot data outside the plot area will be culled from rendering
ImPlotFlags_AntiAliased
=
1
<<
7
,
// lines and fills will be anti-aliased (not recommended)
ImPlotFlags_Default
=
ImPlotFlags_MousePos
|
ImPlotFlags_Legend
|
ImPlotFlags_Highlight
|
ImPlotFlags_Selection
|
ImPlotFlags_ContextMenu
|
ImPlotFlags_CullData
};
// Options for plot axes (X and Y)
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
支持
Markdown
0%
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
菜单
探索
项目
群组
代码片段