|
|
|
@ -7,6 +7,8 @@ |
|
|
|
|
#include "Connector.h" |
|
|
|
|
#include "Wire.h" |
|
|
|
|
#include "Part.h" |
|
|
|
|
#include "FileHandler.h" |
|
|
|
|
#include "Logic.h" |
|
|
|
|
|
|
|
|
|
#include "UndoCommands/AddPart.h" |
|
|
|
|
#include "UndoCommands/AddWire.h" |
|
|
|
@ -14,10 +16,6 @@ |
|
|
|
|
#include "UndoCommands/RemoveParts.h" |
|
|
|
|
#include "UndoCommands/RemoveWire.h" |
|
|
|
|
|
|
|
|
|
#include "FileHandler.h" |
|
|
|
|
|
|
|
|
|
#include "Logic.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Scene::Scene(QGraphicsView *parentGfxView, MainWindow *parentMainWindow) |
|
|
|
|
:m_parentMainWindow(parentMainWindow), m_parentGfxView(parentGfxView), m_logic(new Logic(this)), m_undoStack(new QUndoStack) |
|
|
|
@ -137,11 +135,6 @@ void Scene::moveParts(const QList<Part *>& parts, QPointF relPos) |
|
|
|
|
{ |
|
|
|
|
m_undoStack->push(new MoveParts(this, parts, relPos)); |
|
|
|
|
|
|
|
|
|
for(auto part : parts) |
|
|
|
|
{ |
|
|
|
|
part->m_oldPos = part->pos(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
m_parentMainWindow->changeMade(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -263,18 +256,11 @@ void Scene::removeConnectorsConnections(Connector *connector) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Scene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
|
void Scene::partMoved(QPointF delta) |
|
|
|
|
{ |
|
|
|
|
if (event->button() == Qt::LeftButton) |
|
|
|
|
{ |
|
|
|
|
QList<QGraphicsItem*> movedItems = selectedItems(); |
|
|
|
|
if(!movedItems.isEmpty() && !(((Part*)movedItems[0])->pos() == ((Part*)movedItems[0])->m_oldPos)) |
|
|
|
|
{ |
|
|
|
|
QList<Part*> movedParts; |
|
|
|
|
for(auto item : movedItems) |
|
|
|
|
movedParts.append((Part*)item); |
|
|
|
|
moveParts(movedParts, movedParts[0]->pos() - movedParts[0]->m_oldPos); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
QGraphicsScene::mouseReleaseEvent(event); |
|
|
|
|
QList<QGraphicsItem*> movedItems = selectedItems(); |
|
|
|
|
QList<Part*> movedParts; |
|
|
|
|
for(auto item : movedItems) |
|
|
|
|
movedParts.append((Part*)item); |
|
|
|
|
moveParts(movedParts, delta); |
|
|
|
|
} |
|
|
|
|