valentina/container/vcontainer.cpp
2013-07-13 13:51:31 +03:00

44 lines
809 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "vcontainer.h"
#include <QDebug>
VContainer::VContainer(){
_id = 0;
}
VPointF VContainer::GetPoint(qint64 id) const{
if(points.contains(id)){
return points.value(id);
} else {
qCritical()<<"Не можу знайти id = "<<id<<" в таблиці.";
throw"Не можу знайти точку за id.";
}
return VPointF();
}
qint64 VContainer::AddPoint(const VPointF& point){
qint64 id = getNextId();
points[id] = point;
return id;
}
qint64 VContainer::getId(){
return _id;
}
qint64 VContainer::getNextId(){
++_id;
return _id;
}
void VContainer::UpdatePoint(qint64 id, const VPointF& point){
points[id] = point;
if(id > _id){
_id = id;
}
}
void VContainer::Clear(){
_id = 0;
points.clear();
}