Initial Commit
This commit is contained in:
42
UndoCommands/AddPart.cpp
Normal file
42
UndoCommands/AddPart.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "AddPart.h"
|
||||
|
||||
#include "RemoveWire.h"
|
||||
|
||||
#include "../Part.h"
|
||||
#include "../Connector.h"
|
||||
#include "../Scene.h"
|
||||
#include "../Logic.h"
|
||||
#include "../Parts/IntegratedCircuit.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
AddPart::AddPart(Scene* scene, PartType::PartType partType, QPointF pos, QString icFilename)
|
||||
:m_scene(scene), m_partType(partType), m_pos(pos), m_icFilename(icFilename)
|
||||
{
|
||||
setText("Add Part");
|
||||
}
|
||||
|
||||
AddPart::~AddPart()
|
||||
{
|
||||
m_scene->m_logic->deletePart(m_part);
|
||||
}
|
||||
|
||||
void AddPart::redo()
|
||||
{
|
||||
if(!m_part)
|
||||
{
|
||||
if(m_partType == PartType::IntegratedCircuit)
|
||||
m_part = m_scene->m_logic->createIC(m_icFilename, m_pos);
|
||||
else
|
||||
m_part = m_scene->m_logic->createPart(m_partType, m_pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_scene->startTrackingPart(m_part);
|
||||
}
|
||||
}
|
||||
|
||||
void AddPart::undo()
|
||||
{
|
||||
m_scene->stopTrackingPart(m_part);
|
||||
}
|
||||
Reference in New Issue
Block a user