33 #include <QGraphicsSceneMouseEvent>
34 #include <QItemSelection>
38 : QGraphicsScene(parent)
40 , m_instrumentModel(0)
44 , m_block_selection(false)
47 setSceneRect(QRectF(-1600, 0, 3200, 3200));
71 disconnect(
m_sampleModel, &SampleModel::modelAboutToBeReset,
this,
75 disconnect(
m_sampleModel, &SampleModel::rowsAboutToBeRemoved,
this,
86 connect(
m_sampleModel, &SampleModel::rowsAboutToBeRemoved,
this,
160 for (
int irow = first; irow <= last; ++irow) {
169 const QItemSelection& )
179 if (index.isValid()) {
181 it.value()->setSelected(
true);
183 it.value()->setSelected(
false);
200 QList<QGraphicsItem*> selected = selectedItems();
201 for (
int i = 0; i < selected.size(); ++i) {
202 IView* view =
dynamic_cast<IView*
>(selected[i]);
206 ASSERT(itemIndex.isValid());
209 QItemSelectionModel::Select);
234 parentView->
addView(childView, childCount++);
293 if (it.key() == item) {
294 IView* view = it.value();
295 view->setSelected(
false);
311 QList<IView*> views_which_will_be_deleted;
312 for (
auto index : indexes) {
313 views_which_will_be_deleted.append(
318 while (indexes.size()) {
319 QModelIndex current =
m_proxy->mapToSource(indexes.back());
326 for (
auto graphicsItem : selectedItems()) {
328 if (views_which_will_be_deleted.contains(connection->getParentView())
329 || views_which_will_be_deleted.contains(connection->getChildView()))
340 painter->setPen(QPen(Qt::darkBlue, 2, Qt::DashLine));
389 QGraphicsScene::dragMoveEvent(event);
408 QGraphicsScene::dropEvent(event);
415 if (mimeData->
getClassName().startsWith(
"FormFactor")) {
418 ffName.remove(
"FormFactor");
428 event->scenePos().x() - boundingRect.width() / 2);
430 event->scenePos().y() - boundingRect.height() / 2);
436 QPointF reference(event->scenePos().x() - boundingRect.width() / 2,
437 event->scenePos().y() - boundingRect.height() / 2);
448 const DesignerMimeData* mimeData = qobject_cast<const DesignerMimeData*>(event->mimeData());
453 event->setAccepted(
true);
462 QGraphicsScene::mouseMoveEvent(event);
469 rect.moveCenter(event->scenePos());
470 for (QGraphicsItem* item : items(rect)) {
479 QRectF boundingRect = itemsBoundingRect();
480 if (sceneRect().contains(boundingRect))
483 boundingRect.adjust(20.0, 20.0, 20.0, 20.0);
484 setSceneRect(sceneRect().united(boundingRect));
488 QGraphicsSceneDragDropEvent* event)
#define ASSERT(condition)
Defines class DesignerHelper.
Defines class DesignerMimeData.
Defines class DesignerScene.
Defines class FilterPropertyProxy.
Defines class GUIExamplesFactory.
Defines class InstrumentModel.
Defines class ItemFactory.
Defines class NodeEditorConnection.
Defines class NodeEditor.
Defines class ParticleCompositionItem.
Defines class ParticleCoreShellItem.
Defines class ParticleItem.
Defines class ParticleLayoutItem.
Defines class SampleBuilderFactory.
Defines class SampleModel.
Defines class SampleViewAligner.
Defines class SampleViewFactory.
view of ISampleNode's with rectangular shape and node functionality
int getInputPortIndex(NodeEditorPort *port)
static QPixmap getSceneBackground()
static QRectF getDefaultBoundingRect(const QString &name)
returns default bounding rectangle for given IvView name
static QRectF getDefaultMultiLayerRect()
Mime data for use with SampleDesigner drag and drop operations.
QString getClassName() const
void updateViews(const QModelIndex &parentIndex={}, IView *parentView=0)
runs through all items recursively and updates corresponding views
void deleteSelectedItems()
propagates deletion of views on the scene to the model
void selectionModeChangeRequest(int)
void deleteViews(const QModelIndex &parentIndex)
runs recursively through model's item and schedules view removal
void setInstrumentModel(InstrumentModel *instrumentModel)
SampleModel * m_sampleModel
void setMaterialModel(MaterialModel *materialModel)
QItemSelectionModel * m_selectionModel
QLineF m_layer_interface_line
Foreground line representing appropriate interface during layer's movement.
void onSessionSelectionChanged(const QItemSelection &, const QItemSelection &)
propagate selection from model to scene
void onRowsInserted(const QModelIndex &parent, int first, int last)
void alignViews()
aligns SampleView's on graphical canvas
void drawForeground(QPainter *painter, const QRectF &rect)
shows appropriate layer interface to drop while moving ILayerView
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
IView * getViewForItem(SessionItem *item)
QMap< SessionItem *, IView * > m_ItemToView
Correspondance of model's item and scene's view.
void setSampleModel(SampleModel *sampleModel)
const DesignerMimeData * checkDragEvent(QGraphicsSceneDragDropEvent *event)
returns proper MimeData if the object can be hadled by graphics scene
bool isMultiLayerNearby(QGraphicsSceneDragDropEvent *event)
Returns true if there is MultiLayerView nearby during drag event.
SampleViewAligner * m_aligner
void onSceneSelectionChanged()
propagate selection from scene to model
bool isLayerDragged() const
IView * addViewForItem(SessionItem *item)
adds view for item, if it doesn't exists
FilterPropertyProxy * m_proxy
void removeItemViewFromScene(SessionItem *item)
removes view from scene corresponding to given item
void dragMoveEvent(QGraphicsSceneDragDropEvent *event)
handles drag event LayerView can be dragged only over MultiLayerView MultiLayerView can be dragged bo...
void removeConnection(NodeEditorConnection *)
propagates break of connection between views on scene to the model
DesignerScene(QObject *parent=0)
void onRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
NodeEditor * m_nodeEditor
void onRowsRemoved(const QModelIndex &parent, int first, int last)
void dropEvent(QGraphicsSceneDragDropEvent *event)
Hadles drop event LayerView can be dropped on MultiLayerView only MultiLayerView can be droped on the...
InstrumentModel * m_instrumentModel
bool isAcceptedByMultiLayer(const DesignerMimeData *mimeData, QGraphicsSceneDragDropEvent *event)
void onEstablishedConnection(NodeEditorConnection *)
propagates connection established by NodeEditor to the model
void setSelectionModel(QItemSelectionModel *model, FilterPropertyProxy *proxy)
MaterialModel * m_materialModel
The FilterPropertyProxy class filters out all PropertyItem's and similar from SessionModel to have on...
static SessionItem * createSampleItems(const QString &name, SampleModel *sampleModel, MaterialModel *materialModel)
Populate sample model with.
static bool isValidExampleName(const QString &name)
Base class for LayerView and MultiLayerView Provides functionality for moving view on top of MultiLay...
parent class for graphic representation of all ISampleNode's
virtual SessionItem * getItem()
virtual void setParameterizedItem(SessionItem *item)
virtual void addView(IView *childView, int row=0)
ConnectableView * getChildView()
returns child view, i.e. the view which owns output port of given connection
NodeEditorPort * inputPort()
NodeEditorPort * outputPort()
ConnectableView * getParentView()
returns parent view, i.e. the view which owns input port of given connection
EPortType getPortType() const
The NodeEditor class implement for QGraphicsScene an editable schematic of the dependency graph,...
void connectionIsEstablished(NodeEditorConnection *)
void install(QGraphicsScene *scene)
void selectionModeChangeRequest(int)
static const QString T_CORE
static const QString T_SHELL
static const QString T_TRANSFORMATION
static const QString P_FORM_FACTOR
static const QString T_INTERFERENCE
Main model to hold sample items.
Makes alignment of sample droped on graphics scene.
void alignSample(SessionItem *item, QPointF reference={}, bool force_alignment=false)
Aligns sample starting from.
void smartAlign()
Spring based implified algorithm for smart alignment.
static IView * createSampleView(const QString &name)
static bool isValidType(const QString &name)
static const QString P_XPOS
static const QString P_YPOS
void setItemValue(const QString &tag, const QVariant &variant)
Directly set value of item under given tag.
SessionItem * setGroupProperty(const QString &groupTag, const QString &modelType) const
Set the current type of group item.
QString modelType() const
Get model type.
SessionItem * itemForIndex(const QModelIndex &index) const
T * insertItem(SessionItem *parent=nullptr, int row=-1, QString tag="")
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const
virtual int rowCount(const QModelIndex &parent) const
virtual bool removeRows(int row, int count, const QModelIndex &parent)
SessionItem * insertNewItem(QString model_type, SessionItem *parent_item=nullptr, int row=-1, QString tag="")
SessionItem * moveItem(SessionItem *item, SessionItem *new_parent=0, int row=-1, const QString &tag="")
Move given parameterized item to the new_parent at given row.
QModelIndex indexOfItem(SessionItem *item) const