MeshLib C++ Docs
Loading...
Searching...
No Matches
MRToolsLibrary.h
Go to the documentation of this file.
1#pragma once
2#include "MRMesh/MRMeshFwd.h"
3#include "exports.h"
4#include <vector>
5#include <string>
6#include <filesystem>
7
8namespace MR
9{
10
11struct EndMillTool;
12
13// class for storing CNC tools
14class MRVIEWER_CLASS GcodeToolsLibrary
15{
16public:
17 MRVIEWER_API GcodeToolsLibrary( const std::string& libraryName );
18
19 // draw interface for interacting with storage (based on UI::combo)
20 MRVIEWER_API bool drawInterface();
21
22 // draw dialog for creating end mill tools
23 // must be called outside any BeginCustomStatePlugin/EndCustomStatePlugin blocks
24 MRVIEWER_API bool drawCreateToolDialog( float menuScaling );
25
26 // get selected tool as ObjectMesh
27 [[nodiscard]] MRVIEWER_API const std::shared_ptr<ObjectMesh>& getToolObject();
28
29 // get selected tool as EndMillTool (if available)
30 [[nodiscard]] const std::shared_ptr<EndMillTool>& getEndMillTool() const { return endMillTool_; }
31
32 // set object specific size for automatic resize default object
33 MRVIEWER_API void setAutoSize( float size );
34private:
35
36 // storage folder
37 std::filesystem::path getFolder_();
38 // get valid files in storage folder
39 void updateFilesList_();
40 // add new tool in storage from file with mesh
41 void addNewToolFromFile_();
42 // add new tool in storage from exist ObjectMesh
43 void addNewToolFromMesh_( const std::shared_ptr<ObjectMesh>& objMesh );
44 // add new end mill tool in storage
45 void addNewTool_( const std::string& name, const EndMillTool& tool );
46 // remove the selected tool from storage
47 void removeSelectedTool_();
48 // draw popup with ObjectMeshes available for adding
49 void drawSelectMeshPopup_();
50 // choose mesh from storage (and load it)
51 bool loadFromFile_( const std::string& filename );
52
53 std::string libraryName_;
54 std::vector<std::string> filesList_;
55 std::string selectedFileName_;
56 std::shared_ptr<ObjectMesh> toolMesh_;
57 std::shared_ptr<ObjectMesh> defaultToolMesh_; // default mesh
58 std::shared_ptr<EndMillTool> endMillTool_;
59 float autoSize_ = 0.f; // object specific size for automatic resize default object
60
61 // Create Tool dialog state
62 bool createToolDialogIsOpen_ = false;
63 std::string createToolName_ = "Flat End Mill D2";
64 int createToolType_ = 0;
65 float createToolLength_ = 8.f;
66 float createToolDiameter_ = 2.f;
67 float createToolCornerRadius_ = 0.5f;
68 float createToolCuttingAngle_ = 90.f;
69 float createToolEndDiameter_ = 0.f;
70};
71
72}
Definition MRToolsLibrary.h:15
MRVIEWER_API const std::shared_ptr< ObjectMesh > & getToolObject()
MRVIEWER_API void setAutoSize(float size)
MRVIEWER_API bool drawInterface()
MRVIEWER_API GcodeToolsLibrary(const std::string &libraryName)
const std::shared_ptr< EndMillTool > & getEndMillTool() const
Definition MRToolsLibrary.h:30
MRVIEWER_API bool drawCreateToolDialog(float menuScaling)
Definition MRCameraOrientationPlugin.h:8
end mill tool specifications
Definition MREndMill.h:39