// greebo: This should be called "onComponentSelectionChanged", as it is a similar function of the above one
// Updates the internal list of component nodes if the component selection gets changed
void RadiantSelectionSystem::onComponentSelection(const scene::INodePtr& node, const Selectable& selectable) {

    int delta = selectable.isSelected() ? +1 : -1;

    _countComponent += delta;
    _sigSelectionChanged(selectable);

    _selectionInfo.totalCount += delta;
    _selectionInfo.componentCount += delta;

    // If the instance got selected, add it to the list, otherwise remove it
    if (selectable.isSelected()) {
        _componentSelection.append(node);
    }
    else {
        _componentSelection.erase(node);
    }

    // Notify observers, TRUE => this is a component selection change
    notifyObservers(node, true);

    // Check if the number of selected components in the list matches the value of the selection counter
    ASSERT_MESSAGE(_componentSelection.size() == _countComponent, "component selection-tracking error");

    // Schedule an idle callback
    requestIdleCallback();

    _requestWorkZoneRecalculation = true;
    _requestSceneGraphChange = true;
}
예제 #2
0
// This is called if the selection changes, so that the local list of selected instances can be updated
void RadiantSelectionSystem::onSelectedChanged(scene::Instance& instance, const Selectable& selectable) {
	// Cache the selection state
	bool isSelected = selectable.isSelected();

	_countPrimitive += (isSelected) ? +1 : -1;
	_selectionChangedCallbacks(selectable); // legacy

	_selectionInfo.totalCount += (isSelected) ? +1 : -1;

	if (Instance_getBrush(instance) != NULL) {
		_selectionInfo.brushCount += (isSelected) ? +1 : -1;
	}
	else {
		_selectionInfo.entityCount += (isSelected) ? +1 : -1;
	}

	// If the selectable is selected, add it to the local selection list, otherwise remove it
	if (isSelected) {
		_selection.append(instance);
	}
	else {
		_selection.erase(instance);
	}

	// Notify observers, FALSE = primitive selection change
	notifyObservers(instance, false);

	// Check if the number of selected primitives in the list matches the value of the selection counter
	ASSERT_MESSAGE(_selection.size() == _countPrimitive, "selection-tracking error");

	// Schedule an idle callback
	requestIdleCallback();

	_requestWorkZoneRecalculation = true;
}
예제 #3
0
void post( const scene::Path& path, scene::Instance& instance ) const {
	Selectable *selectable = Instance_getSelectable( instance );
	if ( selectable && selectable->isSelected() ) {
		Entity* entity = Node_getEntity( path.top() );
		if ( entity == 0 && Node_isPrimitive( path.top() ) ) {
			NodeSmartReference child( path.top().get() );
			NodeSmartReference parent( path.parent().get() );

			if ( path.size() >= 3 && parent != worldspawn ) {
				NodeSmartReference parentparent( path[path.size() - 3].get() );

				Node_getTraversable( parent )->erase( child );
				Node_getTraversable( group )->insert( child );

				if ( Node_getTraversable( parent )->empty() ) {
					//deleteme.push(DeletionPair(parentparent, parent));
					Node_getTraversable( parentparent )->erase( parent );
				}
			}
			else
			{
				Node_getTraversable( parent )->erase( child );
				Node_getTraversable( group )->insert( child );
			}
		}
	}
}
예제 #4
0
void FaceInstance::selectedChanged (const Selectable& selectable)
{
	if (selectable.isSelected()) {
		g_SelectedFaceInstances.insert(*this);
	} else {
		g_SelectedFaceInstances.erase(*this);
	}
	m_selectionChanged(selectable);
}
예제 #5
0
// greebo: This should be called "onComponentSelectionChanged", as it is a similar function of the above one
// Updates the internal list of component instances if the component selection gets changed
void RadiantSelectionSystem::onComponentSelection(scene::Instance& instance, const Selectable& selectable) {
	_countComponent += (selectable.isSelected()) ? +1 : -1;
	_selectionChangedCallbacks(selectable); // legacy

	_selectionInfo.totalCount += (selectable.isSelected()) ? +1 : -1;

	// If the instance got selected, add it to the list, otherwise remove it
	if (selectable.isSelected()) {
		_componentSelection.append(instance);
	}
	else {
		_componentSelection.erase(instance);
	}

	notifyObservers(instance, true);

	// Check if the number of selected components in the list matches the value of the selection counter
	ASSERT_MESSAGE(_componentSelection.size() == _countComponent, "selection-tracking error");

	// Schedule an idle callback
	requestIdleCallback();

	_requestWorkZoneRecalculation = true;
}
예제 #6
0
파일: Planes.cpp 프로젝트: AresAndy/ufoai
bool PlaneSelectableSelectPlanes::pre(const scene::Path& path, scene::Instance& instance) const {
    if(path.top().get().visible())
    {
      Selectable* selectable = Instance_getSelectable(instance);
      if(selectable != 0 && selectable->isSelected())
      {
        PlaneSelectable* planeSelectable = Instance_getPlaneSelectable(instance);
        if(planeSelectable != 0)
        {
          planeSelectable->selectPlanes(_selector, _test, _selectedPlaneCallback);
        }
      }
    }
    return true;
}
// This is called if the selection changes, so that the local list of selected nodes can be updated
void RadiantSelectionSystem::onSelectedChanged(const scene::INodePtr& node, const Selectable& selectable) {

    // Cache the selection state
    bool isSelected = selectable.isSelected();
    int delta = isSelected ? +1 : -1;

    _countPrimitive += delta;
    _sigSelectionChanged(selectable);

    _selectionInfo.totalCount += delta;

    if (Node_getPatch(node) != NULL) {
        _selectionInfo.patchCount += delta;
    }
    else if (Node_getBrush(node) != NULL) {
        _selectionInfo.brushCount += delta;
    }
    else {
        _selectionInfo.entityCount += delta;
    }

    // If the selectable is selected, add it to the local selection list, otherwise remove it
    if (isSelected) {
        _selection.append(node);
    }
    else {
        _selection.erase(node);
    }

    // Notify observers, FALSE = primitive selection change
    notifyObservers(node, false);

    // Check if the number of selected primitives in the list matches the value of the selection counter
    ASSERT_MESSAGE(_selection.size() == _countPrimitive, "selection-tracking error");

    // Schedule an idle callback
    requestIdleCallback();

    _requestWorkZoneRecalculation = true;
    _requestSceneGraphChange = true;
}
예제 #8
0
void FaceInstance::selectedChanged(const Selectable& selectable)
{
	if (selectable.isSelected())
	{
		Selection().push_back(this);
	}
	else
	{
		FaceInstanceSet::reverse_iterator found = std::find(Selection().rbegin(), Selection().rend(), this);

		// Emit an error if the instance is not in the list
		ASSERT_MESSAGE(found != Selection().rend(), "selection-tracking error");

		Selection().erase(--found.base());
	}

	if (m_selectionChanged)
	{
		m_selectionChanged(selectable);
	}
}
예제 #9
0
gboolean treemodel_update_selection(GtkTreeModel* model, GtkTreePath* path, GtkTreeIter* iter, gpointer data)
{
  GtkTreeView* view = reinterpret_cast<GtkTreeView*>(data);

  scene::Instance* instance;
  gtk_tree_model_get_pointer(model, iter, 1, &instance);
  Selectable* selectable = Instance_getSelectable(*instance);

  if(selectable != 0)
  {
    GtkTreeSelection* selection = gtk_tree_view_get_selection(view);
    if(selectable->isSelected())
    {
      gtk_tree_selection_select_path(selection, path);
    }
    else
    {
      gtk_tree_selection_unselect_path(selection, path);
    }
  }

  return FALSE;
}
/* greebo: This gets called by SelectObserver if the user just clicks into the scene (without dragging)
 * It checks for any possible targets (in the "line of click") and takes the actions according
 * to the modifiers that are held down (Alt-Shift, etc.)
 */
void RadiantSelectionSystem::SelectPoint(const View& view,
                                         const Vector2& device_point,
                                         const Vector2& device_epsilon,
                                         SelectionSystem::EModifier modifier,
                                         bool face)
{
    ASSERT_MESSAGE(fabs(device_point[0]) <= 1.0f && fabs(device_point[1]) <= 1.0f, "point-selection error");
    // If the user is holding the replace modifiers (default: Alt-Shift), deselect the current selection
    if (modifier == SelectionSystem::eReplace) {
        if (face) {
            setSelectedAllComponents(false);
        }
        else {
            deselectAll();
        }
    }

    {
        View scissored(view);
        // Construct a selection test according to a small box with 2*epsilon edge length
        ConstructSelectionTest(scissored, Rectangle::ConstructFromPoint(device_point, device_epsilon));

        // Create a new SelectionPool instance and fill it with possible candidates
        SelectionVolume volume(scissored);
        // The possible candidates are stored in the SelectablesSet
        SelectablesList candidates;

        if (face)
        {
            SelectionPool selector;

            ComponentSelector selectionTester(selector, volume, eFace);
            GlobalSceneGraph().foreachVisibleNodeInVolume(scissored, selectionTester);

            // Load them all into the vector
            for (SelectionPool::iterator i = selector.begin(); i != selector.end(); ++i)
            {
                candidates.push_back(i->second);
            }
        }
        else {
            testSelectScene(candidates, volume, scissored, Mode(), ComponentMode());
        }

        // Was the selection test successful (have we found anything to select)?
        if (candidates.size() > 0) {
            // Yes, now determine how we should interpret the click
            switch (modifier) {
                // If we are in toggle mode (Shift-Left-Click by default), just toggle the
                // selection of the "topmost" item
                case SelectionSystem::eToggle: {
                    Selectable* best = *candidates.begin();
                    // toggle selection of the object with least depth (=first in the list)
                    best->setSelected(!best->isSelected());
                }
                break;
                // greebo: eReplace mode gets active as soon as the user holds the replace modifiers down
                // and clicks (by default: Alt-Shift). eReplace is only active during the first click
                // afterwards we are in cycle mode.
                // if cycle mode not enabled, enable it
                case SelectionSystem::eReplace: {
                    // select closest (=first in the list)
                    (*candidates.begin())->setSelected(true);
                }
                break;
                // select the next object in the list from the one already selected
                // greebo: eCycle is set if the user keeps holding the replace modifiers (Alt-Shift)
                // and does NOT move the mouse between the clicks, otherwise we fall back into eReplace mode
                // Note: The mode is set in SelectObserver::testSelect()
                case SelectionSystem::eCycle: {
                    // Cycle through the selection pool and activate the item right after the currently selected
                    SelectablesList::iterator i = candidates.begin();

                    while (i != candidates.end()) {
                        if ((*i)->isSelected()) {
                            // unselect the currently selected one
                            (*i)->setSelected(false);
                            // check if there is a "next" item in the list, if not: select the first item
                            ++i;
                            if (i != candidates.end()) {
                                (*i)->setSelected(true);
                            }
                            else {
                                (*candidates.begin())->setSelected(true);
                            }
                            break;
                        }
                        ++i;
                    } // while
                } // case
                break;
                default:
                break;
            } // switch
        }
    }
}
예제 #11
0
 void notify(const Selectable& arguments)
 {
   bool bleh = arguments.isSelected();
 }