ICS

QicsTable Documentation Set

QicsRegion.h

Go to the documentation of this file.
00001 /*********************************************************************
00002 **
00003 ** Copyright (C) 2002-2006 Integrated Computer Solutions, Inc
00004 ** All rights reserved.
00005 **
00006 ** This file is part of the QicsTable Product.
00007 **
00008 **********************************************************************/
00009 
00010 #ifndef _QicsRegion_H
00011 #define _QicsRegion_H
00012 
00013 #include <QRect>
00014 #include <QVector>
00015 
00016 #include <QicsNamespace.h>
00017 #include <QicsICell.h>
00018 
00019 
00030 
00031 
00034 
00035 
00036 class QICS_EXPORT QicsRegion : public QRect
00037 {
00038   public:
00044     QicsRegion(int begin_row, int begin_col, int end_row, int end_col)
00045         : QRect(begin_col, begin_row, end_col-begin_col+1, end_row-begin_row+1) {}
00046 
00052     QicsRegion(const QicsICell &begin_cell, const QicsICell &end_cell)
00053         : QRect(begin_cell.column(), begin_cell.row(),
00054         end_cell.column() - begin_cell.column() + 1,
00055         end_cell.row() - begin_cell.row() + 1) {}
00056 
00060     QicsRegion(void) : QRect() {}
00061   
00065     inline QicsICell startCell(void) const
00066     { return QicsICell(startRow(), startColumn()); }
00067 
00071     inline QicsICell endCell(void) const
00072     { return QicsICell(endRow(), endColumn()); }
00073 
00077     inline int startRow(void) const     { return top(); }
00081     inline int endRow(void) const       { return bottom(); }
00085     inline int startColumn(void) const  { return left(); }
00089     inline int endColumn(void) const    { return right(); }
00093     inline int numColumns(void) const   { return width(); }
00097     inline int numRows(void) const      { return height(); }
00098 
00102     inline void setStartCell(const QicsICell &cell)
00103     { setTop(cell.row()); setLeft(cell.column()); }
00104 
00108     inline void setEndCell(const QicsICell &cell)
00109     { setBottom(cell.row()); setRight(cell.column()); }
00110 
00114     inline void setStartRow(int val)    { setTop(val); }
00118     inline void setEndRow(int val)      { setBottom(val); }
00122     inline void setStartColumn(int val) { setLeft(val); }
00126     inline void setEndColumn(int val)   { setRight(val); }
00127 
00131     inline bool containsCell(const QicsICell &cell) const
00132     { return contains(cell.column(), cell.row()); }
00133 
00138     inline bool containsCell(int row, int col) const
00139     { return contains(col, row); }
00140 
00144     inline QicsRegion intersect(const QicsRegion &reg) const
00145     {
00146         QRect r = QRect::intersect(reg);
00147         return QicsRegion(r.top(), r.left(), r.bottom(), r.right());
00148     }
00149 
00153     inline bool isValid(void) const
00154     { 
00155         return ((top() >= 0) && (bottom() >= 0) &&
00156             (left()>= 0) && (right() >= 0) &&
00157             QRect::isValid());
00158     }
00159 
00164     inline void normalize() 
00165     {
00166         if (left() > right()) {
00167             int l = right();
00168             setRight(left());
00169             setLeft(l);
00170         }
00171         if (top() > bottom()) {
00172             int l = bottom();
00173             setBottom(top());
00174             setTop(l);
00175         }
00176     }
00177 };
00178 
00179 
00180 typedef QVector<QicsRegion> QicsRegionV;
00181 
00182 #endif /*_QicsRegion_H --- Do not add anything past this line */
00183  

All trademarks and copyrights on this page are properties of their respective owners.
The rest is copyright 1999-2006 Integrated Computer Solutions, Inc.