//--------------------------------------------------------- bool CACTIVE::_Show_Page(wxWindow *pPage) { int Image_ID = -1; //----------------------------------------------------- if( pPage == m_pParameters ) Image_ID = IMG_PARAMETERS; if( pPage == m_pDescription ) Image_ID = IMG_DESCRIPTION; if( pPage == m_pHistory ) Image_ID = IMG_HISTORY; if( pPage == m_pLegend ) Image_ID = IMG_LEGEND; if( pPage == m_pAttributes ) Image_ID = IMG_ATTRIBUTES; //----------------------------------------------------- if( pPage == m_pHistory ) m_pHistory ->Set_Item(Get_Active_Data_Item()); if( pPage == m_pLegend ) m_pLegend ->Set_Item(Get_Active_Layer() ? Get_Active_Layer() : Get_Active_Map() ? m_pItem : NULL); if( pPage == m_pAttributes ) m_pAttributes->Set_Item(Get_Active_Layer()); //----------------------------------------------------- if( pPage ) { for(int i=0; i<(int)GetPageCount(); i++) { if( GetPage(i) == pPage ) { return( true ); } } AddPage(pPage, pPage->GetName(), false, Image_ID); return( true ); } return( false ); }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_RDown(wxMouseEvent &event) { m_pParent->Activate(); m_Mouse_Down = m_Mouse_Move = event.GetPosition(); _Draw_Inverse(m_Mouse_Down, event.GetPosition()); m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool ) { g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_RDOWN, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) ) { Get_Active_Layer()->Edit_On_Mouse_Down(_Get_Client2World(event.GetPosition()), _Get_Client2World(1.0), GET_KEYS(event)); } break; //----------------------------------------------------- default: break; } }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Key_Down(wxKeyEvent &event) { if( m_pMap->Find_Layer(Get_Active_Layer()) && Get_Active_Layer()->Edit_On_Key_Down(event.GetKeyCode()) ) { return; } switch( event.GetKeyCode() ) { default: event.Skip(); break; case WXK_PAGEUP: _Zoom(m_pMap->Get_Extent().Get_Center(), true); break; case WXK_PAGEDOWN: _Zoom(m_pMap->Get_Extent().Get_Center(), false); break; case WXK_LEFT: _Move(wxPoint(-10, 0)); break; case WXK_RIGHT: _Move(wxPoint( 10, 0)); break; case WXK_UP: _Move(wxPoint( 0, -10)); break; case WXK_DOWN: _Move(wxPoint( 0, 10)); break; case WXK_F2: m_pMap->SaveAs_Image(); break; case 'C': if( event.GetModifiers() == wxMOD_CONTROL ) { m_pMap->SaveAs_Image_Clipboard(false); } else if( event.GetModifiers() == wxMOD_ALT ) { m_pMap->SaveAs_Image_Clipboard(GetClientSize().x, GetClientSize().y, -1); } break; case 'L': if( event.GetModifiers() == wxMOD_CONTROL ) { m_pMap->SaveAs_Image_Clipboard(true); } } }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_RUp(wxMouseEvent &event) { wxMenu *pMenu = NULL; m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool ) { g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_RUP, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) && !Get_Active_Layer()->Edit_On_Mouse_Up(_Get_Client2World(event.GetPosition()), _Get_Client2World(1.0), GET_KEYS(event)|TOOL_INTERACTIVE_KEY_RIGHT) ) { pMenu = Get_Active_Layer()->Edit_Get_Menu(); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: if( event.ControlDown() ) // context menu { pMenu = m_pParent->_Create_Menu(); } else // reset { _Distance_Reset(); } break; case MAP_MODE_ZOOM: if( event.ControlDown() ) // context menu { pMenu = m_pParent->_Create_Menu(); } else // zoom out { _Zoom(_Get_Client2World(event.GetPosition()), false); } break; //----------------------------------------------------- default: pMenu = m_pParent->_Create_Menu(); break; } //----------------------------------------------------- if( pMenu != NULL ) { PopupMenu(pMenu, event.GetPosition()); delete(pMenu); } }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_LUp(wxMouseEvent &event) { if( HasCapture() ) { ReleaseMouse(); } //----------------------------------------------------- if( m_Mode != MAP_MODE_SELECT && (event.ControlDown() || event.AltDown()) ) // clipboard copy ? { return; } //----------------------------------------------------- _Draw_Inverse(m_Mouse_Down, event.GetPosition()); m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool ) { g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_LUP, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) ) { Get_Active_Layer()->Edit_On_Mouse_Up(_Get_Client2World(event.GetPosition()), _Get_Client2World(1.0), GET_KEYS(event)|TOOL_INTERACTIVE_KEY_LEFT); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: _Distance_Add(event.GetPosition()); break; //----------------------------------------------------- case MAP_MODE_ZOOM: _Zoom(m_Mouse_Down, event.GetPosition()); break; //----------------------------------------------------- case MAP_MODE_PAN: break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: Set_Mode(MAP_MODE_PAN); _Move(m_Mouse_Down, event.GetPosition()); break; } }
//--------------------------------------------------------- inline void CVIEW_Map_Control::_Set_StatusBar(const TSG_Point &Point) { static bool bBuisy = false; if( bBuisy == false ) { bBuisy = true; if( m_pMap->Get_Parameter("GCS_POSITION")->asBool() && m_pMap->Get_Projection().is_Okay() ) { CSG_Projection GCS; GCS.Set_GCS_WGS84(); TSG_Point Position = Point; if( SG_Get_Projected(m_pMap->Get_Projection(), GCS, Position) ) { STATUSBAR_Set_Text(wxString::Format("X %s", SG_Double_To_Degree(Position.x).c_str()), STATUSBAR_VIEW_X); STATUSBAR_Set_Text(wxString::Format("Y %s", SG_Double_To_Degree(Position.y).c_str()), STATUSBAR_VIEW_Y); } } else { STATUSBAR_Set_Text(wxString::Format("X %f", Point.x), STATUSBAR_VIEW_X); STATUSBAR_Set_Text(wxString::Format("Y %f", Point.y), STATUSBAR_VIEW_Y); } if( m_Mode == MAP_MODE_DISTANCE ) { STATUSBAR_Set_Text(wxString::Format("D %f", m_Distance + m_Distance_Move), STATUSBAR_VIEW_Z); } else if( Get_Active_Layer() ) { STATUSBAR_Set_Text(wxString::Format("Z %s", Get_Active_Layer()->Get_Value(Point, _Get_Client2World(2.0)).c_str()), STATUSBAR_VIEW_Z); } else { STATUSBAR_Set_Text("Z", STATUSBAR_VIEW_Z); } bBuisy = false; } }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_LDown(wxMouseEvent &event) { m_Mouse_Down = m_Mouse_Move = event.GetPosition(); //----------------------------------------------------- if( m_Mode != MAP_MODE_SELECT ) // clipboard copy ? { if( event.ControlDown() ) { m_pMap->SaveAs_Image_Clipboard(false); return; } if( event.AltDown() ) { m_pMap->SaveAs_Image_Clipboard(GetClientSize().x, GetClientSize().y, -1); return; } } //----------------------------------------------------- bool bCaptureMouse = true; switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool && g_pTool->is_Interactive() ) { m_Drag_Mode = ((CSG_Tool_Interactive *)g_pTool->Get_Tool())->Get_Drag_Mode(); bCaptureMouse = !g_pTool->Execute(_Get_Client2World(event.GetPosition()), TOOL_INTERACTIVE_LDOWN, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) ) { switch( Get_Active_Layer()->Get_Type() ) { default: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; break; case WKSP_ITEM_Grid: case WKSP_ITEM_PointCloud: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_BOX; break; case WKSP_ITEM_Shapes: m_Drag_Mode = ((CWKSP_Shapes *)Get_Active_Layer())->is_Editing() ? TOOL_INTERACTIVE_DRAG_NONE : TOOL_INTERACTIVE_DRAG_BOX; break; } Get_Active_Layer()->Edit_On_Mouse_Down(_Get_Client2World(event.GetPosition()), _Get_Client2World(1.0), GET_KEYS(event)); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; break; //----------------------------------------------------- case MAP_MODE_ZOOM: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_BOX; break; //----------------------------------------------------- case MAP_MODE_PAN: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; Set_Mode(MAP_MODE_PAN_DOWN); break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: m_Drag_Mode = TOOL_INTERACTIVE_DRAG_NONE; break; } //----------------------------------------------------- if( bCaptureMouse && !HasCapture() ) { CaptureMouse(); } event.Skip(); }
//--------------------------------------------------------- void CVIEW_Map_Control::On_Mouse_Motion(wxMouseEvent &event) { wxPoint Point = event.GetPosition(); switch( m_Mode ) { //----------------------------------------------------- case MAP_MODE_SELECT: if( g_pTool ) { TSG_Tool_Interactive_Mode iMode = event.LeftIsDown () ? TOOL_INTERACTIVE_MOVE_LDOWN : event.MiddleIsDown() ? TOOL_INTERACTIVE_MOVE_MDOWN : event.RightIsDown () ? TOOL_INTERACTIVE_MOVE_RDOWN : TOOL_INTERACTIVE_MOVE; g_pTool->Execute(_Get_Client2World(Point), iMode, GET_KEYS(event)); } else if( m_pMap->Find_Layer(Get_Active_Layer()) ) { Get_Active_Layer()->Edit_On_Mouse_Move( this, m_pMap->Get_World(GetClientSize()), Point, m_Mouse_Move, GET_KEYS(event) ); } break; //----------------------------------------------------- case MAP_MODE_DISTANCE: if( m_Distance_Pts.Get_Count() > 0 ) { int n = m_Distance_Pts.Get_Count(); wxClientDC dc(this); wxPoint Last(_Get_World2Client(m_Distance_Pts[n - 1])); dc.SetLogicalFunction(wxINVERT); dc.DrawLine(Last.x, Last.y, m_Mouse_Move.x, m_Mouse_Move.y); dc.DrawLine(Last.x, Last.y, Point.x, Point.y); m_Distance_Move = SG_Get_Distance(m_Distance_Pts[n - 1], _Get_Client2World(Point)); } break; //----------------------------------------------------- case MAP_MODE_ZOOM: break; //----------------------------------------------------- case MAP_MODE_PAN: break; //----------------------------------------------------- case MAP_MODE_PAN_DOWN: // _Move(m_Mouse_Down, Point); _Pan(m_Mouse_Down, Point); break; } //----------------------------------------------------- if( m_Mode != MAP_MODE_PAN_DOWN ) { m_pParent->Ruler_Set_Position(Point.x, Point.y); m_pMap->Set_Mouse_Position(_Get_Client2World(Point)); _Set_StatusBar(_Get_Client2World(Point)); } //----------------------------------------------------- _Draw_Inverse(m_Mouse_Down, m_Mouse_Move, Point); m_Mouse_Move = Point; }
//--------------------------------------------------------- inline void CVIEW_Map_Control::_Set_StatusBar(CSG_Point ptWorld) { static bool bBuisy = false; if( bBuisy == false ) { bBuisy = true; CSG_Tool *pProjector = NULL; if( m_pMap->Get_Parameter("GCS_POSITION")->asBool() && m_pMap->Get_Projection().is_Okay() && (pProjector = SG_Get_Tool_Library_Manager().Get_Tool("pj_proj4", 2)) != NULL ) // Coordinate Transformation (Shapes) { if( pProjector->is_Executing() ) { pProjector = NULL; } else { SG_UI_Progress_Lock(true); SG_UI_Msg_Lock (true); CSG_Shapes prj(SHAPE_TYPE_Point), gcs(SHAPE_TYPE_Point); prj.Add_Shape()->Add_Point(ptWorld); prj.Get_Projection().Assign(m_pMap->Get_Projection()); pProjector->Settings_Push(NULL); if( pProjector->Set_Parameter("CRS_PROJ4", SG_T("+proj=longlat +ellps=WGS84 +datum=WGS84")) && pProjector->Set_Parameter("SOURCE" , &prj) && pProjector->Set_Parameter("TARGET" , &gcs) && pProjector->Execute() ) { CSG_Point ptWorld_gcs = gcs.Get_Shape(0)->Get_Point(0); STATUSBAR_Set_Text(wxString::Format("X %s", SG_Double_To_Degree(ptWorld_gcs.Get_X()).c_str()), STATUSBAR_VIEW_X); STATUSBAR_Set_Text(wxString::Format("Y %s", SG_Double_To_Degree(ptWorld_gcs.Get_Y()).c_str()), STATUSBAR_VIEW_Y); pProjector->Settings_Pop(); } else { pProjector->Settings_Pop(); pProjector = NULL; } SG_UI_Progress_Lock(false); SG_UI_Msg_Lock (false); } } if( !pProjector ) { STATUSBAR_Set_Text(wxString::Format("X %f", ptWorld.Get_X()), STATUSBAR_VIEW_X); STATUSBAR_Set_Text(wxString::Format("Y %f", ptWorld.Get_Y()), STATUSBAR_VIEW_Y); } if( m_Mode == MAP_MODE_DISTANCE ) { STATUSBAR_Set_Text(wxString::Format("D %f", m_Distance + m_Distance_Move), STATUSBAR_VIEW_Z); } else if( Get_Active_Layer() ) { STATUSBAR_Set_Text(wxString::Format("Z %s", Get_Active_Layer()->Get_Value(ptWorld, _Get_World(2.0)).c_str()), STATUSBAR_VIEW_Z); } else { STATUSBAR_Set_Text("Z", STATUSBAR_VIEW_Z); } bBuisy = false; } }
//--------------------------------------------------------- bool CACTIVE::Set_Active(CWKSP_Base_Item *pItem) { if( pItem == m_pItem ) { return( true ); } //----------------------------------------------------- m_pItem = pItem; if( m_pParameters ) m_pParameters->Set_Parameters(m_pItem); Update_Description(); STATUSBAR_Set_Text(SG_T(""), STATUSBAR_VIEW_X); STATUSBAR_Set_Text(SG_T(""), STATUSBAR_VIEW_Y); STATUSBAR_Set_Text(SG_T(""), STATUSBAR_VIEW_Z); //----------------------------------------------------- if( m_pItem == NULL ) { if( g_pSAGA_Frame ) g_pSAGA_Frame->Set_Pane_Caption(this, _TL("Properties")); if( g_pData_Buttons ) g_pData_Buttons->Refresh(); if( g_pMap_Buttons ) g_pMap_Buttons ->Refresh(); _Hide_Page(m_pHistory); _Hide_Page(m_pLegend); _Hide_Page(m_pAttributes); SendSizeEvent(); return( true ); } //----------------------------------------------------- if( g_pSAGA_Frame ) g_pSAGA_Frame->Set_Pane_Caption(this, wxString(_TL("Properties")) + ": " + m_pItem->Get_Name()); //----------------------------------------------------- if( Get_Active_Data_Item() ) { _Show_Page(m_pHistory ); } else { _Hide_Page(m_pHistory ); } if( Get_Active_Layer() || Get_Active_Map() ) { _Show_Page(m_pLegend ); } else { _Hide_Page(m_pLegend ); } if( Get_Active_Layer() ) { _Show_Page(m_pAttributes); } else { _Hide_Page(m_pAttributes); } //----------------------------------------------------- if( g_pData_Buttons ) g_pData_Buttons->Refresh(false); if( g_pMap_Buttons ) g_pMap_Buttons ->Refresh(false); if( g_pData_Source ) g_pData_Source->Set_Data_Source(m_pItem); //----------------------------------------------------- CSG_Data_Object *pObject = Get_Active_Data_Item() ? Get_Active_Data_Item()->Get_Object() : NULL; if( SG_Get_Data_Manager().Exists(pObject) && ( (pObject->Get_ObjectType() == DATAOBJECT_TYPE_Table && ((CSG_Table *)pObject)->Get_Selection_Count() > 0) || (pObject->Get_ObjectType() == DATAOBJECT_TYPE_TIN && ((CSG_Shapes *)pObject)->Get_Selection_Count() > 0) || (pObject->Get_ObjectType() == DATAOBJECT_TYPE_PointCloud && ((CSG_PointCloud *)pObject)->Get_Selection_Count() > 0) || (pObject->Get_ObjectType() == DATAOBJECT_TYPE_Shapes && ((CSG_Shapes *)pObject)->Get_Selection_Count() > 0)) ) { g_pData->Update_Views(pObject); } SendSizeEvent(); return( true ); }