Navigation Cube corners too small

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Navigation Cube corners too small

Post by Jolbas »

I have used the Navigation Cube and I think the triangular corners are unnecessary small and hard to click and I thought shaping them as hexagons would make them more equal in size to the chamfered edges.
hexagon_corners.jpg
hexagon_corners.jpg (17.56 KiB) Viewed 2459 times
I started to investigate the code even though I don't have the tools to build and test. I think that it should be enough to change the following in src/Gui/NaviCube.cpp to change the corners

In function initNaviCube()
Change row 769 to:

Code: Select all

z *= sqrt(2) * (1 - gap);
(That change isn't necessary but it should simplify changing the relative size of the edges and corners defined on row 672)

Change row 736 to:

Code: Select all

z *= sqrt(3) * (1 - 2 * gap);
and the big change would be in function createCubeFaceTex()
Replace row 379-404 with

Code: Select all

	else if (shape == SHAPE_SQUARE) {
		QPainterPath pathSquare;
		pathSquare.moveTo(gapi * 2.0,                  gapi);
		pathSquare.lineTo((qreal)texSize - gapi * 2.0, gapi);
		pathSquare.lineTo((qreal)texSize - gapi,       gapi * 2.0);
		pathSquare.lineTo((qreal)texSize - gapi,       (qreal)texSize - gapi * 2.0);
		pathSquare.lineTo((qreal)texSize - gapi * 2.0, (qreal)texSize - gapi);
		pathSquare.lineTo(gapi * 2.0,                  (qreal)texSize - gapi);
		pathSquare.lineTo(gapi,                        (qreal)texSize - gapi * 2.0);
		pathSquare.lineTo(gapi,                        gapi * 2.0);
		pathSquare.lineTo(gapi * 2.0,                  gapi);
		paint.fillPath(pathSquare, Qt::white);
		paint.setPen(pen);
		paint.drawPath(pathSquare);
	}
	else if (shape == SHAPE_CORNER) {
		QPainterPath pathCorner;
		float cornerHalfW = sqrt(2) * gapi;
		float cornerHalfH = sqrt(1.5) * gapi;
		float cornerCenter = (qreal)texSize / 2.0
		pathCorner.moveTo(cornerCenter - cornerHalfW, cornerCenter);
		pathCorner.lineTo(cornerCenter - cornerHalfW / 2.0, cornerCenter - cornerHalfH);
		pathCorner.lineTo(cornerCenter + cornerHalfW / 2.0, cornerCenter - cornerHalfH);
		pathCorner.lineTo(cornerCenter + cornerHalfW, cornerCenter);
		pathCorner.lineTo(cornerCenter + cornerHalfW / 2.0, cornerCenter + cornerHalfH);
		pathCorner.lineTo(cornerCenter - cornerHalfW / 2.0, cornerCenter + cornerHalfH);
		pathCorner.lineTo(cornerCenter - cornerHalfW, cornerCenter);
		paint.fillPath(pathCorner, Qt::white);
		paint.setPen(pen);
		paint.drawPath(pathCorner);
	}
	else if (shape == SHAPE_EDGE) {
		QPainterPath pathEdge;
		pathEdge.addRect(QRectF(2 * gapi, 0.5 * (qreal)texSize - sqrt(2) * gapi), (qreal)texSize - 4.0 * gapi, sqrt(2) * gapi));
		paint.fillPath(pathEdge, Qt::white);
		paint.setPen(pen);
		paint.drawPath(pathEdge);
	}
This code is as said not tested and I'm not sure it is enough to make it work but I have a little hope it will.

If you don't like hexagonal corners then maybe some changes should be done anyway because it seems createCubeFaceTex() doesn't respect it's "gap" argument. "3.46 * gapi" should be replaced with "(qreal)texSize - sqrt(2) * gapi" and "3.31 * gapi" should be replaced with "(qreal)texSize - gapi". Also z in row 736 and 769 would better be calculated from "gap" similar to my suggested changes above.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Navigation Cube corners too small

Post by Kunda1 »

Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Re: Navigation Cube corners too small

Post by Jolbas »

It's related but the corners isn't significantly bigger and createCubeFaceTex() isn't changed to respect its gap argument.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Navigation Cube corners too small

Post by adrianinsaval »

hexagon corners do look better
User avatar
obelisk79
Veteran
Posts: 1061
Joined: Thu Sep 24, 2020 9:01 pm

Re: Navigation Cube corners too small

Post by obelisk79 »

If realthunders NaviCube refactor PR gets merged, the corners will be circles instead of any sort of polygon. Not sure which would be considered more desirable since it probably has more to do with overall aesthetic and personal preference rather than any functional or performance concerns.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Navigation Cube corners too small

Post by adrianinsaval »

yeah at that point it's just about looks, I prefer the hexagons over the circles but I can live without them
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Navigation Cube corners too small

Post by adrianinsaval »

@Jolbas could you take a look at the current code and prepare a PR with the hexagon? In a recent PR some changes to the navicube were merged and it was mentioned that the corners are done using textures instead of being drawn with vertex and lines like the other faces, is your proposal using textures too or is it actually drawing a hexagon in coin?
User avatar
Jolbas
Posts: 327
Joined: Sat Mar 26, 2022 7:48 am
Location: Sweden

Re: Navigation Cube corners too small

Post by Jolbas »

@adrianinsaval I would love to do that but that will take some time (weeks). I just started to try compiling FreeCAD. And I have no experience from building C++ applications or using Git.
User avatar
adrianinsaval
Veteran
Posts: 5541
Joined: Thu Apr 05, 2018 5:15 pm

Re: Navigation Cube corners too small

Post by adrianinsaval »

I created an issue for this request issue #7875
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Navigation Cube corners too small

Post by Kunda1 »

Awesome collaboration on this fix. Thanks y'all!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
Post Reply