Skip to content

Stud logo preference#101

Open
trevorsandy wants to merge 21 commits intotcobbs:masterfrom
trevorsandy:STUD_LOGO
Open

Stud logo preference#101
trevorsandy wants to merge 21 commits intotcobbs:masterfrom
trevorsandy:STUD_LOGO

Conversation

@trevorsandy
Copy link
Copy Markdown
Contributor

@trevorsandy trevorsandy commented Oct 30, 2025

Enable the ability to select stud logo preference using the following stud logo geometry:

0 Plain
1 Single Wire
2 Double Wire
3 Raised Flat
4 Raised Rounded
5 Subtle Rounded

Screenshot 2025-10-30 201136

Only the Windows GUI is implemented; however from other platforms (i.e. macOS/Linux), you can set the the following options using [Sessions] in your .ini file.

[Sessions]
LDView Preset - Quality with Edges/UseStudLogo=1
LDView Preset - Quality with Edges/StudLogo=2

This feature is a subset of the comprehensive behaviour which also includes high-contrast studs and edge lines.

HighContrastSamples

With the addition of high-contrast studs and automatic edge line colors, the stud style ini file options have changed to:

[Sessions]
LDView Preset - Quality with Edges/AutomateEdgeColor=1
LDView Preset - Quality with Edges/UseStudStyle=1
LDView Preset - Quality with Edges/StudStyle=2

And stud geometry options are extended to:

0 Plain
1 Single Wire
2 Double Wire
3 Raised Flat
4 Raised Rounded
5 Subtle Rounded
6 High Contrast Plain
7 High Contrast Single Wire

Cheers,

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Oct 30, 2025

Did you use LDView's OBI code for the high-contrast work? (I'm guessing not, since it requires modified parts.) The OBI code was added years ago, but never became mainstream due to the requirement of having updated parts.

@trevorsandy
Copy link
Copy Markdown
Contributor Author

trevorsandy commented Oct 30, 2025

Did you use LDView's OBI code for the high-contrast work?

I did not. The high-contrast behaviour simply extends the primitives in TCStudLogoPrimitive StudLogoPrimitives and adds the ability to manipulate the stud cylinder and edge line colour both manually and automatically. The resulting behaviour adds an 'automate edge line color' checkbox to the Geometry tab and two new options to the Primitives tab's 'use stud logo geometry' combo control:

HighContrast =6 High Contrast Plain
HighContrastSingleWire =7 High Contrast Single Wire

Cheers,

@trevorsandy
Copy link
Copy Markdown
Contributor Author

I've added the full feature set which includes preference options to manually configure high-contrast studs and edge lines along with the preference to automatically adjust edge line color. The automate edge line color preference is set under the Geometry tab while use stud geometry is under Primitives.

Screenshot 2025-11-08 231244

Example model file.

Details
0 FILE StudStyles.ldr
0 Stud Styles
0 Name: studStyles.ldr
0 Author: LPub3D
0 !LICENSE Not redistributable : see NonCAreadme.txt
1 4 0 0 0 1 0 0 0 1 0 0 0 1 3001.dat
1 4 -40 24 0 1 0 0 0 1 0 0 0 1 3001.dat
1 4 40 24 0 1 0 0 0 1 0 0 0 1 3001.dat
0 ROTSTEP END
1 4 80 0 0 1 0 0 0 1 0 0 0 1 3001.dat
1 4 120 24 0 1 0 0 0 1 0 0 0 1 3001.dat
1 15 40 -24 0 1 0 0 0 1 0 0 0 1 3001.dat
0 STEP
1 1 -20 -8 0 1 0 0 0 1 0 0 0 1 subModel-1.ldr
0 STEP
1 15 -60 16 0 1 0 0 0 1 0 0 0 1 subModel-2.ldr
0 ROTSTEP 0 270 0 REL
1 0 100 -8 0 1 0 0 0 1 0 0 0 1 subModel-2.ldr
0 ROTSTEP 0 180 0 REL
1 1 140 16 0 1 0 0 0 1 0 0 0 1 subModel-1.ldr
1 15 40 -64 10 1 0 0 0 1 0 0 0 1 67329.dat
1 71 30 -88 10 1 0 0 0 1 0 0 0 1 15411.dat
1 288 50 -88 10 1 0 0 0 1 0 0 0 1 4070.dat
0 ROTSTEP 0 90 0 REL
0 NOFILE
0 FILE submodel-1.ldr
0 
0 Name: subModel-1.ldr
0 Author: LPub3D
0 !LICENSE Not redistributable : see NonCAreadme.txt
1 1 0 0 0 1 0 0 0 1 0 0 0 1 87580.dat
0 ROTSTEP END
1 14 0 -24 0 1 0 0 0 1 0 0 0 1 3062b.dat
0 STEP
0 NOFILE
0 FILE submodel-2.ldr
0 
0 Name: subModel-2.ldr
0 Author: LPub3D
0 !LICENSE Not redistributable : see NonCAreadme.txt
1 0 0 0 0 1 0 0 0 1 0 0 0 1 87580.dat
0 ROTSTEP END
1 25 0 -24 0 1 0 0 0 1 0 0 0 1 3062a.dat
0 STEP
0 NOFILE

Cheers,

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Jan 15, 2026

@pbartfai Do we want to update this PR to support macOS and Qt before releasing 4.7 or after? (Qt for you, macOS for me.)

@pbartfai
Copy link
Copy Markdown
Collaborator

@pbartfai Do we want to update this PR to support macOS and Qt before releasing 4.7 or after? (Qt for you, macOS for me.)

Let's release 4.7 first.

@pbartfai
Copy link
Copy Markdown
Collaborator

@pbartfai Do we want to update this PR to support macOS and Qt before releasing 4.7 or after? (Qt for you, macOS for me.)

Let's release 4.7 first.

@tcobbs 4.7 has been released
I've prepared the Qt UI...

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 18, 2026 via email

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 18, 2026

@trevorsandy Sorry for the delay. I am finally ready to review this and hopefully merge, but I have hit some possible problems. I'm guessing that this PR includes all of the local changes that you have made to LDView for LPub3d, because there is a bunch of stuff in here that is totally unrelated to the stud logo settings the that PR title makes this seem to be. (You do state in the description that this includes high-contrast studs and edge lines, and maybe that's all that's here in addition to the stud logos.)

While I don't have a problem in principle of incorporating all of these changes, I would greatly prefer if they didn't all show up in one single PR. (Having said that, I am not saying that separate PRs is an absolute requirement.)

How hard would it be to narrow down this PR to just the stud logo changes, and then create one or two other PRs for the other changes? I promise that I will deal with them in a timely manner.

Finally, can you confirm that this PR only contains the following:

  1. Stud logo options
  2. High-contrast studs
  3. High-contrast edge lines
  4. Windows-only preferences UI changes for the above

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 18, 2026 via email

@pbartfai
Copy link
Copy Markdown
Collaborator

Great. I'll do the macOS one. Do you know what the best way is to handle this? I think it's probably easiest to just merge Trevor's Windows-only PR to our master and then create new PRs for Qt and macOS.

The easiest would be merging this PR first then update Mac and Qt code.

@trevorsandy
Copy link
Copy Markdown
Contributor Author

trevorsandy commented Mar 19, 2026

Hi Travis, I can confirm that this PR only contains the following:

Stud logo options
High-contrast studs
High-contrast edge lines
Windows-only preferences UI changes for the above

I was deliberate to remove content that only implicated LPub3D such as the ability to suppress high-contrast colour management for 'fade previous steps' and 'highlight current step' behaviour.

I'm guessing that this PR includes all of the local changes that you have made to LDView for LPub3d, because there is a bunch of stuff in here that is totally unrelated to the stud logo settings the that PR title makes this seem to be.

There is no code in this PR that is not necessary to implement the behaviour outlined above. If you remain convinced otherwise, I will be pleased to clarify any suspicious code you care to specifically reference.

How hard would it be to narrow down this PR to just the stud logo changes, and then create one or two other PRs for the other changes? I promise that I will deal with them in a timely manner.

There are 7 (essentially 5 with 2 build fixes) commits in this PR. The first 2 commits delineate the stud logo preference behaviour:

  1. Add stud logo dialogue to Windows preferences UI - e1145b3
  2. Add stud logo preference including command line option - ef321d8

...and 3-5 address the manually selected or automatically applied, stud cylinder and edge color management :

  1. Rename stud logo to stud style - f8dcb51
  2. Setup stud style and automate edge line color - 7e3ed83
  3. Setup Windows preferences UI - 2879a1a

As you can see, with the exception of f8dcb51 which transitions naming for better maintainability, these commits are broken down into control logic and Windows UI implementation. This shows that the optimal PR breakdown would create 2 PRs:

  1. Stud logo preference - e1145b3, ef321d8, and f8dcb51
  2. Automate edge line color (introducing high-contrast edge lines and stud cylinder colour management) - 7e3ed83 and 2879a1a

If this breakdown is acceptable to you, I will be pleased to close this PR, and create 2 new ones respectively ?

Cheers,

@trevorsandy
Copy link
Copy Markdown
Contributor Author

Do you know what the best way is to handle
this? I think it's probably easiest to just merge Trevor's Windows-only PR
to our master and then create new PRs for Qt and macOS.

FWIW, stud logo and edge line colour management was added to LeoCAD, in quite the same manner as this PR. Leo added his change commits to the PR branch until he was satisfied that the content reflected what he wanted - at this point he merged the PR to master. This is also how I manage large updates so as not to implicate the best-so-far state of master until I am pleased with what is being added.

Cheers,

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 19, 2026

Do you know what the best way is to handle
this? I think it's probably easiest to just merge Trevor's Windows-only PR
to our master and then create new PRs for Qt and macOS.

FWIW, stud logo and edge line colour management was added to LeoCAD, in quite the same manner as this PR. Leo added his change commits to the PR branch until he was satisfied that the content reflected what he wanted - at this point he merged the PR to master. This is also how I manage large updates so as not to implicate the best-so-far state of master until I am pleased with what is being added.

Thanks for your replies. I can accept leaving this PR alone. It may take me a few days to review all the changes.

Copy link
Copy Markdown
Owner

@tcobbs tcobbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevorsandy I'm still reviewing, but I wanted to submit the comments on the code that I have so far reviewed.

if (sm_studCylinderColorEnabled)
return input;

const std::string studColor = "4242";
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the weird color numbers being used in LDConfig.ldr, how safe is 4242?

@trevorsandy
Copy link
Copy Markdown
Contributor Author

@trevorsandy I'm still reviewing, but I wanted to submit the comments on the code that I have so far reviewed.

Many thanks for sharing these review remarks, they present valuable insight into the architectural and design constraints of LDView that I did not take into account when I implemented this update.

If I may, it would be quite a bit more efficient and productive to reflect your changes as commits to the PR branch. Like this, your preferences and changes will be communicated just as well and we could still discus any changes that require clarification while actually evolving the PR towards what you would find acceptable for integration into LDView.

Cheers,

@pbartfai
Copy link
Copy Markdown
Collaborator

If I may, it would be quite a bit more efficient and productive to reflect your changes as commits to the PR branch. Like this, your preferences and changes will be communicated just as well and we could still discus any changes that require clarification while actually evolving the PR towards what you would find acceptable for integration into LDView.

For that we would need permission to push commits to your branch. See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

@trevorsandy
Copy link
Copy Markdown
Contributor Author

If I may, it would be quite a bit more efficient and productive to reflect your changes as commits to the PR branch. Like this, your preferences and changes will be communicated just as well and we could still discus any changes that require clarification while actually evolving the PR towards what you would find acceptable for integration into LDView.

For that we would need permission to push commits to your branch. See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

Travis was added as a collaborator on the entire fork many years ago. I sent you an invitation just now.

Cheers,

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 27, 2026

OK, sounds good. I'll commit to your branch. Because there as so many changes, it's likely going to take a while.

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 27, 2026

@trevorsandy I have committed some fixes to resolve my comments. It would probably be good if you periodically pull and look at the new commits and try to verify that I'm not breaking things.

#define _APS_NEXT_RESOURCE_VALUE 550
#define _APS_NEXT_COMMAND_VALUE 40122
#define _APS_NEXT_CONTROL_VALUE 1325
#define _APS_NEXT_CONTROL_VALUE 1357
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just here to prevent an accidental merge before I get this far.

@trevorsandy
Copy link
Copy Markdown
Contributor Author

@trevorsandy I have committed some fixes to resolve my comments. It would probably be good if you periodically pull and look at the new commits and try to verify that I'm not breaking things.

I reviewed through 9b7eaf5 and did not see anything suspicious.

I would however like to point out your refactor that adds LDPalette to LDPreferences. I wanted to do this and pondered it for many days, but in the end, was unsure of the full implications so I refrained. Your implementation valades my instinct and it is quite a pleasure to see how you provisioned this update! In fact, your move should solve the different palette load times between the snapshot and interactive modelview flows which could, in certain CLI/snapshot use cases, see the palette initialized before the specified colour parameters were loaded. Well done.

Cheers,

* Remove hard-coded (and edited) LDraw library files.
    * Load the files from the library on-demand
    * Algorithmically produce color 4242 versions when needed
* Use istringstream to load generated files instead of saving to temp
@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 29, 2026

@trevorsandy This is a big commit to get rid of the hard-coded stud files and also load the generated strings using a string stream instead of writing files to temp. I tried to test the various code paths, but I may have messed something up. Please give it a try with the various different style options.

@trevorsandy
Copy link
Copy Markdown
Contributor Author

trevorsandy commented Mar 29, 2026

@trevorsandy This is a big commit to get rid of the hard-coded stud files and also load the generated strings using a string stream instead of writing files to temp. I tried to test the various code paths, but I may have messed something up. Please give it a try with the various different style options.

On a fresh build of the STUD_LOGO branch using StudStyles.ldr (see Details above), the overall behaviour seems as expected:

  • Automate edge line color seems to behave as expected.
  • High-contrast edge line color seems to behave as expected.

Here are the exceptions I observed:

  • Stud cylinder color does not propagate when 'Low quality studs' is enabled (this behaviour was present in the original PR code).

  • Stud style geometry does not propagate when 'Low quality studs' is enabled (same as above).

  • Stud cylinder color set to 16 for '7 High Contrast Single Wire'; previously, it would be set to the specified high contrast cylinder color (default 27,42,52,255).

  • '0 Plain' incorrectly uses primitives with 4242 color code instead of default primitives that use 16. This results in all studs inheriting the 4242 assigned color. (this behaviour was also inherited from the original PR.

  • 0 Plain correction
     if (!sm_studCylinderColorEnabled || sm_studStyle == 0)
     {
     	return;
     }
     const std::string studColor = "4242";
  • Reload seems to enter a loop, leaving the viewport empty and menu options disabled, under certain flows. I imagine this is repeatable but I haven’t investigated the exact step sequence needed.

Cheers,

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 30, 2026

  • Stud cylinder color set to 16 for '7 High Contrast Single Wire'; previously, it would be set to the specified high contrast cylinder color (default 27,42,52,255).

Just so I'm on the same page. If I enable stud style and set stud style to 7, are the sides of stud.dat supposed to be black?

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 30, 2026

@trevorsandy The '7 High Contrast Single Wire' problem you reported should now be fixed. The problem was the presence of 4-4cylc.dat in the library's stud-logo.dat file.

@tcobbs
Copy link
Copy Markdown
Owner

tcobbs commented Mar 30, 2026

@trevorsandy Question: are transparent studs supposed to be getting the black sides? That looks very strange to me, but I can see how preventing it might be hard.

@trevorsandy
Copy link
Copy Markdown
Contributor Author

  • Stud cylinder color set to 16 for '7 High Contrast Single Wire'; previously, it would be set to the specified high contrast cylinder color (default 27,42,52,255).

Just so I'm on the same page. If I enable stud style and set stud style to 7, are the sides of stud.dat supposed to be black?

Yes - however to be precise, the color should be that which is set as the stud cylinder color. The default stud cylinder color is 27,42,52,255 which is not quite black.

Cheers,

@trevorsandy
Copy link
Copy Markdown
Contributor Author

@trevorsandy Question: are transparent studs supposed to be getting the black sides? That looks very strange to me, but I can see how preventing it might be hard.

Yes - I pondered making opaque cylinders on trans-clear studs optional using a meta command (in LPub3D) but at the moment, trans-clear studs are opaque. Here is an example:
52617355319_1163c4d10c_c

Cheers,

Comment on lines +2668 to +2669
{
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevorsandy Is there a reason this is empty?

Comment on lines +2676 to +2677
{
}
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevorsandy Is there a reason this is empty?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trevorsandy Is there a reason this is empty?

Yes - there is nothing to do - unlike the void LDViewPreferences::doNewPrefSet(void) function just before.

Cheers,

@trevorsandy
Copy link
Copy Markdown
Contributor Author

On a fresh build of the STUD_LOGO branch (at ff8d8ea) using StudStyles.ldr (see Details above), the overall behaviour seems as expected:

  • Automate edge line color seems to behave as expected.
  • High-contrast edge line color seems to behave as expected.
  • High-contrast stud cylinder color seems to behave as expected

However, these exceptions remain:

  • Stud cylinder color does not propagate when 'Low quality studs (Faster)' is enabled (this behaviour was present in the original PR code).
  • Stud style geometry does not propagate when 'Low quality studs (Faster)' is enabled (same as above).

This behaviour unsettles the UX. I propose that for the GUI, 'Use stud style geometry' and 'Low quality studs (Faster)' should be an either/or selection, with the unselected option disabled to properly indicate the behaviour will not function when the alternate option is selected.
I did not check the CLI behaviour but if it is the same as the GUI then perhaps a console message indicating the contradiction when both options are determined to be enabled would be appropriate.

It is a bit odd that, on reviewing the code, I could not find where the stud style behaviour is ignored when low quality studs is enabled.

Cheers,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants