File indexing completed on 2024-12-01 06:35:36
0001 /* 0002 SPDX-FileCopyrightText: 2007 James B. Bowlin <bowlin@mindspring.com> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #pragma once 0007 0008 #include <QPointF> 0009 #include <QString> 0010 0011 class LineList; 0012 class Projector; 0013 class SkyLabeler; 0014 0015 /** 0016 * @class LabelListIndex 0017 * An abstract parent class to be inherited by Ecliptic and Equator. 0018 * 0019 * @author James B. Bowlin 0020 * @version 0.1 0021 */ 0022 class LineListLabel 0023 { 0024 public: 0025 explicit LineListLabel(const QString &text); 0026 0027 enum 0028 { 0029 TopCandidate, 0030 BotCandidate, 0031 LeftCandidate, 0032 RightCandidate 0033 }; 0034 0035 /** @short prepare the context for selecting label position candidates. */ 0036 void reset(); 0037 0038 /** 0039 * @short draw the label if any. Is currently called at the bottom of draw() but that call could 0040 * be removed and it could be called externally AFTER draw() has been called so draw() can set 0041 * up the label position candidates. 0042 */ 0043 void draw(); 0044 0045 void updateLabelCandidates(qreal x, qreal y, LineList *lineList, int i); 0046 0047 private: 0048 /** 0049 * @short This routine does two things at once. It returns the QPointF 0050 * corresponding to pointList[i] and also computes the angle using 0051 * pointList[i] and pointList[i-1] therefore you MUST ensure that: 0052 * 0053 * 1 <= i < pointList.size(). 0054 */ 0055 QPointF angleAt(const Projector *proj, LineList *list, int i, double *angle); 0056 0057 const QString m_text; 0058 SkyLabeler *m_skyLabeler { nullptr }; 0059 0060 // these two arrays track/contain 4 candidate points 0061 int m_labIndex[4] { 0, 0, 0, 0 }; 0062 LineList *m_labList[4] { nullptr, nullptr, nullptr, nullptr }; 0063 0064 float m_marginLeft { 0 }; 0065 float m_marginRight { 0 }; 0066 float m_marginTop { 0 }; 0067 float m_marginBot { 0 }; 0068 float m_farLeft { 0 }; 0069 float m_farRight { 0 }; 0070 float m_farTop { 0 }; 0071 float m_farBot { 0 }; 0072 };