Giter VIP home page Giter VIP logo

cadquery-gui's Introduction

cadquery-gui (cqg)

An Electron-based CAD GUI built for CadQuery.

Note: Unless you have a compelling reason to use cadquery-gui, it is recommended that you transition to CQ-editor as it has better support and is fully CadQuery 2.x compatible.

User Interface Overview

General Prerequisites

  1. Install npm

CadQuery 1.0 Prerequisites

If you are wanting to use the FreeCAD based version of CadQuery (version 1.x), follow these prerequisite installation instructions.

  1. Install FreeCAD (>=0.16)
  2. Install the latest version of CadQuery from the GitHub repo.
pip install git+https://github.com/dcowden/cadquery.git

CadQuery 2.0 Prerequisites

NOTE: caduqery-gui is not yet compatible with the OCP (latest) version of CadQuery 2.0. Tessellation works differently in the new CadQuery version which has broken show_object processing and display.

If you are wanting to use the PythonOCC based version of CadQuery (version 2.x), follow these prerequisite installation instructions.

  1. Create a cadquery Anaconda environment conda create --name cadquery
  2. Activate the conda environment conda activate cadquery
  3. Follow the instructions here to install the prerequisites.

Install The Latest Development Version of cadquery-gui

The latest version can be cloned directly from this GitHub repo.

git clone https://github.com/jmwright/cadquery-gui.git
cd cadquery-gui/
npm install

Run The Latest Development Version of cadquery-gui

npm start

cadquery-gui's People

Contributors

dependabot[bot] avatar jmwright avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cadquery-gui's Issues

Add CQGI Parameter Handling

Right now a parameters editor wouldn't work because cqg doesn't handle dynamic parameters. This needs to be implemented as part of the CQGI update.

What is the role of cadQuery here?

Hi,

This might be a premature question, as I didn't read the source code deeply (just briefly took a look). I'm confused about something: What is the role of cadQuery here? As far as I could understand, electron creates a Gui, Three.js visualizes the 3D object and provides some controls; so what does cadQuery do? Does it re-calculate the model, send the resulting object (like, STL or something that Three.js understands) over zerorpc and let Three.js update the model?

Decouple Front End and Back End with Websockets

Currently the front end and the back end of the app are pretty much the same thing. With the way Electron works it will be tricky to completely decouple them, but a good first step would be to initiate a model build and transport the glTF information back to the viewer via a websocket. Once this infrastructure is in place, it could lead to things later like a presentation mode or even collaborative editing of parts and assemblies.

Number Pad Support

Background

As I re-implement the viewer, I'll need to choose hotkeys for the different 3D views (front, left-side, top, etc). One idea that was proposed a long time ago in the CadQuery issue tracker was to use the numpad on the keyboard for the different views. I've used a 3D mouse a lot over the years, and always miss it in GUIs that don't support it. Using the numpad would allow people like myself to add a USB numpad for their non-mouse hand and get at least get some of the effect of the 3D mouse. This would also provide easier 3D view manipulation for people with no access to a 3D mouse.

Theory of Operation

This is all theoretical, I haven't tried to use this setup. The views key mapping on the numpad would be as follows:
0 = Isometric/Axiometric, fit-all
1 = Isometric/Axiometric looking up from the bottom left
2 = Bottom
3 = Isometric/Axiometric looking up from the bottom right
4 = Left side
5 = Tap once front view, double-tap (or maybe hold) back view
6 = Right Side
7 = Isometric/Axiometric looking up from the top left
8 = Top
9 Isometric/Axiometric looking up from the top right

Tapping the keys would snap you to that view, and holding down on the keys would cause an alternate operation. Holding down on most keys would start to rotate the object(s) in the direction of the key being held. Maybe the longer you hold the faster it goes. Pressure sensitive keys would be ideal, but I don't think there's anything available like that (possible Tindie product for CadQuery?). The 5 key for the front-back operation might be the exception to the hold-for-rotation operation.

Embed CadQuery Library

This impacts other functionality, but needs to be done so that the CadQuery examples can be embedded with the application. What was done with the CadQuery module for FreeCAD was that sys.path is manipulated so that the embedded library will be found before any other installed versions.

Implement glTF Support

Implement a proof-of-concept with glTF support in parallel with the current flat JSON method. glTF is a JSON-based format that will provide us with deeper information about parts/assemblies and their hierarchy than what we can currently get.

Implement CQGI (CadQuery Gateway Interface) Support

I think CQGI was being written when I first created this GUI. In order for the user to edit script parameters through the GUI, this needs to be implemented. The CadQuery module for FreeCAD can be used as an example.

File Watcher Support for External Editing

I'm documenting this after the fact since I pushed the change in 729c731

A file watcher is not attached under normal circumstances, but when a user clicks the Edit button to open the model's script in Atom, a file watcher is attached. This provides the user with a faster workflow since they can just save the file in Atom to update the 3D view. There are a couple of things about this that need to be addressed.

  1. Users need to be able to specify their own editor and any necessary command line options.
  2. Users should be able to disable this feature when they're working on scripts that take long periods of time to run.

I believe that this completes an MVP that I am able to use to replace CadQuery's FreeCAD workbench. Obviously there's a tremendous amount of work left we can do, but this will allow me to start dogfooding the GUI.

Add Examples Dialog

The examples referenced here are the ones included with the CadQuery library. What I'm thinking for the structure of the dialog is as follows. The list of examples will have to be scrollable because there are quite a few of them.

  • Each example will have a card with:
    • Title
    • Image of model
    • Short paragraph description
    • Link for video of example, if it exists

High CPU Utilization

Any kind of rendering (main scene and origin scene) causes high CPU utilization. Here's my processor info. I'm not running a weak CPU/GPU setup by any means.

i7-7600U CPU @ 2.80GHz
NVIDIA Corporation GM108M [GeForce 940MX] (rev a2)

If I comment out the these two lines of code so that nothing is rendered, the CPU utilization drops from about 40% to 60% at idle (spiking to over 100% when actively rotating) , to about 6%. Disabling anti-aliasing and other things that I've tried have had no effect. I've tried just rendering the main scene, and then just rendering the origin scene. Both lead to the same high CPU utilization problem.

Tagging @fragmuffin on this since I've cited it as the main barrier to moving forward with this GUI.

Add Welcome Dialog

An opt-out dialog should show up when the app starts to mainly tell new users where to click to get help. Other things could also be added like changes in the current version, but I need to look at some examples of good welcome dialog design.

An option to disable this dialog is already present in the settings dialog. It just need to be wired up once this has been created.

Re-Implement 3D Viewer

This is a task related to #1 to address the high CPU utilization problem which will allow us to move forward with this GUI. The features and styles from mviewer need to be ported over.

Add Parameters Editor Dialog

CQGI enables editing of the variables of a script dynamically. A parameter editors dialog box allows users to change the variables through the GUI without editing the script. This is especially useful when someone just wants to view a script and maybe try out a few variations.

Display Script Errors

This could take the form of flash messaes when a script is executed, but could also be rolled into a console. CQGI collects script errors and passes them back to the caller, allowing them to be displayed to the user in any way the execution environment chooses.

Add UI Tour

Not sure if this will take the form of a video with accompanying text, or something like Intro.js. The user should not be dropped straight into the GUI without any orientation though.

Roadmap

@fragmuffin Based on conversations on the cqparts and cadquery issue trackers, I think we might be wanting different things out of this GUI. I'd like to start a discussion here to figure out a high level path forward for how this UI will work.

What You Would Like to See

If I understand correctly, you would like for the GUI to be view only, but allow the user to adjust parameters though the GUI. Is that correct?

What I Would Like to See

I'm interested in that mode of operation, but I'm also interested in a couple of others.

  1. A replacement for the CadQuery module/workbench for FreeCAD. This requires an editor pane and a 3D view pane side-by-side to allow for editing and re-executing scripts. That's the way the GUI is currently laid out.
  2. A platform for experimenting with code-mouse interaction, where what you do in one pane effects the other.

A Possible Path Forward

Right now what I'm thinking is this:

  1. A user opens a CadQuery script (cqparts or a stock script) and they only get the 3D view with a parameter editor box somewhere in the GUI.
  2. The user has the option of hitting a hotkey or (doing something like) right clicking and selecting "Edit Script". Then the GUI splits into the editor-viewer mode.

Additional Design Goals

There are a few other goals that I think are work pursuing.

  1. Support PythonOCC as well as FreeCAD as CadQuery's CAD kernel interface layer. The current design of this GUI makes that pretty easy I think since JSON is used as an intermediate object format. The current version of the GUI was designed while using FreeCAD-CadQuery.
  2. Allow the GUI to be run in web server mode where the UI is served to a web browser instead of into an Electron window.
  3. There should probably also be a well-integrated Python console available in the GUI somewhere so people can try things quickly.

There's also been talk in the community of a single installer for a CadQuery GUI as well as the command line. Something similar to what you get with OpenSCAD and FreeCAD. Should we try to do that at some point with this GUI?

Far Future

Something in the back of my mind is other modes of operation for the GUI such as a generative design mode, but I'm a long ways from having time to start that. It's not feasible to cover expanded use cases at this point, but it's worth noting that this GUI lends itself to being expanded for other uses later.

Add Documentation

The cqg documentation needs to be added (docs directory in this repo). A rendered version of the documentation may be made available directly in cqg (embedded for offline viewing), and also set up to be pushed to GitHub pages.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.