}
}
+void XYWnd::FocusOnBounds( AABB& bounds ){
+ SetOrigin( bounds.origin );
+ int nDim1 = ( m_viewType == YZ ) ? 1 : 0;
+ int nDim2 = ( m_viewType == XY ) ? 1 : 2;
+ if( bounds.extents[ nDim1 ] < 128.f )
+ bounds.extents[ nDim1 ] = 128.f;
+ if( bounds.extents[ nDim2 ] < 128.f )
+ bounds.extents[ nDim2 ] = 128.f;
+ float scale1 = Width() / ( 3.f * bounds.extents[ nDim1 ] );
+ float scale2 = Height() / ( 3.f * bounds.extents[ nDim2 ] );
+ SetScale( MIN( scale1, scale2 ) );
+
+}
+
VIEWTYPE GlobalXYWnd_getCurrentViewType(){
ASSERT_NOTNULL( g_pParentWnd );
ASSERT_NOTNULL( g_pParentWnd->ActiveXY() );
reinterpret_cast<XYWnd*>( data )->ZoomInWithMouse( g_zoom2x, g_zoom2y );
}
else{
- reinterpret_cast<XYWnd*>( data )->ZoomIn();
+ reinterpret_cast<XYWnd*>( data )->ZoomIn();
}
g_dragZoom += 8;
}
-void GetFocusPosition( Vector3& position ){
+void GetCenterPosition( Vector3& position ){
if ( GlobalSelectionSystem().countSelected() != 0 ) {
Select_GetMid( position );
}
}
}
-void XYWnd_Focus( XYWnd* xywnd ){
+void XYWnd_Centralize( XYWnd* xywnd ){
Vector3 position;
- GetFocusPosition( position );
+ GetCenterPosition( position );
xywnd->PositionView( position );
}
-void XY_Split_Focus(){
+void XY_Split_Centralize(){
Vector3 position;
- GetFocusPosition( position );
+ GetCenterPosition( position );
if ( g_pParentWnd->GetXYWnd() ) {
g_pParentWnd->GetXYWnd()->PositionView( position );
}
}
}
+void XY_Centralize(){
+ if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
+ // centralize all
+ XY_Split_Centralize();
+ return;
+ }
+
+ XYWnd* xywnd = g_pParentWnd->GetXYWnd();
+ XYWnd_Centralize( xywnd );
+}
+
+
+
+void GetSelectionBbox( AABB& bounds ){
+ if ( GlobalSelectionSystem().countSelected() != 0 ) {
+ Scene_BoundsSelected( GlobalSceneGraph(), bounds );
+ }
+ else
+ {
+ bounds = AABB( Camera_getOrigin( *g_pParentWnd->GetCamWnd() ), Vector3( 128.f, 128.f, 128.f ) );
+ }
+}
+
+void XYWnd_Focus( XYWnd* xywnd ){
+ AABB bounds;
+ GetSelectionBbox( bounds );
+ xywnd->FocusOnBounds( bounds );
+}
+
+void XY_Split_Focus(){
+ AABB bounds;
+ GetSelectionBbox( bounds );
+ if ( g_pParentWnd->GetXYWnd() ) {
+ g_pParentWnd->GetXYWnd()->FocusOnBounds( bounds );
+ }
+ if ( g_pParentWnd->GetXZWnd() ) {
+ g_pParentWnd->GetXZWnd()->FocusOnBounds( bounds );
+ }
+ if ( g_pParentWnd->GetYZWnd() ) {
+ g_pParentWnd->GetYZWnd()->FocusOnBounds( bounds );
+ }
+}
+
void XY_Focus(){
if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating ) {
- // cannot do this in a split window
- // do something else that the user may want here
+ // focus all
XY_Split_Focus();
return;
}
XYWnd_Focus( xywnd );
}
+
+
void XY_TopFrontSide( VIEWTYPE viewtype ){
if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
// cannot do this in a split window
// do something else that the user may want here
- XY_Split_Focus();
+ XY_Split_Centralize();
return;
}
XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd();
xywnd->SetViewType( viewtype );
- XYWnd_Focus( xywnd );
+ XYWnd_Centralize( xywnd );
}
void XY_Top(){
else{
xywnd->SetViewType( XY );
}
- XYWnd_Focus( xywnd );
+ XYWnd_Centralize( xywnd );
}
void XY_Next(){
if ( g_pParentWnd->CurrentStyle() == MainFrame::eSplit ) {
// cannot do this in a split window
// do something else that the user may want here
- XY_Split_Focus();
+ XY_Split_Centralize();
return;
}
XYWnd* xywnd = g_pParentWnd->CurrentStyle() == MainFrame::eFloating ? g_pParentWnd->ActiveXY() : g_pParentWnd->GetXYWnd();
GlobalCommands_insert( "ViewSide", makeCallbackF(XY_Side), Accelerator( GDK_KEY_KP_Page_Down ) );
GlobalCommands_insert( "ViewFront", makeCallbackF(XY_Front), Accelerator( GDK_KEY_KP_End ) );
GlobalCommands_insert( "Zoom100", makeCallbackF(XY_Zoom100) );
- GlobalCommands_insert( "CenterXYView", makeCallbackF(XY_Focus), Accelerator( GDK_KEY_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "CenterXYView", makeCallbackF(XY_Centralize), Accelerator( GDK_Tab, (GdkModifierType)( GDK_SHIFT_MASK | GDK_CONTROL_MASK ) ) );
+ GlobalCommands_insert( "XYFocusOnSelected", makeCallbackF(XY_Focus), Accelerator( GDK_grave ) );
GlobalPreferenceSystem().registerPreference( "ClipCaulk", make_property_string( g_clip_useCaulk ) );
GlobalPreferenceSystem().registerPreference( "SI_Colors11", make_property_string( g_xywindow_globals.color_selbrushes ) );
-
-
GlobalPreferenceSystem().registerPreference( "XZVIS", make_property_string<ToggleShown_Bool>( g_xz_front_shown ) );
GlobalPreferenceSystem().registerPreference( "YZVIS", make_property_string<ToggleShown_Bool>( g_yz_side_shown ) );