giu icon indicating copy to clipboard operation
giu copied to clipboard

How to disable AntiAliasedLines with giu/golang

Open francmarx opened this issue 3 years ago • 2 comments

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 avatar Dec 16 '22 14:12 francmarx

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

gucio321 avatar May 09 '23 15:05 gucio321

@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

francmarx avatar May 09 '23 20:05 francmarx

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.

gucio321 avatar Feb 18 '24 20:02 gucio321

@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?

francmarx avatar Feb 19 '24 07:02 francmarx

Giu's master branch already used cimgui-go.

gucio321 avatar Feb 19 '24 08:02 gucio321

@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?

francmarx avatar Feb 19 '24 14:02 francmarx

@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 avatar Feb 19 '24 16:02 gucio321

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

gucio321 avatar Feb 19 '24 16:02 gucio321

@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

francmarx avatar Feb 20 '24 08:02 francmarx

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...

gucio321 avatar Feb 20 '24 13:02 gucio321

@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 avatar Feb 20 '24 14:02 francmarx

@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?

francmarx avatar Feb 21 '24 08:02 francmarx

I've never tought about this tbh :smile:

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 avatar Feb 21 '24 08:02 gucio321

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

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

LMK if iyou find something more

gucio321 avatar Feb 21 '24 09:02 gucio321

@gucio321

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

works :) thanks

francmarx avatar Feb 21 '24 09:02 francmarx

@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)
)

francmarx avatar Feb 21 '24 13:02 francmarx

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

gucio321 avatar Feb 21 '24 16:02 gucio321

@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

francmarx avatar Feb 21 '24 19:02 francmarx

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

gucio321 avatar Feb 21 '24 20:02 gucio321