File indexing completed on 2024-05-12 15:26:43

0001 /***************************************************************************
0002     File                 : Segments.h
0003     Project              : LabPlot
0004     Description          : Contain Methods to trace curve of image/plot
0005     --------------------------------------------------------------------
0006     Copyright            : (C) 2015 by Ankit Wagadre (wagadre.ankit@gmail.com)
0007  ***************************************************************************/
0008 /***************************************************************************
0009  *                                                                         *
0010  *  This program is free software; you can redistribute it and/or modify   *
0011  *  it under the terms of the GNU General Public License as published by   *
0012  *  the Free Software Foundation; either version 2 of the License, or      *
0013  *  (at your option) any later version.                                    *
0014  *                                                                         *
0015  *  This program is distributed in the hope that it will be useful,        *
0016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
0017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
0018  *  GNU General Public License for more details.                           *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the Free Software           *
0022  *   Foundation, Inc., 51 Franklin Street, Fifth Floor,                    *
0023  *   Boston, MA  02110-1301  USA                                           *
0024  *                                                                         *
0025  ***************************************************************************/
0026 
0027 #ifndef SEGMENTS_H
0028 #define SEGMENTS_H
0029 
0030 #include <QVector>
0031 
0032 class QImage;
0033 class DatapickerImage;
0034 class Segment;
0035 
0036 class Segments {
0037 
0038 public:
0039     explicit Segments(DatapickerImage*);
0040 
0041     void makeSegments(QImage&);
0042     void setSegmentsVisible(bool);
0043     void setAcceptHoverEvents(bool);
0044 
0045 private:
0046     DatapickerImage* m_image;
0047     QVector<Segment*> segments;
0048 
0049     void clearSegments();
0050     void loadSegment(Segment**, int);
0051     int adjacentRuns(bool*, int, int, int);
0052     Segment* adjacentSegment(Segment**, int, int, int);
0053     int adjacentSegments(Segment**, int, int, int);
0054     void matchRunsToSegments(int, int, bool*, Segment**, bool*, Segment**, bool*);
0055     void finishRun(bool*, bool*, Segment**, Segment**, int, int, int, int);
0056     void scrollSegment(Segment**, Segment**, int);
0057     void removeUnneededLines(Segment**, Segment**, int);
0058 };
0059 #endif