Skip to content

Commit

Permalink
Fix problems with Vehicle view parameters
Browse files Browse the repository at this point in the history
The view parameters were only kept up to date when the ManageViewScreen
was Shown.  This prevented setting the viewpoint from the API unless
the MVS screen was Shown.

It also meant that commands to change the viewpoint sometimes didn't work
properly when the MVS screen was open.
  • Loading branch information
ramcdona committed Jan 19, 2025
1 parent 7593535 commit 492942b
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 277 deletions.
12 changes: 11 additions & 1 deletion src/geom_core/Vehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Vehicle::Vehicle()
m_CORZValue.Init( "CORZ", "AdjustView", this, 0.0, -1.0e12, 1.0e12 );
m_PanXPosValue.Init( "PanX", "AdjustView", this, 0.0, -1.0e12, 1.0e12 );
m_PanYPosValue.Init( "PanY", "AdjustView", this, 0.0, -1.0e12, 1.0e12 );
m_ZoomValue.Init( "Zoom", "AdjustView", this, 1e-3, 1e-6, 10 );
m_ZoomValue.Init( "Zoom", "AdjustView", this, 0.018, 1e-6, 10 );
m_XRotationValue.Init( "RotationX", "AdjustView", this, 0.0, -1.0e12, 1.0e12 );
m_YRotationValue.Init( "RotationY", "AdjustView", this, 0.0, -1.0e12, 1.0e12 );
m_ZRotationValue.Init( "RotationZ", "AdjustView", this, 0.0, -1.0e12, 1.0e12 );
Expand Down Expand Up @@ -320,6 +320,8 @@ Vehicle::Vehicle()
m_VehProjectVec3d.resize( 3 );
m_ColorCount = 0;

m_ViewDirty = true;

// Protect required enum value.
assert( CUSTOM_GEOM_TYPE == 9 );
}
Expand Down Expand Up @@ -506,6 +508,8 @@ void Vehicle::Init()
m_exportDegenGeomCsvFile.Set( true );
m_exportDegenGeomMFile.Set( true );

m_ViewDirty = true;

AnalysisMgr.Init();
}

Expand Down Expand Up @@ -617,6 +621,7 @@ void Vehicle::Wype()
m_TotalMass = double();
m_AttrCollection.Wype();

m_ViewDirty = true;

// Private member variables
m_Name = string();
Expand Down Expand Up @@ -855,6 +860,11 @@ void Vehicle::ParmChanged( Parm* parm_ptr, int type )
return;
}

if ( parm_ptr->GetGroupName() == string( "AdjustView" ) )
{
m_ViewDirty = true;
}

m_UpdatingBBox = true;
UpdateBBox();
m_UpdatingBBox = false;
Expand Down
2 changes: 2 additions & 0 deletions src/geom_core/Vehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ class Vehicle : public ParmContainer
Parm m_YRotationValue;
Parm m_ZRotationValue;

bool m_ViewDirty;

// ScreenshotScreen
FractionParm m_NewRatioValue;
IntParm m_NewWidthValue;
Expand Down
130 changes: 86 additions & 44 deletions src/gui_and_draw/MainGLWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,7 @@ void VspGlWindow::draw()
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

if ( viewScreen->IsShown() )
{
viewScreen->UpdateViewport();
}
UpdateViewportParms();

//Make sure the current width and height update
m_ScreenMgr->GetScreen( vsp::VSP_SCREENSHOT_SCREEN )->Update();
Expand Down Expand Up @@ -529,6 +526,76 @@ void VspGlWindow::clearScene()
m_GEngine->getDisplay()->getViewport()->clearFont();
}

void VspGlWindow::UpdateViewportParms()
{
Vehicle *veh = VehicleMgr.GetVehicle();

if ( veh )
{
veh->m_ViewportSizeXValue.Set( pixel_w() );
veh->m_ViewportSizeYValue.Set( pixel_h() );
}
}

void VspGlWindow::UpdateCORParms()
{
Vehicle *veh = VehicleMgr.GetVehicle();

if ( veh )
{
glm::vec3 center = getCOR();

veh->m_CORXValue.Set( center.x );
veh->m_CORYValue.Set( center.y );
veh->m_CORZValue.Set( center.z );
}
}

void VspGlWindow::UpdatePanParms()
{
Vehicle *veh = VehicleMgr.GetVehicle();

if ( veh )
{
glm::vec2 currentPan = getPanValues();
veh->m_PanXPosValue.Set( currentPan.x );
veh->m_PanYPosValue.Set( currentPan.y );
}
}

void VspGlWindow::UpdateZoomParms()
{
Vehicle *veh = VehicleMgr.GetVehicle();

if ( veh )
{
veh->m_ZoomValue.Set( getRelativeZoomValue() );
}
}

void VspGlWindow::UpdateRotationParms()
{
Vehicle *veh = VehicleMgr.GetVehicle();

if ( veh )
{
glm::vec3 eulerValues = getRotationEulerAngles();

veh->m_XRotationValue.Set( eulerValues[0] * ( 180.0 / M_PI ) );
veh->m_YRotationValue.Set( eulerValues[1] * ( 180.0 / M_PI ) );
veh->m_ZRotationValue.Set( eulerValues[2] * ( 180.0 / M_PI ) );
}
}

void VspGlWindow::UpdateAllViewParms()
{
UpdateViewportParms();
UpdateCORParms();
UpdatePanParms();
UpdateZoomParms();
UpdateRotationParms();
}

void VspGlWindow::_initGLEW()
{
if( !m_initialized )
Expand Down Expand Up @@ -2235,7 +2302,7 @@ void VspGlWindow::OnDrag( int x, int y )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

viewScreen->UpdateZoom();
UpdateZoomParms();
}
m_prevLBRB = glm::vec2( x, y );
}
Expand Down Expand Up @@ -2273,10 +2340,7 @@ void VspGlWindow::OnDrag( int x, int y )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

if ( viewScreen->IsShown() )
{
viewScreen->UpdatePan();
}
UpdatePanParms();
}
m_prevAltLB = glm::vec2( x, y );
}
Expand All @@ -2290,7 +2354,7 @@ void VspGlWindow::OnDrag( int x, int y )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

viewScreen->UpdateZoom();
UpdateZoomParms();
}
m_prevCtrlLB = glm::vec2( x, y );
}
Expand All @@ -2303,7 +2367,7 @@ void VspGlWindow::OnDrag( int x, int y )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

viewScreen->UpdateZoom();
UpdateZoomParms();
}
m_prevMetaLB = glm::vec2( x, y );
}
Expand All @@ -2317,7 +2381,7 @@ void VspGlWindow::OnDrag( int x, int y )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

viewScreen->UpdateRotations();
UpdateRotationParms();
}
m_prevLB = glm::vec2( x, y );
}
Expand All @@ -2332,7 +2396,7 @@ void VspGlWindow::OnDrag( int x, int y )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

viewScreen->UpdateZoom();
UpdateZoomParms();
}
m_prevMB = glm::vec2( x, y );
}
Expand All @@ -2346,10 +2410,7 @@ void VspGlWindow::OnDrag( int x, int y )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

if ( viewScreen->IsShown() )
{
viewScreen->UpdatePan();
}
UpdatePanParms();
}
m_prevRB = glm::vec2( x, y );
}
Expand Down Expand Up @@ -2432,10 +2493,8 @@ int VspGlWindow::OnKeyup( int x, int y )
display->load( 0 );

//===== Update Adjust View Screen with new values =====//
if ( viewScreen->IsShown() )
{
viewScreen->UpdateAll();
}
UpdateAllViewParms();

}
handled = 1;
break;
Expand All @@ -2449,11 +2508,7 @@ int VspGlWindow::OnKeyup( int x, int y )
{
display->load( 1 );

//===== Update Adjust View Screen with new values =====//
if ( viewScreen->IsShown() )
{
viewScreen->UpdateAll();
}
UpdateAllViewParms();
}
handled = 1;
break;
Expand All @@ -2467,11 +2522,7 @@ int VspGlWindow::OnKeyup( int x, int y )
{
display->load( 2 );

//===== Update Adjust View Screen with new values =====//
if ( viewScreen->IsShown() )
{
viewScreen->UpdateAll();
}
UpdateAllViewParms();
}
handled = 1;
break;
Expand All @@ -2486,10 +2537,7 @@ int VspGlWindow::OnKeyup( int x, int y )
display->load( 3 );

//===== Update Adjust View Screen with new values =====//
if ( viewScreen->IsShown() )
{
viewScreen->UpdateAll();
}
UpdateAllViewParms();
}
handled = 1;
break;
Expand Down Expand Up @@ -2619,11 +2667,8 @@ int VspGlWindow::OnWheelScroll( int dx, int dy, int x, int y )

ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* > ( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

if ( viewScreen )
{
viewScreen->UpdateZoom();
viewScreen->UpdatePan();
}
UpdateZoomParms();
UpdatePanParms();

redraw();
}
Expand Down Expand Up @@ -2725,10 +2770,7 @@ void VspGlWindow::_sendFeedback( Selectable * selected )
ManageViewScreen * viewScreen = dynamic_cast< ManageViewScreen* >
( m_ScreenMgr->GetScreen( vsp::VSP_VIEW_SCREEN ) );

if ( viewScreen->IsShown() )
{
viewScreen->UpdateCOR();
}
UpdateCORParms();

m_GEngine->getDisplay()->center();

Expand Down
7 changes: 7 additions & 0 deletions src/gui_and_draw/MainGLWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ class VspGlWindow : public Fl_Gl_Window

virtual void clearScene();

void UpdateViewportParms();
void UpdateCORParms();
void UpdatePanParms();
void UpdateZoomParms();
void UpdateRotationParms();
void UpdateAllViewParms();

// Private helper functions.
private:
void _initGLEW();
Expand Down
Loading

0 comments on commit 492942b

Please sign in to comment.