File indexing completed on 2024-12-22 04:12:56

0001 /*
0002  *  SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "KisFreehandStrokeInfo.h"
0008 
0009 #include <kis_painter.h>
0010 #include <kis_distance_information.h>
0011 
0012 
0013 KisFreehandStrokeInfo::KisFreehandStrokeInfo()
0014     : painter(new KisPainter())
0015     , dragDistance(new KisDistanceInformation())
0016 {
0017 }
0018 
0019 KisFreehandStrokeInfo::KisFreehandStrokeInfo(const KisDistanceInformation &startDist)
0020     : painter(new KisPainter())
0021     , dragDistance(new KisDistanceInformation(startDist))
0022 {
0023 }
0024 
0025 KisFreehandStrokeInfo::KisFreehandStrokeInfo(KisFreehandStrokeInfo *rhs, int levelOfDetail)
0026     : painter(new KisPainter())
0027     , dragDistance(new KisDistanceInformation(*rhs->dragDistance, levelOfDetail))
0028     , m_parentStrokeInfo(rhs)
0029 {
0030     rhs->m_childStrokeInfo = this;
0031 }
0032 
0033 KisFreehandStrokeInfo::~KisFreehandStrokeInfo()
0034 {
0035     if (m_parentStrokeInfo) {
0036         m_parentStrokeInfo->m_childStrokeInfo = 0;
0037     }
0038 
0039     delete(painter);
0040     delete(dragDistance);
0041 }
0042 
0043 KisDistanceInformation* KisFreehandStrokeInfo::buddyDragDistance()
0044 {
0045     return m_childStrokeInfo ? m_childStrokeInfo->dragDistance : 0;
0046 }