Umsci
Upmix Spatial Control Interface — OCA/OCP.1 spatial audio utility
Loading...
Searching...
No Matches
UmsciSoundobjectsPaintComponent Class Reference

The middle layer of the UmsciControlComponent stack — paints a filled circle for each sound object and lets the user drag them to new positions. More...

#include <UmsciSoundobjectsPaintComponent.h>

+ Inheritance diagram for UmsciSoundobjectsPaintComponent:
+ Collaboration diagram for UmsciSoundobjectsPaintComponent:

Public Member Functions

 UmsciSoundobjectsPaintComponent ()
 
 ~UmsciSoundobjectsPaintComponent () override
 
void paint (Graphics &) override
 
void resized () override
 
bool hitTest (int x, int y) override
 Returns true only when the point falls within a rendered source circle.
 
void mouseDown (const juce::MouseEvent &e) override
 Identifies which source is under the cursor and begins a drag.
 
void mouseDrag (const juce::MouseEvent &e) override
 Converts the drag position to world coordinates and fires onSourcePositionChanged.
 
void mouseUp (const juce::MouseEvent &e) override
 Clears the active drag state.
 
void setSourcePositions (const std::map< std::int16_t, std::array< std::float_t, 3 > > &sourcePositions)
 Replaces all source positions at once (e.g. on reconnect or initial query).
 
void setSourcePosition (std::int16_t sourceId, const std::array< std::float_t, 3 > &position)
 Updates a single source position.
 
void setSourceIdFilter (const std::set< std::int16_t > &allowedIds)
 Restricts rendering and interaction to the given set of source IDs. An empty set means no sources are visible. Called by UmsciControlComponent whenever the show-all / upmix-only mode changes.
 
- Public Member Functions inherited from UmsciPaintNControlComponentBase
 UmsciPaintNControlComponentBase ()
 
virtual ~UmsciPaintNControlComponentBase () override
 
void setBoundsRealRef (const juce::Rectangle< float > &boundsRealRef)
 Sets the real-world rectangle that the component's pixel bounds map to.
 
virtual void setControlsSize (ControlsSize size)
 Updates the icon size; derived classes may override to re-prerender.
 
ControlsSize getControlsSize () const
 
float getControlsSizeMultiplier () const
 Returns a multiplier (e.g. 0.5 / 1.0 / 1.5) for S/M/L icon sizes.
 
void setZoom (float factor, juce::Point< float > normalizedPanOffset={})
 Silently applies zoom without firing onViewportZoomChanged. Used by UmsciControlComponent to synchronise sibling layers after one of them fires the callback.
 
float getZoomFactor () const
 
void resetZoom ()
 Resets zoom to 1.0 / no pan and fires onViewportZoomChanged.
 
void simulatePinchZoom (float scaleFactor, juce::Point< float > centre)
 Applies an incremental pinch-zoom step, as if the user performed a native pinch gesture centred at centre (in component-local pixel coordinates).
 

Public Attributes

std::function< void(std::int16_t, std::array< std::float_t, 3 >)> onSourcePositionChanged
 Fired during a drag with the new world position. UmsciControlComponent receives this and calls DeviceController::SetObjectValue() to push the new position to the DS100 via OCP.1. Parameters: (sourceId, newPosition {X, Y, Z}).
 
- Public Attributes inherited from UmsciPaintNControlComponentBase
std::function< void(float, juce::Point< float >)> onViewportZoomChanged
 Fired after every user-initiated zoom/pan change (wheel, pinch, double-click). Parameters: (newFactor, newNormalisedPanOffset). UmsciControlComponent uses this to synchronise the other two layers via setZoom().
 

Additional Inherited Members

- Public Types inherited from UmsciPaintNControlComponentBase
enum class  ControlsSize {
  S ,
  M ,
  L
}
 Visual size of source/speaker icons. Multiplier accessible via getControlsSizeMultiplier(). More...
 
- Protected Member Functions inherited from UmsciPaintNControlComponentBase
juce::Point< float > GetPointForRealCoordinate (const std::array< float, 3 > &realCoordinate)
 Converts a 3D real-world coordinate to a 2D screen pixel point.
 
std::array< float, 3 > GetRealCoordinateForPoint (const juce::Point< float > &screenPoint)
 Inverse of GetPointForRealCoordinate — converts a screen pixel point back to a 3D real-world coordinate (Z is set to 0).
 
void mouseDoubleClick (const juce::MouseEvent &) override
 Double-click resets zoom to 1.0 via resetZoom().
 
void mouseWheelMove (const juce::MouseEvent &, const juce::MouseWheelDetails &) override
 Mouse-wheel zooms about the cursor position.
 
void mouseMagnify (const juce::MouseEvent &, float scaleFactor) override
 Trackpad pinch-to-zoom (macOS).
 
bool processPinchGesture (const juce::MouseEvent &e, bool isDown, bool isUp)
 JUCE-level two-touch pinch-zoom fallback for platforms where neither mouseMagnify nor a native gesture recognizer is available.
 

Detailed Description

The middle layer of the UmsciControlComponent stack — paints a filled circle for each sound object and lets the user drag them to new positions.

Rendering pipeline

  1. setSourcePosition() stores the incoming 3D world position {X, Y, Z} for a sound object and calls PrerenderSourcesInBounds() to re-convert all positions to pixel coordinates via GetPointForRealCoordinate().
  2. paint() draws a filled circle at each prerendered pixel position.

Prerender is retriggered in onZoomChanged() and resized().

Source ID filter

setSourceIdFilter() restricts which source IDs are rendered and interactive. When UmsciControlComponent::setShowAllSources(false) is set, only the channels belonging to the upmix group are passed to the filter.

Drag interaction

hitTest() returns true only over the painted circle of a source, so mouse events pass through to the loudspeakers layer (below) if no source is hit. On mouseDown, the nearest source within a hit-radius is identified and tracked as m_draggedSourceId. On mouseDrag, the new world position is computed via GetRealCoordinateForPoint() and sent to the DS100 via onSourcePositionChanged.

Touch-zoom and hitTest dead zones

Because hitTest() only covers painted circles, the large empty area of the component is transparent to touch events. On iOS, individual fingers of a pinch may therefore land in a dead zone and not be routed to this component at all, making the JUCE-level processPinchGesture() fallback unreliable. Two-finger pinch zoom on iOS is handled by a native UIPinchGestureRecognizer registered by UmsciControlComponent (see that class for details).

Definition at line 61 of file UmsciSoundobjectsPaintComponent.h.

Constructor & Destructor Documentation

◆ UmsciSoundobjectsPaintComponent()

UmsciSoundobjectsPaintComponent::UmsciSoundobjectsPaintComponent ( )

Definition at line 24 of file UmsciSoundobjectsPaintComponent.cpp.

◆ ~UmsciSoundobjectsPaintComponent()

UmsciSoundobjectsPaintComponent::~UmsciSoundobjectsPaintComponent ( )
override

Definition at line 29 of file UmsciSoundobjectsPaintComponent.cpp.

Member Function Documentation

◆ hitTest()

bool UmsciSoundobjectsPaintComponent::hitTest ( int  x,
int  y 
)
override

Returns true only when the point falls within a rendered source circle.

Definition at line 91 of file UmsciSoundobjectsPaintComponent.cpp.

References UmsciPaintNControlComponentBase::getControlsSizeMultiplier().

◆ mouseDown()

void UmsciSoundobjectsPaintComponent::mouseDown ( const juce::MouseEvent &  e)
override

Identifies which source is under the cursor and begins a drag.

Definition at line 118 of file UmsciSoundobjectsPaintComponent.cpp.

References UmsciPaintNControlComponentBase::getControlsSizeMultiplier(), and UmsciPaintNControlComponentBase::processPinchGesture().

◆ mouseDrag()

void UmsciSoundobjectsPaintComponent::mouseDrag ( const juce::MouseEvent &  e)
override

Converts the drag position to world coordinates and fires onSourcePositionChanged.

Definition at line 138 of file UmsciSoundobjectsPaintComponent.cpp.

References UmsciPaintNControlComponentBase::GetRealCoordinateForPoint(), onSourcePositionChanged, and UmsciPaintNControlComponentBase::processPinchGesture().

◆ mouseUp()

void UmsciSoundobjectsPaintComponent::mouseUp ( const juce::MouseEvent &  e)
override

Clears the active drag state.

Definition at line 160 of file UmsciSoundobjectsPaintComponent.cpp.

References UmsciPaintNControlComponentBase::processPinchGesture().

◆ paint()

void UmsciSoundobjectsPaintComponent::paint ( Graphics &  )
override

◆ resized()

void UmsciSoundobjectsPaintComponent::resized ( )
override

Definition at line 69 of file UmsciSoundobjectsPaintComponent.cpp.

◆ setSourceIdFilter()

void UmsciSoundobjectsPaintComponent::setSourceIdFilter ( const std::set< std::int16_t > &  allowedIds)

Restricts rendering and interaction to the given set of source IDs. An empty set means no sources are visible. Called by UmsciControlComponent whenever the show-all / upmix-only mode changes.

Definition at line 105 of file UmsciSoundobjectsPaintComponent.cpp.

◆ setSourcePosition()

void UmsciSoundobjectsPaintComponent::setSourcePosition ( std::int16_t  sourceId,
const std::array< std::float_t, 3 > &  position 
)

Updates a single source position.

Parameters
sourceId1-based DS100 input channel (sound object) index.
positionNormalised real-world {X, Y, Z}.

Definition at line 111 of file UmsciSoundobjectsPaintComponent.cpp.

References UmsciPaintNControlComponentBase::GetPointForRealCoordinate().

◆ setSourcePositions()

void UmsciSoundobjectsPaintComponent::setSourcePositions ( const std::map< std::int16_t, std::array< std::float_t, 3 > > &  sourcePositions)

Replaces all source positions at once (e.g. on reconnect or initial query).

Definition at line 74 of file UmsciSoundobjectsPaintComponent.cpp.

Member Data Documentation

◆ onSourcePositionChanged

std::function<void(std::int16_t, std::array<std::float_t, 3>)> UmsciSoundobjectsPaintComponent::onSourcePositionChanged

Fired during a drag with the new world position. UmsciControlComponent receives this and calls DeviceController::SetObjectValue() to push the new position to the DS100 via OCP.1. Parameters: (sourceId, newPosition {X, Y, Z}).

Definition at line 106 of file UmsciSoundobjectsPaintComponent.h.

Referenced by mouseDrag().


The documentation for this class was generated from the following files: