Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable AntiAliasedLines with giu/golang #632

Closed
francmarx opened this issue Dec 16, 2022 · 19 comments
Closed

How to disable AntiAliasedLines with giu/golang #632

francmarx opened this issue Dec 16, 2022 · 19 comments
Labels
bug Something isn't working

Comments

@francmarx
Copy link

What happend?

in imgui_demo.cpp in line 6208 I can find:
ImGui::Checkbox("Anti-aliased lines", &style.AntiAliasedLines);
to enable/disable AntiAliasedLines.

Can't find a wrapper for this.

How this can be done with giu/golang ?
How to read/write the style structure?

Code example

To Reproduce

Version

master

OS

linux

@francmarx francmarx added the bug Something isn't working label Dec 16, 2022
@gucio321
Copy link
Collaborator

gucio321 commented May 9, 2023

@francmarx do you mean the Plot flag?
if so, there is a flag for giu.Plot().Flags(giu.PlotFlagsAntiAliased)

@francmarx
Copy link
Author

@gucio321 I know "giu.Plot().Flags(giu.PlotFlagsAntiAliased)", but it doesn't solve my problem:
I want to draw lines WITHOUT anti-aliasing. I can only switch on anti-aliasing with that flag.

It seems that anti-aliasing is alwasy on, I can't switch it off. So I am looking for some global settings like "style.AntiAliasedLines" in imgui_demo.cpp

@gucio321
Copy link
Collaborator

In cimgui there is

func (self Style) SetAntiAliasedLines(v bool) {
        selfArg, selfFin := self.handle()
        defer selfFin()
        C.wrap_ImGuiStyle_SetAntiAliasedLines(selfArg, C.bool(v))
}

so imgui.CurrentStyle().SetAntiAliasedLines(false) should work on master.

@francmarx
Copy link
Author

@gucio321 Should I switch from imgui-go to cimgui-go ? cimgui-go has no official release yet.
How can the change to cimgui-go be made easily?

@gucio321
Copy link
Collaborator

Giu's master branch already used cimgui-go.

@francmarx
Copy link
Author

@gucio321 running giu with cimgui-go form master branch I managed to compile,
but many things from implot I have to comment out:

  • how to make plots with second and third y-axis on right side?
  • how to use these plot styles:
    imgui.ImPlotUse24HourClock(true)
    imgui.ImPlotUseISO8601(true)
    imgui.ImPlotUseLocalTime(true)

is there an example to use implot with new cimgui-go package?

@gucio321
Copy link
Collaborator

@francmarx thats a good question.
After a look at cimgui-go api I think this should be something like this: imgui.PlotGetStyle().SetUseLocalTime(true).
You should find most of these methods either here https://pkg.go.dev/github.com/AllenDang/cimgui-go or by searching cimplot_funcs.go

in case of 2nd and 3rd axis: whats the code? I think you may find appropiate functions too.

@gucio321
Copy link
Collaborator

I've added a link to the documentation in cimgui-go repo

@francmarx
Copy link
Author

@gucio321

"2nd and 3rd axis":

old code was:

giu.Plot("Rotation").Flags(giu.PlotFlagsYAxis2).Plots( .... )

now it doesn't work because PlotFlagsYAxis2 doesn't exist, in flags.go it is commented out:

const (
	PlotFlagsNone        = PlotFlags(imgui.PlotFlagsNone)
	PlotFlagsNoTitle     = PlotFlags(imgui.PlotFlagsNoTitle)
	PlotFlagsNoLegend    = PlotFlags(imgui.PlotFlagsNoLegend)
	PlotFlagsNoMenus     = PlotFlags(imgui.PlotFlagsNoMenus)
	PlotFlagsNoBoxSelect = PlotFlags(imgui.PlotFlagsNoBoxSelect)
	// 	PlotFlagsNoMousePos  = PlotFlags(imgui.PlotFlagsNoMousePos)
	// 	PlotFlagsNoHighlight = PlotFlags(imgui.PlotFlagsNoHighlight)
	// PlotFlagsNoChild = PlotFlags(imgui.PlotFlagsNoChild).
	PlotFlagsEqual = PlotFlags(imgui.PlotFlagsEqual)
	// 	PlotFlagsYAxis2      = PlotFlags(imgui.PlotFlagsYAxis2)
	// 	PlotFlagsYAxis3      = PlotFlags(imgui.PlotFlagsYAxis3)
	// 	PlotFlagsQuery       = PlotFlags(imgui.PlotFlagsQuery)
	PlotFlagsCrosshairs = PlotFlags(imgui.PlotFlagsCrosshairs)
	// 	PlotFlagsAntiAliased = PlotFlags(imgui.PlotFlagsAntiAliased)
	PlotFlagsCanvasOnly = PlotFlags(imgui.PlotFlagsCanvasOnly)
)

I have no idea how to activate second/third axis

@gucio321
Copy link
Collaborator

from cimplot_enums.go:

// original name: ImAxis_
type PlotAxisEnum int32

const (
        AxisX1    = 0
        AxisX2    = 1
        AxisX3    = 2
        AxisY1    = 3
        AxisY2    = 4
        AxisY3    = 5
        AxisCOUNT = 6
)

in giu, well, now I see there is something strange done there...

@francmarx
Copy link
Author

@gucio321 another problem:

when entering '2' key from numpad to gui.InputFloat(...) I got an error "panic: Unknown key: 322" at line 204 from Keycode.go

normal '2' from main-keyboard works

(is it possible to communicate via some messenger ??)

@francmarx
Copy link
Author

@gucio321 numkeys work now, thanks :)

checking the framerate I found a difference between imgui-go and cimgui-go:
with imgui I have 60 fps, but with cimgui only 30fps
I checked it with several apps

Do I have to make certain changes to the main loop or certain settings?

@gucio321
Copy link
Collaborator

I've never tought about this tbh 😄

from glfw_backend.cpp:

unsigned int glfw_target_fps = 30;
//...
void igSetTargetFPS(unsigned int fps) { glfw_target_fps = fps; }

from glfw_backend.go:

func (b *GLFWBackend) SetTargetFPS(fps uint) {
        C.igSetTargetFPS(C.uint(fps))
}

So you can set it in cimgui-go

In giu we probably need to add something.

@gucio321
Copy link
Collaborator

gucio321 commented Feb 21, 2024

@francmarx (*MasterWindow).SetTargetFPS(60) should help

btw, thank you for pointing out these bugs - it makes giu still better and better 😄

LMK if iyou find something more

@francmarx
Copy link
Author

@gucio321

w := g.NewMasterWindow(....)
w.SetTargetFPS(60)

works :) thanks

@francmarx
Copy link
Author

@gucio321

PlotAxisFlagsTime doesn't work, it is commented out, Flags.go line 503

// plot axis flags.
const (
	PlotAxisFlagsNone         PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNone)
	PlotAxisFlagsNoLabel      PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoLabel)
	PlotAxisFlagsNoGridLines  PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoGridLines)
	PlotAxisFlagsNoTickMarks  PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoTickMarks)
	PlotAxisFlagsNoTickLabels PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoTickLabels)
	PlotAxisFlagsForeground   PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsForeground)
	//	PlotAxisFlagsLogScale      PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLogScale)
	//	PlotAxisFlagsTime          PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsTime)
	PlotAxisFlagsInvert        PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsInvert)
	PlotAxisFlagsNoInitialFit  PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoInitialFit)
	PlotAxisFlagsAutoFit       PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsAutoFit)
	PlotAxisFlagsRangeFit      PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsRangeFit)
	PlotAxisFlagsLockMin       PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLockMin)
	PlotAxisFlagsLockMax       PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLockMax)
	PlotAxisFlagsLock          PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsLock)
	PlotAxisFlagsNoDecorations PlotAxisFlags = PlotAxisFlags(imgui.PlotAxisFlagsNoDecorations)
)

@gucio321
Copy link
Collaborator

@francmarx yes, because there is no such a flag in implot. What should it do?
The only thing I found about "time" is PlotScaleTime.

@francmarx
Copy link
Author

francmarx commented Feb 21, 2024

@gucio321 old code was:

g.Plot("header").
   XAxeFlags(g.PlotAxisFlagsTime).
   YAxeFlags(g.PlotAxisFlagsNoLabel,g.PlotAxisFlagsNoLabel,g.PlotAxisFlagsNoLabel).
   Plots(...),

it switches to time scale for x-axis, looks like this:

image

@gucio321
Copy link
Collaborator

ok so we need to implement Scale setting, thank you ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants