| 110 | //----------------------------------------------------------------------------- |
| 111 | |
| 112 | void WorldEditorSelection::addObject( SimObject* obj ) |
| 113 | { |
| 114 | // Return if object is already in selection. |
| 115 | |
| 116 | if( objInSet( obj ) ) |
| 117 | return; |
| 118 | |
| 119 | // Refuse to add object if this selection is locked. |
| 120 | |
| 121 | if( isLocked() ) |
| 122 | return; |
| 123 | |
| 124 | // Prevent adding us to ourselves. |
| 125 | |
| 126 | if( obj == this ) |
| 127 | return; |
| 128 | |
| 129 | // If the object is itself a selection set, make sure we |
| 130 | // don't create a cycle. |
| 131 | |
| 132 | WorldEditorSelection* selection = dynamic_cast< WorldEditorSelection* >( obj ); |
| 133 | if( selection && !selection->objInSet( this ) ) |
| 134 | return; |
| 135 | |
| 136 | // Refuse to add any of our parents. |
| 137 | |
| 138 | for( SimGroup* group = getGroup(); group != NULL; group = group->getGroup() ) |
| 139 | if( obj == group ) |
| 140 | return; |
| 141 | |
| 142 | invalidateCentroid(); |
| 143 | |
| 144 | Parent::addObject( obj ); |
| 145 | |
| 146 | if( mAutoSelect ) |
| 147 | WorldEditor::markAsSelected( obj, true ); |
| 148 | |
| 149 | return; |
| 150 | } |
| 151 | |
| 152 | //----------------------------------------------------------------------------- |
| 153 |
no test coverage detected