NDEVR
API Documentation
SelectionWidget.h
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: NDEVR
28File: SelectionWidget
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/QTDesignObject.h>
35#include <NDEVR/QTModelManager.h>
36#include <NDEVR/DesignObjectWidgetInterface.h>
37#include <NDEVR/DesignWidget.h>
38#include <NDEVR/OrientationEditor.h>
39#include <NDEVR/CommandLockObject.h>
40namespace NDEVR
41{
42 class RibbonSubGroup;
44 class Button;
45 class SmoothButton;
46 class DesignWidget;
48 class FilteringWidget;
50 class GridButton;
51 class GeoReferenceDialog;
52 class GeometryEditor;
53 class SmoothDialog;
54
98
107
111 class NDEVR_API SelectionWidget : public QWidget, public DesignObjectWidgetInterface, public BasicKeyController
112 {
113 Q_OBJECT
114 public:
126
131 SelectionWidget(QTModelManager* manager, QWidget *parent = nullptr);
133 {}
138 void addInclusionType(const StringView& type);
143 void addExclusionType(const StringView& type);
148 static void AddGlobalInclusionType(const StringView& type);
153 static void AddGlobalExclusionType(const StringView& type);
158 static void AddGlobalExclusionTypes(const Buffer<String>& types);
166 void resizeEvent(QResizeEvent *event) override;
172 bool canHandle(UUID id) const;
178 Model findModelThatIsHandled(const Model& root_model) const;
184 bool canHandleDirectly(const Model& model) const;
190 bool isShowing(UUID id) const;
191 bool event(QEvent* ev) override;
195 void clear();
196 void onTargetUpdated(UUID id) override;
214 virtual bool processKeyEvent(const StringView& id, const KeyEvent& key_event, DesignObjectLookup* lookup, Camera* camera) override;
216 public slots:
222 void onSelectedSlot(Buffer<UUID> id, bool selected);
223 signals:
226 private:
227 void updateTitle();
228 void startClearSignalTimer();
229 void stopClearSignalTimer();
230 void startUpdateSignalTimer();
231 void stopUpdateSignalTimer();
232 private:
233 DesignWidget::PropertiesStruct m_last_props;
234 Set<String> m_inclusion_types;
235 Set<String> m_exclusion_types;
236 static Set<String> s_inclusion_types;
237 static Set<String> s_exclusion_types;
238 SizeMode m_size_mode;
239 Dictionary<UUID, SelectionButtonFactory*> m_selection_button_factories;
240 DesignObjectVisibleButton* m_visible_button = nullptr;
241 Button* m_flip_normal_button = nullptr;
242 Button* m_delete_button = nullptr;
243 Button* m_export_button = nullptr;
244 Button* m_smooth_button = nullptr;
245 Button* m_fill_holes_button = nullptr;
246 Button* m_geometry_button = nullptr;
247 Button* m_wireframe_button = nullptr;
248 Button* m_two_sided_button = nullptr;
249 Button* m_gridlines_button = nullptr;
250 Button* m_register_button = nullptr;
251 Button* m_geo_reference_button = nullptr;
252 Button* m_group_explode_button = nullptr;
253
254 GridButton* m_grid_button_container = nullptr;
255 Button* m_filter_button = nullptr;
256 SmoothButton* m_smooth_logic = nullptr;
257 Time m_last_modified_time;
258 OrientationEditor* m_orientation_editor = nullptr;
259 DesignWidget* m_design_widget = nullptr;
260 QTModelManager* m_manager = nullptr;
261 FilteringWidget* m_filtering_widget = nullptr;
262 SmoothDialog* m_smooth_dialog = nullptr;
263 GeometryEditor* m_geometry_editor = nullptr;
264 UUID m_capture_uuid_pitch;
265 UUID m_capture_uuid_roll;
266 UUID m_capture_uuid_yaw;
267 RibbonSubGroup* m_basic_commands;
268 UUID m_command_id;
269 QBoxLayout* m_layout;
270 QTimer* m_hide_timer;
271 QTimer* m_update_timer;
272 };
273}
BasicKeyController(const TranslatedString &key_controller_title)
Constructs a BasicKeyController with the given title.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core widget that allows the user to click one of many button types.
Definition Button.h:68
Sets up a button to be a combobox with the various snap locations of a camera.
A core object representing a user view as well as convenience functions for moving this view through ...
Definition Camera.h:95
A core class where all Design Objects including models, materials, and geometries are stored.
A class for easily showing or hiding a Model in 3D space.
QTModelManager * manager() const
Returns the current model manager.
A widget showing key properties of a DesignObject selection, used primarily in a SelectionWidget.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:356
A widget allowing the user to select a FilterDescription and adjust its properties and execute a filt...
A popup Editor dialog for showing options or information related to Geometry objects.
Describes a user key press event used to trigger behavior in the NDEVR API.
Definition Event.h:49
A core class that represents a node on model hierarchy.
Definition Model.h:292
A dialog where the user can set a 3D orientation of an object.
Used to capture a 2D image of a DesignObjectLookup from a specific perspective.
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Represents a sub-section of "Tab" of a ribbon representing a grouping of buttons or widgets within a ...
A factory for creating custom buttons that appear when objects are selected.
virtual SelectionButtonFactory * clone()=0
Creates a copy of this factory.
virtual UUID id() const =0
Retrieves the unique identifier for this factory.
static Dictionary< UUID, SelectionButtonFactory * > s_default_factories
Registered default factories.
virtual Buffer< Button * > getButtons(DesignWidget::PropertiesStruct props, const Buffer< DynamicPointer< QTDesignObject > > &selection)=0
Creates buttons for the given selection and properties.
static void RegisterDefault(SelectionButtonFactory *factory)
Registers a default selection button factory.
virtual void updateButtonStates(DesignWidget::PropertiesStruct props, const Buffer< DynamicPointer< QTDesignObject > > &selection)=0
Updates the enabled/checked states of buttons for the current selection.
static Buffer< SelectionButtonFactory * > DefaultFactories()
Retrieves all registered default selection button factories.
void addInclusionType(const StringView &type)
Adds a model type that this widget can handle.
void onSelectedSignal()
Emitted when the widget updates for a new selection.
void onTargetUpdatedSlot(UUID id)
Handles notification that a target object was updated.
void onClearSignal()
Emitted when the widget is cleared.
void clear()
Clears the widget, removing all displayed objects.
SelectionWidget(QTModelManager *manager, QWidget *parent=nullptr)
Constructs a selection widget for the given model manager.
static void AddGlobalExclusionType(const StringView &type)
Adds a global exclusion type applied to all selection widgets.
void setSizeMode(SizeMode mode)
Sets the size mode controlling the layout.
void onTargetUpdated(UUID id) override
Called when a target design object is updated.
static void AddGlobalExclusionTypes(const Buffer< String > &types)
Adds multiple global exclusion types at once.
bool canHandleDirectly(const Model &model) const
Checks whether this widget can handle the given model directly.
void addExclusionType(const StringView &type)
Adds a model type that this widget should exclude.
bool canHandle(UUID id) const
Checks whether this widget can handle the given object.
void resetKeyControllerToDefaults() override
Resets all key mappings to their default values.
Model findModelThatIsHandled(const Model &root_model) const
Searches the model hierarchy for a model that this widget can handle.
bool isShowing(UUID id) const
Checks whether the given object is currently shown in the widget.
void createGroup()
Creates the button group layout for the selection widget.
void updateSelected()
Updates the widget to reflect the current selection state.
void onSelectedSlot(Buffer< UUID > id, bool selected)
Handles selection change events from the model manager.
void onAddedSlot(UUID id)
Handles notification that a new object was added.
SizeMode
Size modes controlling the layout of the selection widget.
@ e_tiny_vertical
Minimal vertical layout.
@ e_small_vertical
Compact vertical layout.
@ e_normal
Full-size layout.
@ e_tiny_horizontal
Minimal horizontal layout.
@ e_small_horizontal
Compact horizontal layout.
static void AddGlobalInclusionType(const StringView &type)
Adds a global inclusion type applied to all selection widgets.
void updateControls()
Updates the enabled and visible state of all controls.
void addFactory(SelectionButtonFactory *factory)
Adds a custom selection button factory.
virtual bool processKeyEvent(const StringView &id, const KeyEvent &key_event, DesignObjectLookup *lookup, Camera *camera) override
Processes a key event identified by its string ID.
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
Definition Set.h:59
A widget allowing the user to select options and execute smoothing a 3D mesh.
The core String View class for the NDEVR API.
Definition StringView.h:58
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
NDEVRSelectionAction
Actions that can be performed on the current selection.
@ e_save_selection
Save the selected objects to a file.
@ e_selection_action_size
The number of selection actions.
@ e_delete_selection
Delete the selected objects.
Aggregated rendering properties of the current selection, used to update UI controls.