This class provides a basic implementation of an interactor system and a right click context menu
AbstractView can be separated into 3 parts :
Interactor functions : with in one hand get, push, pop, reset and remove interactor functions. And in other hand constructInteractorsMap and constructInteractorsActionList
In constructInteractorsMap you have to construct Chain-of-responsability of interactors and store it in interactorsMap variable : An interactor is a list of basic interactor. For example in Tulip createEdge interactor is the list of createNodeInteractor and createEdgeInteractor, if the user click on an node, the createEdgeInteractor catch signal and begin an edge and if user doesn'nt click on node createEdgeInteractor doesn't catch the signal and createNodeNode catch it.
So in constrcutInteractorsMap you have a code like this :
interactorsMap["addEdge"].push_back(interactors.get(InteractorManager::getInst().interactorId("MouseNodeBuilder"))); interactorsMap["addEdge"].push_back(interactors.get(InteractorManager::getInst().interactorId("MouseEdgeBuilder")));
The name of interactor ("addEdge" in this example) must be the same in constructInteractorsActionList function. In this function you contruct list of QAction who will be add to graphToolBar
An example of implementation of this function is :
interactorsActionList.push_back(new QAction(QIcon(":/i_addedge.png"),"addEdge",this));
Finaly when the user click on an interactor in graphToolBar the installInteractor function is call with in parameter the QAction
An example of implementation of installInteractor function is :
resetInteractors(interactorsMap[action->text().toStdString()]);
ContextMenu functions :
In this part you have 3 different functions :
buildContextMenu function : here you construct your menu, to do that you add QMenu in contextMenu parameters, for example :
contextMenu->addMenu(new QMenu("viewMenu"));
computeContextMenu function : this function is call when the user click on a menu in context menu. In this function you have to threat this action
Finaly you have specificEventFilter function : this function is call before all others function if the user move/click the mouse. You have to implement (if you want) your specific mouse mechanism on this function
Widget function : AbstractView automaticaly construct a QWidget who will be returned by construct function so in your constrcut function you will be have something like this :
QWidget *YouViewClass::construct(QWidget *parent) { QWidget *widget=GlMainView::construct(parent); Qwidget *yourWidget=new QWidget; ... setCentralWidget(yourWidget); return widget; }