1
/***************************************************************************
4
--------------------------------------------------------------------
5
Copyright : (C) 2006 by Ion Vasilief, Tilman Benkert
6
Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net
7
Description : Plot symbol combo box
9
***************************************************************************/
11
/***************************************************************************
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
18
* This program is distributed in the hope that it will be useful, *
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21
* GNU General Public License for more details. *
23
* You should have received a copy of the GNU General Public License *
24
* along with this program; if not, write to the Free Software *
25
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26
* Boston, MA 02110-1301 USA *
28
***************************************************************************/
29
#include "SymbolBox.h"
35
const QwtSymbol::Style SymbolBox::symbols[] = {
54
SymbolBox::SymbolBox(bool rw, QWidget *parent) : QComboBox(rw, parent)
59
SymbolBox::SymbolBox(QWidget *parent) : QComboBox(parent)
64
void SymbolBox::init()
66
QPixmap icon = QPixmap(14, 14);
67
icon.fill ( QColor (Qt::gray) );
68
const QRect r= QRect(0, 0, 14, 14);
70
p.setBackgroundColor(QColor(Qt::gray));
72
p.setBrush(QBrush(QColor(Qt::white)));
74
this->insertItem(tr("No Symbol" ));
76
symb.setStyle (QwtSymbol::Ellipse);
78
this->insertItem(icon, tr("Ellipse" ));
80
symb.setStyle (QwtSymbol::Rect);
83
this->insertItem(icon,tr("Rectangle"));
85
symb.setStyle (QwtSymbol::Diamond);
88
this->insertItem(icon,tr("Diamond"));
90
symb.setStyle (QwtSymbol::Triangle);
93
this->insertItem(icon,tr("Triangle"));
95
symb.setStyle (QwtSymbol::DTriangle);
98
this->insertItem(icon,tr("Down Triangle"));
100
symb.setStyle (QwtSymbol::UTriangle);
103
this->insertItem(icon,tr("Up Triangle"));
105
symb.setStyle (QwtSymbol::LTriangle);
108
this->insertItem(icon,tr("Left Triangle"));
110
symb.setStyle (QwtSymbol::RTriangle);
113
this->insertItem(icon,tr("Right Triangle"));
115
symb.setStyle (QwtSymbol::Cross);
118
this->insertItem(icon,tr("Cross"));
120
symb.setStyle (QwtSymbol::XCross);
123
this->insertItem(icon,tr("Diagonal Cross"));
125
symb.setStyle (QwtSymbol::HLine);
128
this->insertItem(icon,tr("Horizontal Line"));
130
symb.setStyle (QwtSymbol::VLine);
133
this->insertItem(icon,tr("Vertical Line"));
135
symb.setStyle (QwtSymbol::Star1);
138
this->insertItem(icon,tr("Star 1"));
140
symb.setStyle (QwtSymbol::Star2);
143
this->insertItem(icon,tr("Star 2"));
145
symb.setStyle (QwtSymbol::Hexagon);
148
this->insertItem(icon,tr("Hexagon"));
153
void SymbolBox::setStyle(const QwtSymbol::Style& style)
155
const QwtSymbol::Style*ite = std::find(symbols, symbols + sizeof(symbols), style);
156
if (ite == symbols + sizeof(symbols))
157
this->setCurrentIndex(0);
159
this->setCurrentIndex(ite - symbols);
162
QwtSymbol::Style SymbolBox::selectedSymbol() const
164
size_t i = this->currentItem();
165
if (i < sizeof(symbols))
166
return symbols[this->currentItem()];
168
return QwtSymbol::NoSymbol;
171
int SymbolBox::symbolIndex(const QwtSymbol::Style& style)
173
const QwtSymbol::Style*ite = std::find(symbols, symbols + sizeof(symbols), style);
174
if (ite == symbols + sizeof(symbols))
177
return (ite - symbols);
180
QwtSymbol::Style SymbolBox::style(int index)
182
if (index < (int)sizeof(symbols))
183
return symbols[index];
185
return QwtSymbol::NoSymbol;