#ADD_SUBDIRECTORY (src/ModelAPI)
#ADD_SUBDIRECTORY (src/Model)
ADD_SUBDIRECTORY (src/XGUI)
-#ADD_SUBDIRECTORY (src/GeomModule)
+ADD_SUBDIRECTORY (src/GeomModule)
void GeomModule::createFeatures()
{
- int aPageId = myWorkshop->addWorkbench("Primitives");
- int aGroupId = myWorkshop->addGroup(aPageId);
- int aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Box", "Create Box", QIcon(":icons/box.png"), QKeySequence());
- aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Cylinder", "Create Cylinder", QIcon(":icons/cylinder.png"), QKeySequence());
- aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Disk", "Create Disk", QIcon(":icons/disk.png"), QKeySequence());
- aCommand = myWorkshop->addFeature(aPageId, aGroupId, "Torus", "Create Torus", QIcon(":icons/torus.png"), QKeySequence());
-
- aPageId = myWorkshop->addWorkbench("Operations");
+ IWorkbench* aPage = myWorkshop->addWorkbench("Primitives");
+ IMenuGroup* aGroup = aPage->addGroup();
+
+ IFeatureMenu* aCommand = aGroup->addFeature("new_part", "Part", "Creates a new part", QIcon(":pictures/part_ico.png"));
+ aCommand = aGroup->addFeature("new_point", "Point", "Create a new point", QIcon(":icons/point.png"));
+ aCommand = aGroup->addFeature("new_axis", "Axis", "Create a new axis", QIcon(":icons/axis.png"), QKeySequence());
+ aCommand = aGroup->addFeature("new_plane", "Plane", "Create a new plane", QIcon(":icons/plane.png"), QKeySequence());
+
+ //aGroup = aPage->addGroup();
+ aCommand = aGroup->addFeature("duplicate", "Duplicate", "Duplicate selected object", QIcon(":icons/duplicate.png"));
+ aCommand = aGroup->addFeature("remove", "Remove", "Remove selected object", QIcon(":icons/remove.png"));
+
+ aPage = myWorkshop->addWorkbench("Features");
+ aGroup = aPage->addGroup();
+
+ aCommand = aGroup->addFeature("extrusion", "Extrusion", "Make extrusion", QIcon(":icons/extrusion.png"));
+ aCommand = aGroup->addFeature("cut", "Cut", "Make cut", QIcon(":icons/cut.png"));
+ aCommand = aGroup->addFeature("fusion", "Fusion", "Make fusion", QIcon(":icons/fusion.png"));
+ aCommand = aGroup->addFeature("revolution", "Revolution", "Make revolution", QIcon(":icons/revol.png"));
+ aCommand = aGroup->addFeature("common", "Common", "Make common", QIcon(":icons/common.png"));
+
+ //aGroup = aPage->addGroup();
+ aCommand = aGroup->addFeature("import", "Import", "Make import", QIcon(":icons/import.png"));
}
\ No newline at end of file
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
- <file>icons/box.png</file>
- <file>icons/cylinder.png</file>
- <file>icons/disk.png</file>
- <file>icons/torus.png</file>
+ <file>icons/point.png</file>
+ <file>icons/plane.png</file>
+ <file>icons/axis.png</file>
+ <file>icons/duplicate.png</file>
+ <file>icons/remove.png</file>
+ <file>icons/extrusion.png</file>
+ <file>icons/cut.png</file>
+ <file>icons/fusion.png</file>
+ <file>icons/revol.png</file>
+ <file>icons/common.png</file>
+ <file>icons/import.png</file>
</qresource>
</RCC>
#include <QPushButton>
-XGUI_Command::XGUI_Command(QObject * parent) :
- QWidgetAction(parent)
+XGUI_Command::XGUI_Command(const QString& theId, QObject * parent) :
+ QWidgetAction(parent), myId(theId)
{
}
-XGUI_Command::XGUI_Command(const QIcon& icon, const QString& text, QObject* parent):
- QWidgetAction(parent)
+XGUI_Command::XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent):
+ QWidgetAction(parent), myId(theId)
{
setIcon(icon);
setText(text);
return aBtn;
}
return QWidgetAction::createWidget(theParent);
+}
+
+bool XGUI_Command::enabled() const
+{
+ return isEnabled();
+}
+
+void XGUI_Command::enable()
+{
+ setEnabled(true);
+}
+
+void XGUI_Command::disable()
+{
+ setEnabled(false);
+}
+
+void XGUI_Command::connectTo(const QObject* theResiver, const char* theSlot)
+{
+ connect(this, SIGNAL(triggered()), theResiver, theSlot);
}
\ No newline at end of file
#ifndef XGUI_Command_H
#define XGUI_Command_H
+#include "XGUI_Interfaces.h"
+
#include <QWidgetAction>
#define MIN_BUTTON_HEIGHT 18
#define MIN_BUTTON_WIDTH 40
-class XGUI_Command : public QWidgetAction
+class XGUI_Command : public QWidgetAction, public IFeatureMenu
{
Q_OBJECT
public:
- XGUI_Command(QObject * parent);
- XGUI_Command(const QIcon& icon, const QString& text, QObject* parent);
+ XGUI_Command(const QString& theId, QObject * parent);
+ XGUI_Command(const QString& theId, const QIcon& icon, const QString& text, QObject* parent);
~XGUI_Command();
+ virtual bool enabled() const;
+ virtual void enable();
+ virtual void disable();
+ virtual QString getId() const { return myId; }
+
+ virtual void connectTo(const QObject* theResiver, const char* theSlot);
+
protected:
virtual QWidget* createWidget(QWidget* theParent);
+
+private:
+ QString myId;
};
#endif
\ No newline at end of file
#include <QIcon>
#include <QKeySequence>
-class IWorkshop
+
+class IFeatureMenu
+{
+public:
+ virtual bool enabled() const = 0;
+ virtual void enable() = 0;
+ virtual void disable() = 0;
+ virtual QString getId() const = 0;
+ virtual void connectTo(const QObject* theResiver, const char* theSlot) = 0;
+};
+
+
+class IMenuGroup
+{
+public:
+ virtual IFeatureMenu* addFeature(const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ const QKeySequence& theKeys = QKeySequence()) = 0;
+};
+
+
+class IWorkbench
{
public:
- virtual int addWorkbench(const QString& theName) = 0;
+ virtual IMenuGroup* addGroup() = 0;
+};
- virtual int addGroup(int thePageId) = 0;
- virtual int addFeature(int thePageId, int theGroupId,
- const QString& theTitle, const QString& theTip,
- const QIcon& theIcon,
- const QKeySequence& theKeys = QKeySequence()) = 0;
+class IWorkshop
+{
+public:
+ virtual IWorkbench* addWorkbench(const QString& theName) = 0;
};
{
}
-int XGUI_MainMenu::addWorkbench(QString theTitle)
+IWorkbench* XGUI_MainMenu::addWorkbench(QString theTitle)
{
QDockWidget* aDoc = new QDockWidget(myDesktop);
aDoc->setFeatures(QDockWidget::DockWidgetVerticalTitleBar);
myMenuTabs.append(aDoc);
- return myMenuTabs.length() - 1;
+ return aPage;
}
-int XGUI_MainMenu::addGroup(int thePageId)
+IMenuGroup* XGUI_MainMenu::addGroup(int thePageId)
{
XGUI_Workbench* aPage = dynamic_cast<XGUI_Workbench*>(myMenuTabs[thePageId]->widget());
return aPage->addGroup();
}
-void XGUI_MainMenu::addCommand(int thePageId, int theGroupId, XGUI_Command* theCommand)
-{
- XGUI_Workbench* aPage = dynamic_cast<XGUI_Workbench*>(myMenuTabs[thePageId]->widget());
- aPage->addCommand(theGroupId, theCommand);
-}
-
#ifndef XGUI_MainMenu_H
#define XGUI_MainMenu_H
+#include "XGUI_Interfaces.h"
+
#include <QObject>
#include <QList>
XGUI_MainMenu(XGUI_MainWindow *parent);
virtual ~XGUI_MainMenu();
- int addWorkbench(QString theTitle);
-
- int addGroup(int thePageId);
+ IWorkbench* addWorkbench(QString theTitle);
- void addCommand(int thePageId, int theGroupId, XGUI_Command* theCommand);
+ IMenuGroup* addGroup(int thePageId);
private:
XGUI_MainWindow* myDesktop;
#include <QFormLayout>
#include <QDoubleSpinBox>
#include <QPushButton>
+#include <QScrollArea>
XGUI_MainWindow::XGUI_MainWindow(QWidget* parent) :
QMainWindow(parent), myObjectBrowser(0)
aDoc = new QDockWidget(this);
aDoc->setFeatures(QDockWidget::AllDockWidgetFeatures | QDockWidget::DockWidgetVerticalTitleBar);
- aDoc->setMinimumHeight(20);
+ aDoc->setMinimumHeight(0);
aDoc->setWindowTitle("Console");
QTextEdit* aTextEdt = new QTextEdit(aDoc);
aTextEdt->setText(">>>");
- aTextEdt->setMinimumHeight(20);
aDoc->setWidget(aTextEdt);
+ aTextEdt->setMinimumHeight(0);
addDockWidget(Qt::BottomDockWidgetArea, aDoc);
QMdiArea* aMdiArea = new QMdiArea(this);
QWidget* XGUI_MainWindow::getSubWindow()
{
QMdiSubWindow* aSub = new QMdiSubWindow(this);
- aSub->setGeometry(0,0, 600, 400);
QLabel* aLbl = new QLabel(aSub);
aLbl->setFrameStyle(QFrame::Sunken);
aLbl->setFrameShape(QFrame::Panel);
void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
{
- addWidget(theAction->requestWidget(this));
+ myActions[theAction] = theAction->requestWidget(this);
+ addWidget(myActions[theAction]);
}
void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt)
{
placeWidget(theWgt);
- myWidgets.append(theWgt);
}
void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
{
QWidget::resizeEvent(theEvent);
- if (myWidgets.size() == 0)
+ if (myActions.size() == 0)
return;
int aH = theEvent->size().height();
return;
myMaxRow = aMaxRow;
- QListIterator<QWidget*> aIt(myWidgets);
+ QListIterator<QWidget*> aIt(myActions.values());
myNewRow = 0;
myNewCol = 0;
while (aIt.hasNext()) {
placeWidget(aIt.next());
}
}
+
+IFeatureMenu* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ const QKeySequence& theKeys)
+{
+ XGUI_Command* aCommand = new XGUI_Command(theId, theIcon, theTitle, this);
+ aCommand->setToolTip(theTip);
+ if (!theKeys.isEmpty())
+ aCommand->setShortcut(theKeys);
+
+ addCommand(aCommand);
+ return aCommand;
+}
#ifndef XGUI_MenuGroupPanel_H
#define XGUI_MenuGroupPanel_H
+#include "XGUI_Interfaces.h"
+
#include <QWidget>
-#include <QList>
+#include <QMap>
class QGridLayout;
class XGUI_Command;
-class XGUI_MenuGroupPanel : public QWidget
+class XGUI_MenuGroupPanel : public QWidget, public IMenuGroup
{
Q_OBJECT
public:
explicit XGUI_MenuGroupPanel(QWidget *parent = 0);
- void addCommand(XGUI_Command* theAction);
+ virtual IFeatureMenu* addFeature(const QString& theId,
+ const QString& theTitle,
+ const QString& theTip,
+ const QIcon& theIcon,
+ const QKeySequence& theKeys = QKeySequence());
protected:
virtual void resizeEvent(QResizeEvent *theEvent);
private:
void addWidget(QWidget* theWgt);
void placeWidget(QWidget* theWgt);
+ void addCommand(XGUI_Command* theAction);
- QList<QWidget*> myWidgets;
+ QMap<XGUI_Command*, QWidget*> myActions;
QGridLayout* myLayout;
int myNewRow;
int myNewCol;
myLeftButton = new QPushButton("<", this);
myLeftButton->setMaximumWidth(14);
- //myLeftButton->setEnabled(false);
myLeftButton->setVisible(false);
connect(myLeftButton,SIGNAL(clicked()), this, SLOT(onLeftScroll()));
aMainLayout->addWidget(myLeftButton);
}
-int XGUI_Workbench::addGroup()
+IMenuGroup* XGUI_Workbench::addGroup()
{
if (!myLayout->isEmpty()) {
int aNb = myLayout->count();
addSeparator();
myLayout->addStretch();
myGroups.append(aGroup);
- return myGroups.size() - 1;
+ return aGroup;
}
void XGUI_Workbench::addSeparator()
myLayout->addWidget(aLine);
}
-void XGUI_Workbench::addCommand(int theGroupId, XGUI_Command* theCommand)
-{
- XGUI_MenuGroupPanel* aGroup = myGroups.at(theGroupId);
- aGroup->addCommand(theCommand);
-}
-
-
void XGUI_Workbench::resizeEvent(QResizeEvent* theEvent)
{
QWidget::resizeEvent(theEvent);
#ifndef XGUI_Workbench_H
#define XGUI_Workbench_H
+#include "XGUI_Interfaces.h"
+
#include <QWidget>
#include <QScrollArea>
#include <QList>
class XGUI_Command;
-class XGUI_Workbench : public QWidget
+class XGUI_Workbench : public QWidget, public IWorkbench
{
Q_OBJECT
public:
XGUI_Workbench(QWidget* theParent);
- int addGroup();
-
- void addCommand(int theGroupId, XGUI_Command* theCommand);
+ virtual IMenuGroup* addGroup();
private slots:
void onLeftScroll();
//******************************************************
void XGUI_Workshop::initMenu()
{
- int aPageId = addWorkbench(tr("HOME_MENU_TITLE"));
+ IWorkbench* aPage = addWorkbench(tr("HOME_MENU_TITLE"));
// File commands group
- int aGroupId = addGroup(aPageId);
+ IMenuGroup* aGroup = aPage->addGroup();
- XGUI_Command* aCommand;
+ IFeatureMenu* aCommand;
- //aCommand = createMenuCommand(aPageId, aGroupId, NEW_CMD, tr("NEW_MENU"), tr("NEW_MENU_TIP"),
- // QIcon(":pictures/new.png"), QKeySequence::New);
- //connect(aCommand, SIGNAL(triggered()), this, SLOT(onNew()));
+ aCommand = aGroup->addFeature("NEW_CMD", tr("NEW_MENU"), tr("NEW_MENU_TIP"),
+ QIcon(":pictures/new.png"), QKeySequence::New);
+ aCommand->connectTo(this, SLOT(onNew()));
- //aCommand = createMenuCommand(aPageId, aGroupId, OPEN_CMD, tr("OPEN_MENU"), tr("OPEN_MENU_TIP"),
- // QIcon(":pictures/open.png"), QKeySequence::Open);
- //connect(aCommand, SIGNAL(triggered()), this, SLOT(onOpen()));
+ aCommand = aGroup->addFeature("OPEN_CMD", tr("OPEN_MENU"), tr("OPEN_MENU_TIP"),
+ QIcon(":pictures/open.png"), QKeySequence::Open);
+ aCommand->connectTo(this, SLOT(onOpen()));
- aCommand = createMenuCommand(aPageId, aGroupId, SAVE_CMD, tr("SAVE_MENU"), tr("SAVE_MENU_TIP"),
- QIcon(":pictures/save.png"), QKeySequence::Save);
- connect(aCommand, SIGNAL(triggered()), this, SLOT(onSave()));
- aCommand->setEnabled(false);
+ aCommand = aGroup->addFeature("SAVE_CMD", tr("SAVE_MENU"), tr("SAVE_MENU_TIP"),
+ QIcon(":pictures/save.png"), QKeySequence::Save);
+ aCommand->connectTo(this, SLOT(onSave()));
+ aCommand->disable();
- aCommand = createMenuCommand(aPageId, aGroupId, SAVEAS_CMD, tr("SAVEAS_MENU"), tr("SAVEAS_MENU_TIP"),
- QIcon(":pictures/save.png"));
- connect(aCommand, SIGNAL(triggered()), this, SLOT(onSaveAs()));
- aCommand->setEnabled(false);
+ aCommand = aGroup->addFeature("SAVEAS_CMD", tr("SAVEAS_MENU"), tr("SAVEAS_MENU_TIP"),
+ QIcon(":pictures/save.png"));
+ aCommand->connectTo(this, SLOT(onSaveAs()));
+ aCommand->disable();
// Edit commands group
- //aGroupId = addGroup(aPageId);
+ //aGroup = aPage->addGroup();
- aCommand = createMenuCommand(aPageId, aGroupId, UNDO_CMD, tr("UNDO_MENU"), tr("UNDO_MENU_TIP"),
- QIcon(":pictures/undo.png"), QKeySequence::Undo);
+ aCommand = aGroup->addFeature("UNDO_CMD", tr("UNDO_MENU"), tr("UNDO_MENU_TIP"),
+ QIcon(":pictures/undo.png"), QKeySequence::Undo);
- aCommand = createMenuCommand(aPageId, aGroupId, REDO_CMD, tr("REDO_MENU"), tr("REDO_MENU_TIP"),
+ aCommand = aGroup->addFeature("REDO_CMD", tr("REDO_MENU"), tr("REDO_MENU_TIP"),
QIcon(":pictures/redo.png"), QKeySequence::Redo);
- //aCommand = createMenuCommand(aPageId, aGroupId, CUT_CMD, tr("CUT_MENU"), tr("CUT_MENU_TIP"),
- // QIcon(":pictures/cut.png"), QKeySequence::Cut);
+ aCommand = aGroup->addFeature("REBUILD_CMD", tr("REBUILD_MENU"), tr("REBUILD_MENU_TIP"),
+ QIcon(":pictures/rebuild.png"));
- //aCommand = createMenuCommand(aPageId, aGroupId, COPY_CMD, tr("COPY_MENU"), tr("COPY_MENU_TIP"),
- // QIcon(":pictures/copy.png"), QKeySequence::Copy);
-
- //aCommand = createMenuCommand(aPageId, aGroupId, PASTE_CMD, tr("PASTE_MENU"), tr("PASTE_MENU_TIP"),
- // QIcon(":pictures/paste.png"), QKeySequence::Paste);
-
- aCommand = createMenuCommand(aPageId, aGroupId, EXIT_CMD, tr("EXIT_MENU"), tr("EXIT_MENU_TIP"),
- QIcon(":pictures/close.png"), QKeySequence::Close);
- connect(aCommand, SIGNAL(triggered()), this, SLOT(onExit()));
-
- // Tests
- //aPageId = addWorkbench("Primitives");
- //aGroupId = addGroup(aPageId);
- //
- //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Box", "Create Box", QIcon(":pictures/box.png"));
- //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Cylinder", "Create Cylinder", QIcon(":pictures/cylinder.png"));
- //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Disk", "Create Disk", QIcon(":pictures/disk.png"));
- //aCommand = createMenuCommand(aPageId, aGroupId, LAST_CMD, "Torus", "Create Torus", QIcon(":pictures/torus.png"));
-
- //aPageId = addWorkbench("Operations");
+ aCommand = aGroup->addFeature("EXIT_CMD", tr("EXIT_MENU"), tr("EXIT_MENU_TIP"),
+ QIcon(":pictures/close.png"), QKeySequence::Close);
+ aCommand->connectTo(this, SLOT(onExit()));
}
//******************************************************
-XGUI_Command* XGUI_Workshop::createMenuCommand(int thePageId, int theGroupId, XCommandId theCmdId,
- const QString& theTitle, const QString& theTip,
- const QIcon& theIcon, const QKeySequence& theKeys)
-{
- XGUI_Command* aCommand = new XGUI_Command(theIcon, theTitle, this);
- aCommand->setToolTip(theTip);
- if (!theKeys.isEmpty())
- aCommand->setShortcut(theKeys);
- addCommand(theCmdId, thePageId, theGroupId, aCommand);
- return aCommand;
-}
-
-//******************************************************
-int XGUI_Workshop::addWorkbench(const QString& theName)
+IWorkbench* XGUI_Workshop::addWorkbench(const QString& theName)
{
XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
return aMenuBar->addWorkbench(theName);
}
-//******************************************************
-int XGUI_Workshop::addGroup(int thePageId)
-{
- XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
- return aMenuBar->addGroup(thePageId);
-}
-
-//******************************************************
-void XGUI_Workshop::addCommand(XCommandId theCommandId, int thePageId, int theGroupId, XGUI_Command* theCommand)
-{
- XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
- aMenuBar->addCommand(thePageId, theGroupId, theCommand);
- myCommands[theCommandId] = theCommand;
-}
-
-//******************************************************
-XGUI_Command* XGUI_Workshop::command(XCommandId theId) const
-{
- if (myCommands.contains(theId))
- return myCommands[theId];
- return 0;
-}
-
//******************************************************
void XGUI_Workshop::onExit()
{
return true;
}
-//******************************************************
-int XGUI_Workshop::addFeature(int thePageId, int theGroupId,
- const QString& theTitle, const QString& theTip,
- const QIcon& theIcon,
- const QKeySequence& theKeys)
-{
- return (int) createMenuCommand(thePageId, theGroupId, LAST_CMD, theTitle, theTip, theIcon, theKeys);
-}
class XGUI_Command;
class XGUI_Module;
-class XGUI_Workshop: public QObject, IWorkshop
+class XGUI_Workshop: public QObject, public IWorkshop
{
Q_OBJECT
public:
- enum XCommandId {
- NEW_CMD,
- OPEN_CMD,
- SAVE_CMD,
- SAVEAS_CMD,
- EXIT_CMD,
- UNDO_CMD,
- REDO_CMD,
- COPY_CMD,
- CUT_CMD,
- PASTE_CMD,
- LAST_CMD
- };
XGUI_Workshop();
virtual ~XGUI_Workshop();
void startApplication();
- XGUI_Command* command(XCommandId theId) const;
-
XGUI_MainWindow* mainWindow() const { return myMainWindow; }
- virtual int addWorkbench(const QString& theName);
- virtual int addGroup(int thePageId);
- virtual int addFeature(int thePageId, int theGroupId,
- const QString& theTitle, const QString& theTip,
- const QIcon& theIcon,
- const QKeySequence& theKeys = QKeySequence());
-
+ virtual IWorkbench* addWorkbench(const QString& theName);
public slots:
void onNew();
IModule* loadModule(const QString& theModule);
bool activateModule();
- void addCommand(XCommandId theCommandId, int thePageId, int theGroupId, XGUI_Command* theCommand);
- XGUI_Command* createMenuCommand(int thePageId, int theGroupId, XCommandId theCmdId,
- const QString& theTitle, const QString& theTip,
- const QIcon& theIcon = QIcon(), const QKeySequence& theKeys = QKeySequence());
-
- QMap<int, XGUI_Command*> myCommands;
-
XGUI_MainWindow* myMainWindow;
};
<source>PASTE_MENU_TIP</source>
<translation>Paste copied object</translation>
</message>
+ <message>
+ <source>REBUILD_MENU</source>
+ <translation>Rebuild</translation>
+ </message>
+ <message>
+ <source>REBUILD_MENU_TIP</source>
+ <translation>Rebuild data objects</translation>
+ </message>
</context>
<context>
<name>XGUI_MainWindow</name>
<file>pictures/open.png</file>
<file>pictures/save.png</file>
<file>pictures/close.png</file>
- <file>pictures/copy.png</file>
- <file>pictures/cut.png</file>
- <file>pictures/paste.png</file>
<file>pictures/redo.png</file>
<file>pictures/undo.png</file>
+ <file>pictures/rebuild.png</file>
<!--For test purposes-->
<file>pictures/ViewPort.png</file>