You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Include/nmNum/nmRender/nmVTKViewCommandController.h

94 lines
3.2 KiB
C

#ifndef NMVTKVIEWCOMMANDCONTROLLER_H
#define NMVTKVIEWCOMMANDCONTROLLER_H
#include "nmRender_global.h"
#include <QFlags>
#include <QObject>
#include <QString>
class QAction;
class QMenu;
class QToolBar;
class nmWxVTKRenderContainerWidget;
/**
* @brief
*
* QAction
* QAction
*/
class NM_RENDER_EXPORT nmVTKViewCommandController : public QObject
{
Q_OBJECT
public:
enum ViewCommand
{
ViewCommand_ZoomIn = 0x0001,
ViewCommand_ZoomOut = 0x0002,
ViewCommand_Fit = 0x0004,
ViewCommand_Top = 0x0008,
ViewCommand_Front = 0x0010,
ViewCommand_Right = 0x0020,
ViewCommand_Isometric = 0x0040,
ViewCommand_ResetRotationCenter = 0x0080,
ViewCommand_SaveImage = 0x0100,
ViewCommand_CopyImage = 0x0200,
ViewCommand_Print = 0x0400,
ViewCommand_PrintPreview = 0x0800
};
Q_DECLARE_FLAGS(ViewCommands, ViewCommand)
/**
* @param pContainer
* @param pParent Qt pContainer
*/
explicit nmVTKViewCommandController(
nmWxVTKRenderContainerWidget* pContainer,
QObject* pParent = nullptr);
virtual ~nmVTKViewCommandController();
/** @brief 设置当前视图对外提供的命令集合。 */
void setCapabilities(ViewCommands eCommands);
/** @brief 返回当前命令集合。 */
ViewCommands getCapabilities() const;
/** @brief 返回长期持有的 QAction调用方不得删除或修改其父对象。 */
QAction* getAction(ViewCommand eCommand) const;
/** @brief 将已启用的导航和复制动作加入工具栏,不创建新 QAction。 */
void populateToolBar(QToolBar* pToolBar) const;
/** @brief 按统一顺序构造右键菜单,并同步请求业务层追加扩展动作。 */
void populateContextMenu(QMenu* pMenu) const;
/** @brief 就绪状态启用命令,空、错误和加载状态统一禁用命令。 */
void setViewAvailable(bool bAvailable);
bool isViewAvailable() const;
signals:
/** @brief 在视图命令和打印命令之间同步追加业务 QAction。 */
void contextMenuAboutToShow(QMenu* pMenu) const;
private:
Q_DISABLE_COPY(nmVTKViewCommandController)
enum { ViewCommandCount = 12 };
QAction* createAction(ViewCommand eCommand,
const QString& sText,
const QString& sIconFile,
const char* pSlot);
int actionIndex(ViewCommand eCommand) const;
bool supports(ViewCommand eCommand) const;
void updateActionStates();
nmWxVTKRenderContainerWidget* m_pContainer; ///< 非所有权命令接收者。
QAction* m_pActions[ViewCommandCount]; ///< 本对象通过 Qt 父子关系拥有。
ViewCommands m_eCapabilities;
bool m_bViewAvailable;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(nmVTKViewCommandController::ViewCommands)
#endif // NMVTKVIEWCOMMANDCONTROLLER_H