// 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 StatusBarManager::setText(const std::string& name, const std::string& text, bool immediateUpdate)
{
	// Look up the key
	ElementMap::const_iterator found = _elements.find(name);

	// return NULL if not found
	if (found != _elements.end() && found->second->label != NULL)
	{
        if (found->second->text != text)
        {
            // Set the text
            found->second->text = text;

            // Do the rest of the work in the idle callback
            requestIdleCallback();

            if (immediateUpdate)
            {
                flushIdleCallback();
            }
        }
	}
	else
	{
		rError() << "Could not find text status bar element with the name "
			<< name << std::endl;
	}
}
void RadiantSelectionSystem::onSceneBoundsChanged()
{
    // The bounds of the scenegraph have (possibly) changed
    pivotChanged();

    _requestWorkZoneRecalculation = true;
    requestIdleCallback();
}
Пример #5
0
// This actually applies the transformation to the objects
void RadiantSelectionSystem::freezeTransforms() {
	GlobalSceneGraph().traverse(FreezeTransforms());

	// The selection bounds have possibly changed, request an idle callback
	_requestWorkZoneRecalculation = true;

	requestIdleCallback();
}
// This actually applies the transformation to the objects
void RadiantSelectionSystem::freezeTransforms()
{
    FreezeTransforms freezer;
    Node_traverseSubgraph(GlobalSceneGraph().root(), freezer);

    // The selection bounds have possibly changed, request an idle callback
    _requestWorkZoneRecalculation = true;
    _requestSceneGraphChange = true;

    requestIdleCallback();
}
/* greebo: This "moves" the current selection. It calculates the device manipulation matrix
 * and passes it to the currently active Manipulator.
 */
void RadiantSelectionSystem::MoveSelected(const View& view, const Vector2& devicePoint)
{
    // Check, if the active manipulator is selected in the first place
    if (_manipulator->isSelected()) {
        // Initalise the undo system, if not yet done
        if (!_undoBegun) {
            _undoBegun = true;
            GlobalUndoSystem().start();
        }

        Matrix4 device2manip;
        ConstructDevice2Manip(device2manip, _pivot2worldStart, view.GetModelview(), view.GetProjection(), view.GetViewport());

        Vector2 constrainedDevicePoint(devicePoint);

        // Constrain the movement to the axes, if the modifier is held
        if ((GlobalEventManager().getModifierState() & GDK_SHIFT_MASK) != 0)
        {
            // Get the movement delta relative to the start point
            Vector2 delta = devicePoint - _deviceStart;

            // Set the "minor" value of the movement to zero
            if (fabs(delta[0]) > fabs(delta[1])) {
                // X axis is major, reset the y-value to the start
                delta[1] = 0;
            }
            else {
                // Y axis is major, reset the x-value to the start
                delta[0] = 0;
            }

            // Add the modified delta to the start point, constrained to one axis
            constrainedDevicePoint = _deviceStart + delta;
        }

        // Get the manipulatable from the currently active manipulator (done by selection test)
        // and call the Transform method (can be anything)
        _manipulator->getActiveComponent()->Transform(_manip2pivotStart, device2manip, constrainedDevicePoint[0], constrainedDevicePoint[1]);

        _requestWorkZoneRecalculation = true;
        _requestSceneGraphChange = true;

        requestIdleCallback();
    }
}
Пример #8
0
void StatusBarManager::setText(const std::string& name, const std::string& text)
{
	// Look up the key
	ElementMap::const_iterator found = _elements.find(name);

	// return NULL if not found
	if (found != _elements.end() && found->second->label != NULL)
	{
		// Set the text
		found->second->text = text;

		// Request an idle callback
		requestIdleCallback();
	}
	else
	{
		rError() << "Could not find text status bar element with the name "
			<< name << std::endl;
	}
}
// 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;
}
Пример #10
0
/* greebo: This "moves" the current selection. It calculates the device manipulation matrix
 * and passes it to the currently active Manipulator.
 */
void RadiantSelectionSystem::MoveSelected(const View& view, const float device_point[2]) {
	// Check, if the active manipulator is selected in the first place
	if (_manipulator->isSelected()) {
		// Initalise the undo system
		if (!_undoBegun) {
			_undoBegun = true;
			GlobalUndoSystem().start();
		}

		Matrix4 device2manip;
		ConstructDevice2Manip(device2manip, _pivot2worldStart, view.GetModelview(), view.GetProjection(), view.GetViewport());

		// Get the manipulatable from the currently active manipulator (done by selection test)
		// and call the Transform method (can be anything)
		_manipulator->GetManipulatable()->Transform(_manip2pivotStart, device2manip, device_point[0], device_point[1]);

		_requestWorkZoneRecalculation = true;

		requestIdleCallback();
	}
}
Пример #11
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;
}
Пример #12
0
// greebo: Callback for the selectionSystem event: onBoundsChanged
void RadiantSelectionSystem::onBoundsChanged() {
	pivotChanged();

	_requestWorkZoneRecalculation = true;
	requestIdleCallback();
}