Namespaces | |
namespace | Private |
Functions | |
const QPair< QPointF, QPointF > | calculateDataBoundaries () const |
QBrush | downTrendCandlestickBrush (int column) const |
QBrush | downTrendCandlestickBrush () const |
QPen | downTrendCandlestickPen (int column) const |
QPen | downTrendCandlestickPen () const |
void | init () |
Initializes the diagram. | |
QPen | lowHighLinePen (int column) const |
QPen | lowHighLinePen () const |
const int | numberOfAbscissaSegments () const |
const int | numberOfOrdinateSegments () const |
void | paint (PaintContext *context) |
void | resize (const QSizeF &size) |
void | setDownTrendCandlestickBrush (int column, const QBrush &brush) |
void | setDownTrendCandlestickBrush (const QBrush &brush) |
void | setDownTrendCandlestickPen (int column, const QPen &pen) |
void | setDownTrendCandlestickPen (const QPen &pen) |
void | setLowHighLinePen (int column, const QPen &pen) |
void | setLowHighLinePen (const QPen &pen) |
void | setStockBarAttributes (int column, const StockBarAttributes &attr) |
void | setStockBarAttributes (const StockBarAttributes &attr) |
void | setThreeDBarAttributes (int column, const ThreeDBarAttributes &attr) |
Sets the 3D attributes for the bar (i.e. | |
void | setThreeDBarAttributes (const ThreeDBarAttributes &attr) |
Sets the 3D attributes for all bars (i.e. | |
void | setType (Type type) |
Switches between the supported types of stock charts, depending on type. | |
void | setUpTrendCandlestickBrush (int column, const QBrush &brush) |
void | setUpTrendCandlestickBrush (const QBrush &brush) |
void | setUpTrendCandlestickPen (int column, const QPen &pen) |
void | setUpTrendCandlestickPen (const QPen &pen) |
StockBarAttributes | stockBarAttributes (int column) const |
StockBarAttributes | stockBarAttributes () const |
StockDiagram (QWidget *parent, CartesianCoordinatePlane *plane) | |
ThreeDBarAttributes | threeDBarAttributes (int column) const |
Returns the 3D attributes for a bars (i.e. | |
ThreeDBarAttributes | threeDBarAttributes () const |
Returns the 3D attributes for all bars (i.e. | |
double | threeDItemDepth (const QModelIndex &index) const |
double | threeDItemDepth (int column) const |
StockDiagram::Type | type () const |
| |
QBrush | upTrendCandlestickBrush (int column) const |
QBrush | upTrendCandlestickBrush () const |
QPen | upTrendCandlestickPen (int column) const |
QPen | upTrendCandlestickPen () const |
~StockDiagram () |
const QPair<QPointF, QPointF> StockDiagram::calculateDataBoundaries | ( | ) | const |
Definition at line 340 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AbstractDiagram::attributesModelRootIndex(), KDChart::AttributesModel::columnCount(), d, and KDChart::AttributesModel::rowCount().
00341 { 00342 const int rowCount = attributesModel()->rowCount( attributesModelRootIndex() ); 00343 const int colCount = attributesModel()->columnCount( attributesModelRootIndex() ); 00344 qreal xMin = 0.0; 00345 qreal xMax = rowCount; 00346 qreal yMin = 0.0; 00347 qreal yMax = 0.0; 00348 for ( int row = 0; row < rowCount; row++ ) { 00349 for ( int col = 0; col < colCount; col++ ) { 00350 const CartesianDiagramDataCompressor::CachePosition pos( row, col ); 00351 const CartesianDiagramDataCompressor::DataPoint point = d->compressor.data( pos ); 00352 yMax = qMax( yMax, point.value ); 00353 yMin = qMin( yMin, point.value ); // FIXME: Can stock charts really have negative values? 00354 } 00355 } 00356 return QPair<QPointF, QPointF>( QPointF( xMin, yMin ), QPointF( xMax, yMax ) ); 00357 }
QBrush StockDiagram::downTrendCandlestickBrush | ( | int | column | ) | const |
QBrush StockDiagram::downTrendCandlestickBrush | ( | ) | const |
Definition at line 188 of file KDChartStockDiagram.cpp.
References d.
00189 { 00190 return d->downTrendCandlestickBrush; 00191 }
QPen StockDiagram::downTrendCandlestickPen | ( | int | column | ) | const |
QPen StockDiagram::downTrendCandlestickPen | ( | ) | const |
Definition at line 233 of file KDChartStockDiagram.cpp.
References d.
00234 { 00235 return d->downTrendCandlestickPen; 00236 }
void StockDiagram::init | ( | ) |
Initializes the diagram.
Definition at line 23 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), d, KDChart::StockDiagram::HighLowClose, and KDChart::AbstractDiagram::setPen().
Referenced by KDChart::AbstractArea::AbstractArea(), KDChart::AbstractAreaWidget::AbstractAreaWidget(), KDChart::AbstractAxis::AbstractAxis(), KDChart::AbstractCartesianDiagram::AbstractCartesianDiagram(), KDChart::AbstractDiagram::AbstractDiagram(), KDChart::AbstractPieDiagram::AbstractPieDiagram(), KDChart::BarDiagram::BarDiagram(), KDChart::CartesianAxis::CartesianAxis(), KDGantt::ConstraintModel::ConstraintModel(), KDGantt::GraphicsScene::GraphicsScene(), KDChart::HeaderFooter::HeaderFooter(), KDChart::Legend::Legend(), KDChart::LeveyJenningsAxis::LeveyJenningsAxis(), KDChart::LeveyJenningsDiagram::LeveyJenningsDiagram(), KDChart::LineDiagram::LineDiagram(), KDChart::PieDiagram::PieDiagram(), KDChart::Plotter::Plotter(), KDGantt::ProxyModel::ProxyModel(), KDChart::RingDiagram::RingDiagram(), StockDiagram(), KDGantt::SummaryHandlingProxyModel::SummaryHandlingProxyModel(), KDChart::TernaryLineDiagram::TernaryLineDiagram(), and KDChart::TernaryPointDiagram::TernaryPointDiagram().
00024 { 00025 d->diagram = this; 00026 d->compressor.setModel( attributesModel() ); 00027 00028 // Set properties to defaults 00029 d->type = HighLowClose; 00030 d->upTrendCandlestickBrush = QBrush( Qt::white ); 00031 d->downTrendCandlestickBrush = QBrush( Qt::black ); 00032 d->upTrendCandlestickPen = QPen( Qt::black ); 00033 d->downTrendCandlestickPen = QPen( Qt::black ); 00034 00035 d->lowHighLinePen = QPen( Qt::black ); 00036 00037 setPen( QPen( Qt::black ) ); 00038 }
QPen StockDiagram::lowHighLinePen | ( | int | column | ) | const |
QPen StockDiagram::lowHighLinePen | ( | ) | const |
Definition at line 156 of file KDChartStockDiagram.cpp.
References d.
00157 { 00158 return d->lowHighLinePen; 00159 }
const int StockDiagram::numberOfAbscissaSegments | ( | ) | const |
const int StockDiagram::numberOfOrdinateSegments | ( | ) | const |
void StockDiagram::paint | ( | PaintContext * | context | ) |
Definition at line 272 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AbstractDiagram::attributesModelRootIndex(), KDChart::StockDiagram::Candlestick, d, KDChart::StockDiagram::HighLowClose, KDChart::StockDiagram::OpenHighLowClose, KDChart::PaintContext::painter(), and KDChart::AttributesModel::rowCount().
00273 { 00274 // Clear old reverse mapping data and create new 00275 // reverse mapping scene 00276 d->reverseMapper.clear(); 00277 00278 PainterSaver painterSaver( context->painter() ); 00279 int rowCount = attributesModel()->rowCount( attributesModelRootIndex() ); 00280 for ( int row = 0; row < rowCount; row++ ) { 00281 CartesianDiagramDataCompressor::DataPoint low; 00282 CartesianDiagramDataCompressor::DataPoint high; 00283 CartesianDiagramDataCompressor::DataPoint open; 00284 CartesianDiagramDataCompressor::DataPoint close; 00285 CartesianDiagramDataCompressor::DataPoint volume; 00286 00287 if ( d->type == HighLowClose ) { 00288 const CartesianDiagramDataCompressor::CachePosition highPos( row, 0 ); 00289 const CartesianDiagramDataCompressor::CachePosition lowPos( row, 1 ); 00290 const CartesianDiagramDataCompressor::CachePosition closePos( row, 2 ); 00291 low = d->compressor.data( lowPos ); 00292 high = d->compressor.data( highPos ); 00293 close = d->compressor.data( closePos ); 00294 } else if ( d->type == OpenHighLowClose || d->type == Candlestick ) { 00295 const CartesianDiagramDataCompressor::CachePosition openPos( row, 0 ); 00296 const CartesianDiagramDataCompressor::CachePosition highPos( row, 1 ); 00297 const CartesianDiagramDataCompressor::CachePosition lowPos( row, 2 ); 00298 const CartesianDiagramDataCompressor::CachePosition closePos( row, 3 ); 00299 open = d->compressor.data( openPos ); 00300 low = d->compressor.data( lowPos ); 00301 high = d->compressor.data( highPos ); 00302 close = d->compressor.data( closePos ); 00303 } 00304 00305 switch( d->type ) { 00306 case HighLowClose: 00307 open.hidden = true; 00308 // Fall-through intended! 00309 case OpenHighLowClose: 00310 d->drawOHLCBar( open, high, low, close, context ); 00311 break; 00312 case Candlestick: 00313 d->drawCandlestick( open, high, low, close, context ); 00314 break; 00315 } 00316 } 00317 }
void StockDiagram::resize | ( | const QSizeF & | size | ) |
Definition at line 319 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::coordinatePlane(), d, KDChart::AbstractDiagram::setDataBoundariesDirty(), KDChart::AbstractCoordinatePlane::zoomFactorX(), and KDChart::AbstractCoordinatePlane::zoomFactorY().
00320 { 00321 d->compressor.setResolution( static_cast< int >( size.width() * coordinatePlane()->zoomFactorX() ), 00322 static_cast< int >( size.height() * coordinatePlane()->zoomFactorY() ) ); 00323 setDataBoundariesDirty(); 00324 }
void StockDiagram::setDownTrendCandlestickBrush | ( | int | column, | |
const QBrush & | brush | |||
) |
Definition at line 205 of file KDChartStockDiagram.cpp.
References d.
00206 { 00207 d->downTrendCandlestickBrushes[column] = brush; 00208 }
void StockDiagram::setDownTrendCandlestickBrush | ( | const QBrush & | brush | ) |
Definition at line 183 of file KDChartStockDiagram.cpp.
References d.
00184 { 00185 d->downTrendCandlestickBrush = brush; 00186 }
void StockDiagram::setDownTrendCandlestickPen | ( | int | column, | |
const QPen & | pen | |||
) |
Definition at line 250 of file KDChartStockDiagram.cpp.
References d.
00251 { 00252 d->downTrendCandlestickPens[column] = pen; 00253 }
void StockDiagram::setDownTrendCandlestickPen | ( | const QPen & | pen | ) |
Definition at line 228 of file KDChartStockDiagram.cpp.
References d.
00229 { 00230 d->downTrendCandlestickPen = pen; 00231 }
void StockDiagram::setLowHighLinePen | ( | int | column, | |
const QPen & | pen | |||
) |
Definition at line 161 of file KDChartStockDiagram.cpp.
References d.
00162 { 00163 d->lowHighLinePens[column] = pen; 00164 }
void StockDiagram::setLowHighLinePen | ( | const QPen & | pen | ) |
Definition at line 151 of file KDChartStockDiagram.cpp.
References d.
00152 { 00153 d->lowHighLinePen = pen; 00154 }
void StockDiagram::setStockBarAttributes | ( | int | column, | |
const StockBarAttributes & | attr | |||
) |
Definition at line 72 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AbstractDiagram::propertiesChanged(), KDChart::AttributesModel::setHeaderData(), and KDChart::StockBarAttributesRole.
00073 { 00074 attributesModel()->setHeaderData( 00075 column, Qt::Vertical, 00076 qVariantFromValue( attr ), 00077 StockBarAttributesRole ); 00078 emit propertiesChanged(); 00079 }
void StockDiagram::setStockBarAttributes | ( | const StockBarAttributes & | attr | ) |
Definition at line 58 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AbstractDiagram::propertiesChanged(), KDChart::AttributesModel::setModelData(), and KDChart::StockBarAttributesRole.
00059 { 00060 attributesModel()->setModelData( 00061 qVariantFromValue( attr ), 00062 StockBarAttributesRole ); 00063 emit propertiesChanged(); 00064 }
void StockDiagram::setThreeDBarAttributes | ( | int | column, | |
const ThreeDBarAttributes & | attr | |||
) |
Sets the 3D attributes for the bar (i.e.
candlestick) in certain column of the diagram
Note: Every column in a StockDiagram is represented by a row in the model
column | The column to set the 3D bar attributes for | |
attr | The 3D attributes to set |
Definition at line 123 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AbstractDiagram::propertiesChanged(), KDChart::AttributesModel::setHeaderData(), and KDChart::StockBarAttributesRole.
00124 { 00125 attributesModel()->setHeaderData( 00126 column, Qt::Vertical, 00127 qVariantFromValue( attr ), 00128 StockBarAttributesRole ); 00129 emit propertiesChanged(); 00130 }
void StockDiagram::setThreeDBarAttributes | ( | const ThreeDBarAttributes & | attr | ) |
Sets the 3D attributes for all bars (i.e.
candlesticks)
attr | The 3D attributes to set |
Definition at line 95 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AbstractDiagram::propertiesChanged(), KDChart::AttributesModel::setModelData(), and KDChart::ThreeDBarAttributesRole.
00096 { 00097 attributesModel()->setModelData( 00098 qVariantFromValue( attr ), 00099 ThreeDBarAttributesRole ); 00100 emit propertiesChanged(); 00101 }
void StockDiagram::setType | ( | Type | type | ) |
Switches between the supported types of stock charts, depending on type.
Definition at line 44 of file KDChartStockDiagram.cpp.
References d, and KDChart::AbstractDiagram::propertiesChanged().
void StockDiagram::setUpTrendCandlestickBrush | ( | int | column, | |
const QBrush & | brush | |||
) |
Definition at line 193 of file KDChartStockDiagram.cpp.
References d.
00194 { 00195 d->upTrendCandlestickBrushes[column] = brush; 00196 }
void StockDiagram::setUpTrendCandlestickBrush | ( | const QBrush & | brush | ) |
Definition at line 173 of file KDChartStockDiagram.cpp.
References d.
00174 { 00175 d->upTrendCandlestickBrush = brush; 00176 }
void StockDiagram::setUpTrendCandlestickPen | ( | int | column, | |
const QPen & | pen | |||
) |
Definition at line 238 of file KDChartStockDiagram.cpp.
References d.
00239 { 00240 d->upTrendCandlestickPens[column] = pen; 00241 }
void StockDiagram::setUpTrendCandlestickPen | ( | const QPen & | pen | ) |
Definition at line 218 of file KDChartStockDiagram.cpp.
References d.
00219 { 00220 d->upTrendCandlestickPen = pen; 00221 }
StockBarAttributes StockDiagram::stockBarAttributes | ( | int | column | ) | const |
Definition at line 81 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::StockDiagram::stockBarAttributes(), and KDChart::StockBarAttributesRole.
00082 { 00083 const QVariant attr( attributesModel()->headerData( 00084 column, Qt::Vertical, StockBarAttributesRole ) ); 00085 if ( attr.isValid() ) 00086 return qVariantValue<StockBarAttributes>( attr ); 00087 return stockBarAttributes(); 00088 }
StockBarAttributes StockDiagram::stockBarAttributes | ( | ) | const |
Definition at line 66 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AttributesModel::modelData(), and KDChart::StockBarAttributesRole.
00067 { 00068 return qVariantValue<StockBarAttributes>( 00069 attributesModel()->modelData( StockBarAttributesRole ) ); 00070 }
StockDiagram::StockDiagram | ( | QWidget * | parent, | |
CartesianCoordinatePlane * | plane | |||
) |
Definition at line 10 of file KDChartStockDiagram.cpp.
References init().
00011 : AbstractCartesianDiagram( new Private(), parent, plane ) 00012 { 00013 init(); 00014 }
ThreeDBarAttributes StockDiagram::threeDBarAttributes | ( | int | column | ) | const |
Returns the 3D attributes for a bars (i.e.
candlestick) in a certain column of the diagram
Note: Every column in a StockDiagram is represented by a row in the model
column | The column to get the 3D bar attributes for |
Definition at line 141 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::StockDiagram::threeDBarAttributes(), and KDChart::ThreeDBarAttributesRole.
00142 { 00143 const QVariant attr( attributesModel()->headerData( 00144 column, Qt::Vertical, ThreeDBarAttributesRole ) ); 00145 if ( attr.isValid() ) 00146 return qVariantValue<ThreeDBarAttributes>( attr ); 00147 return threeDBarAttributes(); 00148 }
ThreeDBarAttributes StockDiagram::threeDBarAttributes | ( | ) | const |
Returns the 3D attributes for all bars (i.e.
candlesticks)
Definition at line 108 of file KDChartStockDiagram.cpp.
References KDChart::AbstractDiagram::attributesModel(), KDChart::AttributesModel::modelData(), and KDChart::ThreeDBarAttributesRole.
00109 { 00110 return qVariantValue<ThreeDBarAttributes>( 00111 attributesModel()->modelData( ThreeDBarAttributesRole ) ); 00112 }
double StockDiagram::threeDItemDepth | ( | const QModelIndex & | index | ) | const |
Definition at line 333 of file KDChartStockDiagram.cpp.
00334 { 00335 Q_UNUSED( index ); 00336 //FIXME: Implement threeD functionality 00337 return 1.0; 00338 }
double StockDiagram::threeDItemDepth | ( | int | column | ) | const |
Definition at line 326 of file KDChartStockDiagram.cpp.
00327 { 00328 Q_UNUSED( column ); 00329 //FIXME: Implement threeD functionality 00330 return 1.0; 00331 }
StockDiagram::Type StockDiagram::type | ( | ) | const |
Definition at line 53 of file KDChartStockDiagram.cpp.
References d.
Referenced by StockDiagram::Private::closeValueColumn(), StockDiagram::Private::highValueColumn(), StockDiagram::Private::lowValueColumn(), StockDiagram::Private::openValueColumn(), and KDGantt::StyleOptionGanttItem::StyleOptionGanttItem().
00054 { 00055 return d->type; 00056 }
QBrush StockDiagram::upTrendCandlestickBrush | ( | int | column | ) | const |
QBrush StockDiagram::upTrendCandlestickBrush | ( | ) | const |
Definition at line 178 of file KDChartStockDiagram.cpp.
References d.
00179 { 00180 return d->upTrendCandlestickBrush; 00181 }
QPen StockDiagram::upTrendCandlestickPen | ( | int | column | ) | const |
QPen StockDiagram::upTrendCandlestickPen | ( | ) | const |
Definition at line 223 of file KDChartStockDiagram.cpp.
References d.
00224 { 00225 return d->upTrendCandlestickPen; 00226 }
StockDiagram::~StockDiagram | ( | ) |