1 #include "RubberBandComboBox.h" 
   17       unsigned int defaultOption, 
bool showIndicatorColors) : 
QComboBox() {
 
   21     setDuplicatesEnabled(
false);
 
   23     setIconSize(QSize(24, 24));
 
   27     defaultOption = 
getDefault(defaultOption, bandingOptions);
 
   30     escapeKeyHit->setShortcut(Qt::Key_Escape);
 
   31     connect(escapeKeyHit, SIGNAL(triggered()), m_tool->rubberBandTool(), SLOT(escapeKeyPress()));
 
   32     addAction(escapeKeyHit);
 
   37     setToolTip(
"Select Measurement Type");
 
   39       "<b>Function:</b> This drop down will enable you to switch between drawing various shapes.";
 
   42     if((bandingOptions & 
Circle) == Circle) {
 
   43       QIcon circleIcon(
toolIconDir() + 
"/qview_circle.png");
 
   44       circleIcon.addFile(
toolIconDir() + 
"/qview_circle_active.png", QSize(24, 24), QIcon::Active);
 
   48       whatsThis += 
"<br><br>When <b>Circle</b> is selected, you can draw a perfect circle. To draw a circle, \ 
   49                      click at a corner of the circle, drag the mouse until the circle is the correct shape, and release the mouse \ 
   50                      to complete the circle.";
 
   52       if((defaultOption & Circle) == 
Circle) {
 
   58     if((bandingOptions & 
Ellipse) == Ellipse) {
 
   59       QIcon ellipseIcon(
toolIconDir() + 
"/qview_ellipse.png");
 
   60       ellipseIcon.addFile(
toolIconDir() + 
"/qview_ellipse_active.png", QSize(24, 24), QIcon::Active);
 
   64       whatsThis += 
"<br><br>When <b>Ellipse</b> is selected, you can draw an ellipse. To draw an ellipse, \ 
   65                      click at a corner of the ellipse, drag the mouse until the ellipse is the correct shape, and release the mouse \ 
   66                      to complete the ellipse.";
 
   68       if((defaultOption & Ellipse) == 
Ellipse) {
 
   74     if((bandingOptions & 
Rectangle) == Rectangle) {
 
   75       QIcon rectangleIcon(
toolIconDir() + 
"/qview_rectangle.png");
 
   76       rectangleIcon.addFile(
toolIconDir() + 
"/qview_rectangle_active.png", QSize(24, 24), QIcon::Active);
 
   80       whatsThis += 
"<br><br>When <b>Rectangle</b> is selected, you can draw a rectangle. To draw a rectangle, \ 
   81                      click a corner of the rectangle, drag the mouse until the rectangle is the correct size and shape, and release the mouse \ 
   82                      to complete the rectangle.";
 
   84       if((defaultOption & Rectangle) == 
Rectangle) {
 
   91       QIcon rotatedRectangleIcon(
toolIconDir() + 
"/qview_rotated_rectangle.png");
 
   95       whatsThis += 
"<br><br>When <b>Rotated Rectangle</b> is selected, you can draw a rectangle rotated about its center. To draw a rotated rectangle, \ 
   96                      click, drag the mouse to form the first side of the rectangle and determine it's rotation, and release the mouse. \ 
   97                      Now, the final side of the rotated rectangle should follow the mouse. \ 
   98                      Click again when the rotated rectangle is the correct size to complete the rotated rectangle.";
 
  101         whatsThis += 
" The data will be calculated starting from the initial (GREEN) side of the rotated rectangle and ending at the opposite \ 
  102                       side of the rotated rectangle.";
 
  111     if((bandingOptions & 
Polygon) == Polygon) {
 
  112       QIcon polygonIcon(
toolIconDir() + 
"/qview_polygon.png");
 
  116       whatsThis += 
"<br><br>When <b>Polygon</b> is selected, you can draw any closed polygon. To begin drawing a polygon, \ 
  117                      click where you want the start point. Now, click for any new vertices or click and drag the mouse to form irregular shapes. \ 
  118                      When completed, double click the final vertex and the figure will close.";
 
  120       if((defaultOption & Polygon) == 
Polygon) {
 
  126     if((bandingOptions & 
Line) == Line) {
 
  128       lineIcon.addFile(
toolIconDir() + 
"/qview_line_active.png", QSize(24, 24), QIcon::Active);
 
  132       whatsThis += 
"<br><br>When <b>Line</b> is selected, you can draw a line. " 
  133           "To draw a line, click the starting point of the line, drag the " 
  134           "mouse until the line is the correct length in the correct direction," 
  135           " and release the mouse.  To draw vertical or horizontal lines, press" 
  136           " and hold the control key while drawing your line";
 
  138       if((defaultOption & Line) == 
Line) {
 
  145       QIcon segmentedLineIcon(
toolIconDir() + 
"/qview_segmentedline.png");
 
  149       whatsThis += 
"<br><br>When <b>Segmented Line</b> is selected, you can draw any open polygon. To begin drawing a segmented line, \ 
  150                      click where you want the start point. Now, click for any new vertices or click and drag the mouse to form irregular shapes. \ 
  151                      When completed, double click the final vertex.";
 
  159     if((bandingOptions & 
Angle) == Angle) {
 
  161       angleIcon.addFile(
toolIconDir() + 
"/qview_angle.png", QSize(24, 24), QIcon::Normal);
 
  166       whatsThis += 
"<br><br>When <b>Angle</b> is selected, you can draw an angle from zero to 180 degrees. To draw an angle, \ 
  167                      click where the first corner should go, then click where the vertex should go. Finally, click where the final \ 
  168                      side of the angle should end to complete the angle.";
 
  170       if((defaultOption & Angle) == 
Angle) {
 
  175     connect(
this, SIGNAL(currentIndexChanged(
int)), 
this, SLOT(
selectionChanged(
int)));
 
  178     setWhatsThis(whatsThis);
 
  190     switch(itemData(index).
toInt()) {
 
  217         m_tool->rubberBandTool()->
disable();
 
  247     if(defaultOption == 0) {
 
  248       defaultOption = bandingOptions;
 
  255     while(((defaultOption >> (power + 1)) << (power + 1)) == defaultOption) {
 
  259     defaultOption = 1 << power;
 
  262     return defaultOption;
 
void showRectangle()
Enables the rectangle shape. 
 
void showLine()
Enables the line. 
 
void reset()
Resets the selection. 
 
void showCircle()
Enables the circle shape. 
 
QString toolIconDir() const 
Returns the icon directory. 
 
void showSegmentedLine()
Enables the segmented line shape. 
 
int toInt(const QString &string)
Global function to convert from a string to an integer. 
 
void showRotatedRectangle()
Enables the rotated rectangle shape. 
 
bool m_showIndicatorColors
Show colors? 
 
void showAngle()
Enables the angle shape. 
 
RubberBandComboBox(Tool *tool, unsigned int bandingOptions, unsigned int defaultOption, bool showIndicatorColors=false)
RubberBandComboBox constructor. 
 
void showPolygon()
Enables the polygon shape. 
 
void selectionChanged(int index)
This slot is called whenever the rubberband shape selection has changed. 
 
Defines an angle and provides unit conversions. 
 
unsigned int getDefault(unsigned int defaultOption, unsigned int bandingOptions)
This is used to figure out which option should be defaulted. 
 
void showEllipse()
Enables the ellipse shape. 
 
QStringList m_bandingOptionStrings
List of rubberband options.