6#include <QtCore/QtGlobal>
7#include <QtWidgets/QMenu>
8#include <QtWidgets/QPushButton>
9#include <QtWidgets/QToolButton>
10#include <QtWidgets/QComboBox>
11#include <QtWidgets/QToolBar>
12#include <QtWidgets/QAbstractItemView>
13#include <QtWidgets/QScrollArea>
30template <
class Ui,
class Shape,
class ShapeModel>
33 iqtgui::TWheelFocusEvent<
34 iqtgui::TDesignerGuiObserverCompBase<Ui, ShapeModel> > >,
44 I_ASSIGN(m_defaultUnitInfoCompPtr,
"DefaultUnitInfo",
"Provide default information about the logical value units e.g. mm, this will be used if no unit information found in model",
false,
"DefaultUnitInfo");
45 I_ASSIGN(m_colorSchemaCompPtr,
"ShapeColorSchema",
"Color schema used by displayed shape",
false,
"ShapeColorSchema");
46 I_ASSIGN(m_fixedPositionAttrPtr,
"FixedPosition",
"If enabled, the shape position will be not editable",
true,
false);
47 I_ASSIGN(m_fixedPositionParamPtr,
"FixedPositionParam",
"If set, will be used instead of FixedPosition attribute",
false,
"FixedPositionParam");
48 I_ASSIGN(m_allowToolsMenuAttrPtr,
"ShowTools",
"Show extended shape edit tools",
true,
true);
49 I_ASSIGN(m_toolBarGuiCompPtr,
"ToolBarGui",
"Toolbar GUI object to fill with actions",
false,
"ToolBarGui");
50 I_ASSIGN(m_shapeToolTipAttrPtr,
"ShapeToolTip",
"Tool tip will be show on console",
false,
"");
99 QAbstractButton* m_menuButtonPtr;
101 typedef QSet<QAction*> Actions;
102 Actions m_toolBarActions;
107 I_ATTR(
bool, m_fixedPositionAttrPtr);
108 I_ATTR(
bool, m_allowToolsMenuAttrPtr);
116template <
class Ui,
class Shape,
class ShapeModel>
119 m_menuButtonPtr(
NULL)
126template <
class Ui,
class Shape,
class ShapeModel>
129 if (BaseClass::OnModelAttached(modelPtr, changeMask)){
130 const ShapesMap& shapesMap = BaseClass::GetShapesMap();
131 for (
typename ShapesMap::const_iterator iter = shapesMap.begin();
132 iter != shapesMap.end();
134 const Shapes& shapes = iter.value();
135 int shapesCount = shapes.GetCount();
136 for (
int shapeIndex = 0; shapeIndex < shapesCount; ++shapeIndex){
137 Shape* shapePtr =
dynamic_cast<Shape*
>(shapes.GetAt(shapeIndex));
138 if (shapePtr !=
NULL){
140 shapePtr->SetVisible(
true);
154template <
class Ui,
class Shape,
class ShapeModel>
157 if (BaseClass::OnModelDetached(modelPtr)){
158 const ShapesMap& shapesMap = BaseClass::GetShapesMap();
159 for (
typename ShapesMap::const_iterator iter = shapesMap.begin();
160 iter != shapesMap.end();
162 const Shapes& shapes = iter.value();
163 int shapesCount = shapes.GetCount();
164 for (
int shapeIndex = 0; shapeIndex < shapesCount; ++shapeIndex){
165 Shape* shapePtr =
dynamic_cast<Shape*
>(shapes.GetAt(shapeIndex));
166 if (shapePtr !=
NULL){
171 shapePtr->SetVisible(
false);
186template <
class Ui,
class Shape,
class ShapeModel>
190 if (shapePtr !=
NULL){
193 if (m_colorSchemaCompPtr.IsValid()){
197 if (m_shapeToolTipAttrPtr.IsValid()){
201 if (BaseClass::IsReadOnly()){
207 if (modelPtr !=
NULL){
221template <
class Ui,
class Shape,
class ShapeModel>
224 if (m_fixedPositionParamPtr.IsValid()){
225 return m_fixedPositionParamPtr->IsEnabled();
228 return *m_fixedPositionAttrPtr;
232template <
class Ui,
class Shape,
class ShapeModel>
235 return *m_allowToolsMenuAttrPtr;
239template <
class Ui,
class Shape,
class ShapeModel>
242 return m_toolBarGuiCompPtr.IsValid() ?
dynamic_cast<QToolBar*
>(m_toolBarGuiCompPtr->GetWidget()) :
NULL;
246template <
class Ui,
class Shape,
class ShapeModel>
251 const ShapeModel* objectPtr = BaseClass::GetObservedObject();
252 if (objectPtr !=
NULL){
254 if (calibrationProviderPtr !=
NULL){
256 if (calibrationPtr !=
NULL){
262 if (unitInfoPtr !=
NULL){
266 if (m_defaultUnitInfoCompPtr.IsValid()){
267 return m_defaultUnitInfoCompPtr->GetUnitName();
274template <
class Ui,
class Shape,
class ShapeModel>
281template <
class Ui,
class Shape,
class ShapeModel>
284 m_menuButtonPtr = buttonPtr;
286 if (buttonPtr ==
NULL){
290 if (!IsToolsMenuAllowed()){
295 if (m_menuPtr ==
NULL){
296 m_menuPtr =
new QMenu(buttonPtr);
297 QObject::connect(m_menuPtr, SIGNAL(triggered(QAction*)),
this, SLOT(OnActionTriggered(QAction*)));
299 QPushButton* pushButtonPtr =
dynamic_cast<QPushButton*
>(buttonPtr);
300 if (pushButtonPtr !=
NULL){
301 pushButtonPtr->setMenu(m_menuPtr);
304 QToolButton* toolButtonPtr =
dynamic_cast<QToolButton*
>(buttonPtr);
305 if (toolButtonPtr !=
NULL){
306 toolButtonPtr->setMenu(m_menuPtr);
313template <
class Ui,
class Shape,
class ShapeModel>
320template <
class Ui,
class Shape,
class ShapeModel>
323 if (m_menuPtr !=
NULL){
326 if (PopulateActions(*m_menuPtr, modelPtr)){
327 m_menuButtonPtr->setEnabled(
true);
330 m_menuButtonPtr->setEnabled(
false);
333 QToolBar* toolBarPtr = GetToolBar();
334 if (toolBarPtr !=
NULL){
336 QList<QAction*> actions = toolBarPtr->actions();
338#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
339 QSet<QAction*> oldActions(actions.begin(), actions.end());
341 QSet<QAction*> oldActions = actions.toSet();
344 if (PopulateActions(*toolBarPtr, modelPtr)){
346 actions = toolBarPtr->actions();
348#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
349 QSet<QAction*> newActions(actions.begin(), actions.end());
351 QSet<QAction*> newActions = actions.toSet();
354 m_toolBarActions = newActions - oldActions;
356 toolBarPtr->setVisible(
true);
360 if (m_menuPtr ==
NULL){
361 QObject::connect(toolBarPtr, SIGNAL(actionTriggered(QAction*)),
this, SLOT(OnActionTriggered(QAction*)));
365 toolBarPtr->disconnect();
371template <
class Ui,
class Shape,
class ShapeModel>
374 if (m_menuButtonPtr !=
NULL){
375 m_menuButtonPtr->setEnabled(
false);
378 QToolBar* toolBarPtr = GetToolBar();
380 toolBarPtr->disconnect();
383 for (Actions::ConstIterator iter = m_toolBarActions.constBegin(); iter != m_toolBarActions.constEnd(); ++iter){
384 toolBarPtr->removeAction(*iter);
387 m_toolBarActions.clear();
394template <
class Ui,
class Shape,
class ShapeModel>
402template <
class Ui,
class Shape,
class ShapeModel>
405 iview::IShape* shapePtr = CreateShape(BaseClass::GetObservedObject(),
true);
406 if (shapePtr !=
NULL){
407 result.PushBack(shapePtr);
414template <
class Ui,
class Shape,
class ShapeModel>
417 m_menuButtonPtr =
NULL;
418 if (m_menuPtr !=
NULL){
419 m_menuPtr->deleteLater();
424 BaseClass::OnGuiDestroyed();
428template <
class Ui,
class Shape,
class ShapeModel>
431 BaseClass::OnGuiShown();
433 OnModelAttachedAndGuiShown(BaseClass::GetObservedModel());
437template <
class Ui,
class Shape,
class ShapeModel>
440 OnModelDetachedOrGuiHidden(BaseClass::GetObservedModel());
442 BaseClass::OnGuiHidden();
448template <
class Ui,
class Shape,
class ShapeModel>
451 BaseClass::OnGuiModelAttached();
453 if (BaseClass::IsGuiShown()){
454 OnModelAttachedAndGuiShown(BaseClass::GetObservedModel());
457 m_fixedPositionParamPtr.EnsureInitialized();
461template <
class Ui,
class Shape,
class ShapeModel>
464 OnModelDetachedOrGuiHidden(BaseClass::GetObservedModel());
466 BaseClass::OnGuiModelDetached();
Interface for 2D calibration and coordinate transformation with unit information.
virtual const imath::IUnitInfo * GetArgumentUnitInfo() const =0
Get unit description of calibration input (transformation function argument).
Common interface for an object, which delivers a 2D-calibration.
virtual const ICalibration2d * GetCalibration() const =0
Get access to transformation object, which transforms a local logical coordinate system to global one...
Common interface to get information about a measurement unit.
virtual QString GetUnitName() const =0
Get name of unit.
Common interface for model objects, that supports Model/Observer design pattern.
virtual void DetachObserver(IObserver *observerPtr)=0
Detaches model object from observer observerPtr.
virtual bool AttachObserver(IObserver *observerPtr)=0
Attaches model object to observer observerPtr.
virtual bool IsAttached(const IObserver *observerPtr) const =0
Returns true if observer observer is attached to this model object.
Interface for objects which can be enabled/disabled.
virtual void OnModelAttachedAndGuiShown(imod::IModel *modelPtr)
virtual void CreateShapes(int sceneId, Shapes &result) override
virtual void CreateToolsMenu(QAbstractButton *buttonPtr)
Maintenance of the tools actions.
BaseClass::ShapesMap ShapesMap
virtual void OnGuiHidden() override
bool IsPositionFixed() const
virtual void OnGuiDestroyed() override
QString GetUnitName() const
virtual bool PopulateActions(QWidget &host, imod::IModel *modelPtr)
virtual void OnGuiModelAttached() override
virtual void OnGuiShown() override
virtual void OnGuiModelDetached() override
iqt2d::TViewExtenderCompBase< iqtgui::TWheelFocusEvent< iqtgui::TDesignerGuiObserverCompBase< Ui, ShapeModel > > > BaseClass
virtual iview::CInteractiveShapeBase * CreateShapeInstance() const
Simple creation of shape instance.
QToolBar * GetToolBar() const
virtual iview::IShape * CreateShape(const istd::IChangeable *objectPtr, bool connectToModel=false) const override
Create a graphical representation of the given 2D-object object.
bool IsToolsMenuAllowed() const
TShapeParamsGuiCompBase()
virtual void OnModelDetachedOrGuiHidden(imod::IModel *modelPtr)
virtual bool OnModelAttached(imod::IModel *modelPtr, istd::IChangeable::ChangeSet &changeMask) override
virtual bool OnModelDetached(imod::IModel *modelPtr) override
virtual void OnActionTriggered(QAction *actionPtr)
istd::TPointerVector< iview::IShape > Shapes
QMap< IViewProvider *, Shapes > ShapesMap
Common interface for GUI objects used in ACF component context.
Base class for all Qt GUI components.
Set of change flags (its IDs).
Common interface for data model objects, which can be changed.
virtual void SetEditablePosition(bool state=true)
virtual void SetVisible(bool state=true) override
Make shape to be visible or not.
virtual void SetUserColorSchema(const IColorSchema *schemaPtr) override
Set color schema to draw shape.
virtual void SetDefaultDescription(const QString &description) override
Set default description will be used to display on console.
virtual bool AssignToLayer(int layerType)
Assign this shape to same layer.
Defines set of standard pens, brushes and simple management of unions.
Interface for creation of visualization shapes of some geometrical object.
Common interface for all display console shapes.
@ LT_INACTIVE
Layer with inactive shapes.
#define I_TEXTATTR(member)
Declare translatable text attribute member.
This package contains Qt based implementations for 2D graphic objects.