diff --git a/GUI/Views/SampleDesigner/DesignerScene.cpp b/GUI/Views/SampleDesigner/DesignerScene.cpp index c90fbe27efd7f5ef0ebb2931648307f67741818a..062ffa27d9c87b298e008e04716e6a088b55cf7b 100644 --- a/GUI/Views/SampleDesigner/DesignerScene.cpp +++ b/GUI/Views/SampleDesigner/DesignerScene.cpp @@ -424,41 +424,41 @@ void DesignerScene::dropEvent(QGraphicsSceneDragDropEvent* event) if (isAcceptedByMultiLayer(mimeData, event)) { // certain views can be dropped on MultiLayer and so will be processed there QGraphicsScene::dropEvent(event); + return; + } - } else { - // other views can be dropped on canvas anywhere - if (SampleViewFactory::isValidType(mimeData->getClassName())) { - - SessionGraphicsItem* new_item(nullptr); - if (mimeData->getClassName().startsWith("FormFactor")) { - ParticleItem* new_particle = m_sampleModel->insertItem<ParticleItem>(); - QString ffName = mimeData->getClassName(); - ffName.remove("FormFactor"); - new_particle->setFormFactor(ffName); - new_item = new_particle; - } else { - new_item = dynamic_cast<SessionGraphicsItem*>( - m_sampleModel->insertNewItem(mimeData->getClassName())); - } - - // propagating drop coordinates to SessionItem - QRectF boundingRect = DesignerHelper::getDefaultBoundingRect(new_item->modelType()); - new_item->setXPos(event->scenePos().x() - boundingRect.width() / 2); - new_item->setYPos(event->scenePos().y() - boundingRect.height() / 2); - clearSelection(); - selectItem(new_item); - } else if (GUIExamplesFactory::isValidExampleName(mimeData->getClassName())) { - SessionItem* topItem = GUIExamplesFactory::createSampleItems( - mimeData->getClassName(), m_sampleModel, m_materialModel); - QRectF boundingRect = DesignerHelper::getDefaultBoundingRect(topItem->modelType()); - QPointF reference(event->scenePos().x() - boundingRect.width() / 2, - event->scenePos().y() - boundingRect.height() / 2); - m_aligner->alignSample(topItem, reference, true); - clearSelection(); - selectItem(topItem, true); + // other views can be dropped on canvas anywhere + if (SampleViewFactory::isValidType(mimeData->getClassName())) { + SessionGraphicsItem* new_item(nullptr); + if (mimeData->getClassName().startsWith("FormFactor")) { + ParticleItem* new_particle = m_sampleModel->insertItem<ParticleItem>(); + QString ffName = mimeData->getClassName(); + ffName.remove("FormFactor"); + new_particle->setFormFactor(ffName); + new_item = new_particle; + } else { + new_item = dynamic_cast<SessionGraphicsItem*>( + m_sampleModel->insertNewItem(mimeData->getClassName())); } - adjustSceneRect(); + + // propagating drop coordinates to SessionItem + QRectF boundingRect = DesignerHelper::getDefaultBoundingRect(new_item->modelType()); + new_item->setXPos(event->scenePos().x() - boundingRect.width() / 2); + new_item->setYPos(event->scenePos().y() - boundingRect.height() / 2); + clearSelection(); + selectItem(new_item); + + } else if (GUIExamplesFactory::isValidExampleName(mimeData->getClassName())) { + SessionItem* topItem = GUIExamplesFactory::createSampleItems( + mimeData->getClassName(), m_sampleModel, m_materialModel); + QRectF boundingRect = DesignerHelper::getDefaultBoundingRect(topItem->modelType()); + QPointF reference(event->scenePos().x() - boundingRect.width() / 2, + event->scenePos().y() - boundingRect.height() / 2); + m_aligner->alignSample(topItem, reference, true); + clearSelection(); + selectItem(topItem, true); } + adjustSceneRect(); } //! returns proper MimeData if the object can be hadled by graphics scene