Skip to content

Examples and basic shapes #39

@trailcode

Description

@trailcode

Examples and basic shapes

Summary

This issue documents the feature additions and improvements made to EzyCad (File/Edit menu, Examples, primitives, naming, Scale command, and related fixes).


Changes

File menu – Examples

  • Examples submenu added to the File menu (before Open).
  • On startup the app scans res/examples for .ezy files and populates the Examples submenu.
  • Selecting an example opens that file like a normal project.
  • Native: Uses res/examples (relative to process cwd).
  • Emscripten: Uses /res/examples (preloaded); Examples menu works in the browser build.
  • CMake: res/examples is copied into the build output for native; Emscripten preloads res/examples via --preload-file.

Edit menu – Primitives

  • Edit menu added with primitives (each has a quick-add at default size and an “_prms” entry that opens a parameter dialog in display units):
    • Add box – Box (width × length × height). Quick-add: unit cube at origin. Dialog: origin X/Y/Z, width, length, height.
    • Add pyramid – Square-based pyramid (base side = height). Quick-add: unit at origin. Dialog: origin X/Y/Z, side.
    • Add sphere – Sphere. Quick-add: unit radius at origin. Dialog: origin X/Y/Z, radius.
    • Add cylinder – Cylinder. Quick-add: unit radius and height at origin. Dialog: origin X/Y/Z, radius, height.
    • Add cone – Cone (truncated). Quick-add: base radius = height, top radius 0. Dialog: origin X/Y/Z, base radius (R1), top radius (R2), height.
    • Add torus – Torus. Quick-add: major radius = 1, minor = 0.5 at origin. Dialog: origin X/Y/Z, major radius (R1), minor radius (R2).
  • All use get_dimension_scale() for quick-add sizes; dialogs take values in display units and scale when adding. Display and selection (AIS_Shaded, default material, selection mode from Options) match the cube/pyramid behavior.

Shape naming in Shape List

  • Cube / Pyramid: When adding a cube or pyramid, the shape is named "Cube" or "Pyramid". If one already exists, names get a numeric suffix: "Cube.001", "Cube.002", "Pyramid.001", etc.
  • Extruded: When finalizing a shape extrude (sketch face extrude), the new shape is named "Extruded", then "Extruded.001", "Extruded.002", etc., using the same logic.
  • Names are shown and editable in the Shape List; numbering is consistent when adding multiple primitives or extrusions.

Scale command

  • Scale toolbar mode was present but not implemented (empty ShpScale stub, no handling).
  • Implemented: Full scale operation similar to Move/Rotate:
    • Select one or more shapes, click Scale, drag mouse away from scale center (bbox center); scale factor = current distance / initial distance.
    • Left-click to apply (bake transform); Escape/cancel to revert.
    • Uses gp_Trsf::SetScale(center, factor); add_shp_ and display flow aligned with other shape ops.
  • Integration: Shp_scale class, Occt_view::shp_scale(), mouse handling and cancel/finalize in GUI and view; Scale resets when switching mode.

Fixes

  • Cube display: Cube was shown as wireframe; fixed by displaying with AIS_Shaded and selection mode when adding.
  • Emscripten examples: Examples menu was empty on web; load_examples_list_() now runs on Emscripten using path /res/examples.
  • Release build: GUI::dbg_() wrapped in #ifndef NDEBUG so Release builds (where m_show_dbg is not defined) compile.

Files touched (high level)

  • Menu / GUI: src/gui.cpp, src/gui.h – Examples submenu, Edit menu, Scale handling, Options for Scale, dbg_ guard.
  • View / primitives / naming: src/occt_view.cpp, src/occt_view.h – Examples loading, add_cube, add_pyramid, unique_shape_name_, get_unique_shape_name, Scale wiring, cancel for Scale.
  • Scale: src/shp_scale.h, src/shp_scale.cpp – Scale operation implementation.
  • Extrude naming: src/shp_extrude.cpp – Set extruded shape name via get_unique_shape_name("Extruded") in finalize().
  • Build / resources: CMakeLists.txt – Copy and preload res/examples for native and Emscripten.

How to use (brief)

  • Examples: File → Examples → <example.ezy> to open an example project.
  • Primitives: Edit → Add cube / Add pyramid; names appear in Shape List as Cube, Pyramid, Cube.001, etc.
  • Extrude: Sketch face extrude; on finalize the new shape appears in Shape List as Extruded, Extruded.001, etc.
  • Scale: Select shape(s) → Scale tool → drag to scale from center → LMB to apply.

This issue can be closed as documentation once the changes are merged or released.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions