libodsstream
Library for mass spectrometry
Loading...
Searching...
No Matches
OdsColorScale Class Reference

#include <odscolorscale.h>

Public Member Functions

 OdsColorScale (const QString &cell_start_position, const QString &cell_stop_position)
 
 OdsColorScale (const OdsColorScale &other)
 
virtual ~OdsColorScale ()
 
void setCellRange (const QString &cell_start_position, const QString &cell_stop_position)
 set cell range to apply color scale
 
void setMinimumColor (const QColor &minimum_color)
 set minimum color of the color scale
 
void setMaximumColor (const QColor &maximum_color)
 set maximum color of the color scale
 

Protected Member Functions

bool isInSheet (const QString &sheet_name)
 
void writeConditionalFormat (QXmlStreamWriter *p_writer)
 

Private Member Functions

std::tuple< QString, QString > parseCellRange (const QString &cell_position)
 

Private Attributes

friend ContentXml
 
QString _sheet_name
 
QString _cell_start_position
 
QString _cell_stop_position
 
QColor _minimum_color = QColor("#0000ff")
 
QColor _maximum_color = QColor("#ff0000")
 
QColor _percentile_color = QColor("#ffffff")
 

Detailed Description

Definition at line 43 of file odscolorscale.h.

Constructor & Destructor Documentation

◆ OdsColorScale() [1/2]

OdsColorScale::OdsColorScale ( const QString &  cell_start_position,
const QString &  cell_stop_position 
)

Definition at line 41 of file odscolorscale.cpp.

43{
44 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
45 << cell_start_position;
46
47 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
48 << cell_stop_position;
49 setCellRange(cell_start_position, cell_stop_position);
50}
void setCellRange(const QString &cell_start_position, const QString &cell_stop_position)
set cell range to apply color scale

References setCellRange().

◆ OdsColorScale() [2/2]

OdsColorScale::OdsColorScale ( const OdsColorScale other)

◆ ~OdsColorScale()

OdsColorScale::~OdsColorScale ( )
virtual

Definition at line 62 of file odscolorscale.cpp.

63{
64}

Member Function Documentation

◆ isInSheet()

bool OdsColorScale::isInSheet ( const QString &  sheet_name)
protected

Definition at line 76 of file odscolorscale.cpp.

77{
78 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
79 << sheet_name << " " << _sheet_name;
80 if(_sheet_name == sheet_name)
81 {
82 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " OK";
83 return true;
84 }
85 return false;
86}

References _sheet_name.

◆ parseCellRange()

std::tuple< QString, QString > OdsColorScale::parseCellRange ( const QString &  cell_position)
private

Definition at line 154 of file odscolorscale.cpp.

155{
156 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
157 if(cell_position.isEmpty())
158 {
159 throw OdsException(
160 QObject::tr("error parsing cell range :\n empty cell position"));
161 }
162 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
163 << cell_position;
164 QRegularExpression reg_exp("^(.*)\\.([A-Z]+[0-9]+)$");
165 QRegularExpressionMatch reg_exp_match = reg_exp.match(cell_position);
166 if(reg_exp_match.hasMatch())
167 {
168 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__ << " "
169 << cell_position;
170 return std::make_tuple(reg_exp_match.capturedTexts().at(1),
171 reg_exp_match.capturedTexts().at(2));
172 }
173 else
174 {
175 throw OdsException(
176 QObject::tr("error parsing cell range :\n cell_position %1 does not "
177 "contains pattern ^(.*).([A-Z]+[0-9]+)$")
178 .arg(cell_position));
179 }
180}

Referenced by setCellRange().

◆ setCellRange()

void OdsColorScale::setCellRange ( const QString &  cell_start_position,
const QString &  cell_stop_position 
)

set cell range to apply color scale

Parameters
cell_start_positioncell position to start (Feuille1.C2)
cell_stop_positioncell position to stop (Feuille1.D4)

Definition at line 183 of file odscolorscale.cpp.

185{
186 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
187 if(cell_start_position.isEmpty() && cell_stop_position.isEmpty())
188 return; // this is not an ods doc writer
189 QString sheet_name;
190 std::tie(sheet_name, _cell_start_position) =
191 parseCellRange(cell_start_position);
192 _sheet_name = sheet_name;
193
194 std::tie(sheet_name, _cell_stop_position) =
195 parseCellRange(cell_stop_position);
196 //"Feuille1.C2:Feuille1.D4"
197 if(sheet_name != _sheet_name)
198 {
199 throw OdsException(
200 QObject::tr("error in OdsColorScale::setCellRange :\n start %1 and "
201 "stop %2 are not on the same sheet")
202 .arg(cell_start_position)
203 .arg(cell_stop_position));
204 }
205 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
206}
std::tuple< QString, QString > parseCellRange(const QString &cell_position)

References _cell_start_position, _cell_stop_position, _sheet_name, and parseCellRange().

Referenced by OdsColorScale().

◆ setMaximumColor()

void OdsColorScale::setMaximumColor ( const QColor &  maximum_color)

set maximum color of the color scale

Parameters
maximum_colormaximum color

Definition at line 213 of file odscolorscale.cpp.

214{
215 _maximum_color = maximum_color;
216}

References _maximum_color.

◆ setMinimumColor()

void OdsColorScale::setMinimumColor ( const QColor &  minimum_color)

set minimum color of the color scale

Parameters
minimum_colorminimum color

Definition at line 208 of file odscolorscale.cpp.

209{
210 _minimum_color = minimum_color;
211}

References _minimum_color.

◆ writeConditionalFormat()

void OdsColorScale::writeConditionalFormat ( QXmlStreamWriter *  p_writer)
protected

Definition at line 88 of file odscolorscale.cpp.

89{
90
91 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
92 QString sheet_name = _sheet_name;
93 if(sheet_name.contains(" "))
94 {
95 sheet_name = QString("&apos;%1&apos;").arg(sheet_name);
96 }
97
98
99 //<calcext:conditional-format
100 //calcext:target-range-address="Feuille1.C2:Feuille1.D4">
101 p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
102 "conditional-format");
103 p_writer->device()->write(
104 QString(" calcext:target-range-address=\"%1.%2:%1.%3\" ")
105 .arg(sheet_name)
108 .toUtf8());
109 // p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"),
110 // "target-range-address",QString("%1:%2").arg(cell_start_position).arg(cell_stop_position));
111
112 //<calcext:color-scale>
113 p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
114 "color-scale");
115 //<calcext:color-scale-entry calcext:value="0" calcext:type="minimum"
116 //calcext:color="#ff0000"/>
117 p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
118 "color-scale-entry");
119 p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"), "value", "0");
120 p_writer->writeAttribute(
121 MetaXml::getNamespaceURI("calcext"), "type", "minimum");
122 p_writer->writeAttribute(
123 MetaXml::getNamespaceURI("calcext"), "color", _minimum_color.name());
124 p_writer->writeEndElement();
125 //<calcext:color-scale-entry calcext:value="50" calcext:type="percentile"
126 //calcext:color="#ffffff"/>
127 p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
128 "color-scale-entry");
129 p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"), "value", "50");
130 p_writer->writeAttribute(
131 MetaXml::getNamespaceURI("calcext"), "type", "percentile");
132 p_writer->writeAttribute(
133 MetaXml::getNamespaceURI("calcext"), "color", _percentile_color.name());
134 p_writer->writeEndElement();
135 //<calcext:color-scale-entry calcext:value="0" calcext:type="maximum"
136 //calcext:color="#0000ff"/>
137 p_writer->writeStartElement(MetaXml::getNamespaceURI("calcext"),
138 "color-scale-entry");
139 p_writer->writeAttribute(MetaXml::getNamespaceURI("calcext"), "value", "0");
140 p_writer->writeAttribute(
141 MetaXml::getNamespaceURI("calcext"), "type", "maximum");
142 p_writer->writeAttribute(
143 MetaXml::getNamespaceURI("calcext"), "color", _maximum_color.name());
144 p_writer->writeEndElement();
145 //</calcext:color-scale>
146 p_writer->writeEndElement();
147 //</calcext:conditional-format>
148 p_writer->writeEndElement();
149 qDebug() << __FILE__ << " " << __FUNCTION__ << " " << __LINE__;
150}
static const QString & getNamespaceURI(const QString &xml_namespace)
Definition metaxml.cpp:32

References _cell_start_position, _cell_stop_position, _maximum_color, _minimum_color, _percentile_color, _sheet_name, and MetaXml::getNamespaceURI().

Member Data Documentation

◆ _cell_start_position

QString OdsColorScale::_cell_start_position
private

Definition at line 79 of file odscolorscale.h.

Referenced by OdsColorScale(), setCellRange(), and writeConditionalFormat().

◆ _cell_stop_position

QString OdsColorScale::_cell_stop_position
private

Definition at line 80 of file odscolorscale.h.

Referenced by OdsColorScale(), setCellRange(), and writeConditionalFormat().

◆ _maximum_color

QColor OdsColorScale::_maximum_color = QColor("#ff0000")
private

Definition at line 83 of file odscolorscale.h.

Referenced by OdsColorScale(), setMaximumColor(), and writeConditionalFormat().

◆ _minimum_color

QColor OdsColorScale::_minimum_color = QColor("#0000ff")
private

Definition at line 82 of file odscolorscale.h.

Referenced by OdsColorScale(), setMinimumColor(), and writeConditionalFormat().

◆ _percentile_color

QColor OdsColorScale::_percentile_color = QColor("#ffffff")
private

Definition at line 84 of file odscolorscale.h.

Referenced by OdsColorScale(), and writeConditionalFormat().

◆ _sheet_name

QString OdsColorScale::_sheet_name
private

Definition at line 78 of file odscolorscale.h.

Referenced by OdsColorScale(), isInSheet(), setCellRange(), and writeConditionalFormat().

◆ ContentXml

friend OdsColorScale::ContentXml
private

Definition at line 45 of file odscolorscale.h.


The documentation for this class was generated from the following files: