88 lines
2.3 KiB
C++
88 lines
2.3 KiB
C++
/*
|
|
QAD - Qt ADvanced
|
|
|
|
Ivan Pelipenko peri4ko@yandex.ru
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef GRAPHIC_RANGES_H
|
|
#define GRAPHIC_RANGES_H
|
|
|
|
#include "graphic.h"
|
|
|
|
|
|
class QAD_GRAPHIC_EXPORT GraphicRanges: public Graphic {
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit GraphicRanges(QWidget * parent = 0);
|
|
~GraphicRanges();
|
|
|
|
struct QAD_GRAPHIC_EXPORT Range {
|
|
Range(double s = 0., double e = 0., QString n = QString(), QColor c = Qt::black) {
|
|
start = s;
|
|
end = e;
|
|
name = n;
|
|
color = c;
|
|
}
|
|
bool isEmpty() const { return qFuzzyIsNull(start - end); }
|
|
bool hasColor() const { return color != Qt::black; }
|
|
QString name;
|
|
QColor color;
|
|
double start;
|
|
double end;
|
|
};
|
|
|
|
int addRange(double start, double end, QString name, QColor color = Qt::black);
|
|
void replaceRange(int index, double start, double end);
|
|
Range removeRange(int index);
|
|
void clearRanges();
|
|
void clearRangesByColor(QColor c);
|
|
QList<Range> ranges() const { return ranges_; }
|
|
Range rangeAll() const;
|
|
Range rangeVisible() const;
|
|
bool isRangeRequested() const { return request; }
|
|
|
|
void setCurrentRange(double start, double end);
|
|
void clearCurrentRange();
|
|
Range currentRange() const;
|
|
|
|
void clear();
|
|
|
|
protected:
|
|
void drawRange(QPainter * p, const Range & r, QColor color);
|
|
|
|
QList<Range> ranges_;
|
|
QColor color_, color_cur;
|
|
double range_start, range_end;
|
|
bool range_sel, request;
|
|
|
|
private slots:
|
|
void onPaintEvent(QPainter * p);
|
|
void onMousePressEvent(QPointF p, int b);
|
|
void onMouseMoveEvent(QPointF p, int b);
|
|
void onMouseReleaseEvent(QPointF p, int b);
|
|
|
|
public slots:
|
|
void rangeRequest();
|
|
void cancelRangeRequest(bool with_nav = true);
|
|
|
|
signals:
|
|
void rangeSelected(double start, double end);
|
|
};
|
|
|
|
|
|
#endif
|