00001 #include "selectionset.h" 00002 #include "TraceLog.h" 00003 00004 SelectionSet::SelectionSet() { 00005 resetBox(); 00006 } 00007 00008 SelectionSet::~SelectionSet() {;} 00009 00010 /* 00011 * Overload [] to make selection set behave like 00012 * an array of SelObjs. 00013 * Return the information about the selected object 00014 * as stored in the list at index iobj. Useful for 00015 * iterating through all the selected vector objects. 00016 * 00017 * @param iobj index into the array of selected objects. 00018 * 00019 * @return SelObj is the information for a single selected 00020 * object in the list of all the objects the user has 00021 * selected on the screen. 00022 */ 00023 SelectionSet::SelObj& SelectionSet::operator[]( int iobj ) { 00024 return mSelObj[iobj]; 00025 } 00026 00027 /* 00028 * Deselect all the vector objects. 00029 */ 00030 void SelectionSet::clear() { 00031 mSelObj.clear(); 00032 //emit selectionChanged() ; 00033 } 00034 00035 /* 00036 * How many vector objects are in the selection list? 00037 * 00038 * @return The number of vector objects in the selection list. 00039 */ 00040 int SelectionSet::size() { 00041 return mSelObj.size(); 00042 } 00043 00044 /* 00045 * Add a new object to the list of vector objects 00046 * selected by the user. 00047 * 00048 * @param obj a single vector object to add to the selection list. 00049 */ 00050 void SelectionSet::add( SelObj &obj ) { 00051 mSelObj.push_back( obj ); 00052 // emit selectionChanged() ; 00053 } 00054 00055 /* 00056 * Get the structure holding the information about the 00057 * selection boundary the user has defined. 00058 * 00059 * @return structure holding the information about the 00060 * selection boundary the user has defined. 00061 */ 00062 SelectionSet::SelBox& SelectionSet::selBox() { 00063 return mBox; 00064 } 00065 00066 /* 00067 * Set the status of the user defining a selection boundary. 00068 * Change the status of whether or not the user is 00069 * defining (or has defined) a boundary for selecting 00070 * vector objects. 00071 * 00072 * @param sel boolean 00073 * true: selection boundary is being set or has been set 00074 * false: no selection boundary 00075 */ 00076 void SelectionSet::setSelecting( bool sel ) { 00077 mSelecting = sel; 00078 } 00079 00080 /* 00081 * Is a selection boundary being set or has it been 00082 * set? 00083 * 00084 * @return true or false 00085 */ 00086 bool SelectionSet::isSelecting( ) { 00087 return mSelecting; 00088 } 00089 00090 /* 00091 * Reset the selection boundary. 00092 * Wipe out the selection boundary and set its status 00093 * to "no selection" (mSelecting = false). 00094 */ 00095 void SelectionSet::resetBox() { 00096 mBox.x = mBox.y = mBox.w = mBox.h = 0; 00097 mSelecting = false; 00098 } 00099 00100 /* 00101 * Remove vector object "i" from list of selected objects. 00102 * 00103 * @param i index of object to remove from list 00104 */ 00105 void SelectionSet::erase( int i ) { 00106 mSelObj.erase( mSelObj.begin() + i ); 00107 emit selectionChanged() ; 00108 } 00109 00110 /* 00111 * Is this object selected? 00112 * Is this object on the list of selected objects? 00113 * 00114 * @param iobj an object to look for in list of selected objects 00115 * 00116 * @return whether or not the object is selected 00117 */ 00118 bool SelectionSet::isSelObj( int iobj ) { 00119 for ( unsigned int isel=0; isel < mSelObj.size(); isel++ ) { 00120 if ( mSelObj[isel].obj == iobj ) 00121 return true; 00122 } 00123 return false; 00124 } 00125 00126 /* 00127 * Is this node selected? 00128 * 00129 * @param iobj object the node is a part of 00130 * @param inode a Node to look for in the selected list 00131 * 00132 * @return whether or not the node is selected 00133 */ 00134 bool SelectionSet::isSelNode( int iobj, int inode ) { 00135 unsigned int isel; 00136 for ( isel=0; isel < mSelObj.size(); isel++ ) { 00137 if ( mSelObj[isel].obj == iobj ) 00138 break; 00139 } 00140 00141 if ( isel >= mSelObj.size() ) 00142 return false; 00143 00144 for ( int in=0; in < (int)mSelObj[isel].nodes.size(); in++ ) { 00145 if ( mSelObj[isel].nodes[in] == inode ) 00146 return true; 00147 } 00148 return false; 00149 } 00150 00151 00152
Home |
Search |
Disclaimers & Privacy |
Contact Us GLIMSView Maintainer: dsoltesz@usgs.gov |