void QgsMapToolIdentifyAction::canvasReleaseEvent( QMouseEvent *e ) { if ( !mCanvas || mCanvas->isDrawing() ) { return; } resultsDialog()->clear(); connect( this, SIGNAL( identifyProgress( int, int ) ), QgisApp::instance(), SLOT( showProgress( int, int ) ) ); connect( this, SIGNAL( identifyMessage( QString ) ), QgisApp::instance(), SLOT( showStatusMessage( QString ) ) ); bool res = QgsMapToolIdentify::identify( e->x(), e->y() ); disconnect( this, SIGNAL( identifyProgress( int, int ) ), QgisApp::instance(), SLOT( showProgress( int, int ) ) ); disconnect( this, SIGNAL( identifyMessage( QString ) ), QgisApp::instance(), SLOT( showStatusMessage( QString ) ) ); QList<VectorResult>::const_iterator vresult; for ( vresult = results().mVectorResults.begin(); vresult != results().mVectorResults.end(); ++vresult ) resultsDialog()->addFeature( vresult->mLayer, vresult->mFeature, vresult->mDerivedAttributes ); QList<RasterResult>::const_iterator rresult; for ( rresult = results().mRasterResults.begin(); rresult != results().mRasterResults.end(); ++rresult ) resultsDialog()->addFeature( rresult->mLayer, rresult->mLabel, rresult->mAttributes, rresult->mDerivedAttributes ); if ( res ) { resultsDialog()->show(); } else { QSettings mySettings; bool myDockFlag = mySettings.value( "/qgis/dockIdentifyResults", false ).toBool(); if ( !myDockFlag ) { resultsDialog()->hide(); } else { resultsDialog()->clear(); } QgisApp::instance()->statusBar()->showMessage( tr( "No features at this position found." ) ); } }
/// Function name : wndprocSplashWindow // Description : Splash window procedure // LRESULT wndprocSplashWindow(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { SPLASH_WINDOW_DATA* pWindowData; CREATESTRUCT* pCreationData; BOOL bResult = TRUE; TRY { // Prepare pWindowData = (SPLASH_WINDOW_DATA*)GetWindowLong(hWnd, 0); // Examine message switch (iMessage) { /// [CREATE] Display window case WM_CREATE: // Prepare pCreationData = (CREATESTRUCT*)lParam; // Initialise window and store window data onSplashWindowCreate((SPLASH_WINDOW_DATA*)pCreationData->lpCreateParams, hWnd); break; /// [DESTROY] Destroy ticker case WM_DESTROY: onSplashWindowDestroy(pWindowData); break; /// [TIMER] Update window case WM_TIMER: onSplashWindowTimer(pWindowData); break; // [UNHANDLED] default: bResult = DefWindowProc(hWnd, iMessage, wParam, lParam); break; } return bResult; } /// [EXCEPTION HANDLER] CATCH3("iMessage=%s wParam=%d lParam=%d", identifyMessage(iMessage), wParam, lParam); EnableWindow(getAppWindow(), TRUE); return FALSE; }
/// Function name : dlgprocArgumentPage // Description : Window procedure for the 'Arguments' properties dialog page // // INT_PTR dlgprocArgumentPage(HWND hDialog, UINT iMessage, WPARAM wParam, LPARAM lParam) { PROPERTIES_DATA* pDialogData; POINT ptCursor; BOOL bResult; TRY { // Get dialog data pDialogData = getPropertiesDialogData(hDialog); // Examine message switch (iMessage) { /// [CONTEXT MENU] - Display arguments list context menu case WM_CONTEXTMENU: ptCursor.x = LOWORD(lParam); ptCursor.y = HIWORD(lParam); onArgumentPage_ContextMenu(pDialogData->pScriptDocument, (HWND)wParam, ptCursor); return TRUE; /// [COMMANDS] - Process Arguments List menu items and button commands case WM_COMMAND: if (bResult = onArgumentPage_Command(pDialogData->pScriptDocument, hDialog, LOWORD(wParam), HIWORD(wParam), (HWND)lParam)) return bResult; break; /// [NOTIFICATION] - Handle ListView notifications case WM_NOTIFY: if (bResult = onArgumentPage_Notify(pDialogData->pScriptDocument, hDialog, (NMHDR*)lParam)) return bResult; break; /// [THEME CHANGED] Update ListView background colour case WM_THEMECHANGED: ListView_SetBkColor(GetControl(hDialog, IDC_ARGUMENTS_LIST), getThemeSysColour(TEXT("TAB"), COLOR_WINDOW)); return TRUE; } } /// [EXCEPTION HANDLER] CATCH3("iMessage=%s wParam=%d lParam=%d", identifyMessage(iMessage), wParam, lParam); // Pass to base proc return dlgprocPropertiesPage(hDialog, iMessage, wParam, lParam, PP_SCRIPT_ARGUMENTS); }
QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, int y, IdentifyMode mode, const QList<QgsMapLayer*>& layerList, const LayerType& layerType ) { QList<IdentifyResult> results; mLastPoint = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y ); mLastExtent = mCanvas->extent(); mLastMapUnitsPerPixel = mCanvas->mapUnitsPerPixel(); if ( mode == DefaultQgsSetting ) { QSettings settings; mode = static_cast<IdentifyMode>( settings.value( "/Map/identifyMode", 0 ).toInt() ); } if ( mode == LayerSelection ) { QList<IdentifyResult> results = identify( x, y, TopDownAll, layerList, layerType ); QPoint globalPos = mCanvas->mapToGlobal( QPoint( x + 5, y + 5 ) ); return mIdentifyMenu->exec( results, globalPos ); } else if ( mode == ActiveLayer && layerList.isEmpty() ) { QgsMapLayer *layer = mCanvas->currentLayer(); if ( !layer ) { emit identifyMessage( tr( "No active layer. To identify features, you must choose an active layer." ) ); return results; } QApplication::setOverrideCursor( Qt::WaitCursor ); identifyLayer( &results, layer, mLastPoint, mLastExtent, mLastMapUnitsPerPixel, layerType ); } else { QApplication::setOverrideCursor( Qt::WaitCursor ); QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); int layerCount; if ( layerList.isEmpty() ) layerCount = mCanvas->layerCount(); else layerCount = layerList.count(); for ( int i = 0; i < layerCount; i++ ) { QgsMapLayer *layer; if ( layerList.isEmpty() ) layer = mCanvas->layer( i ); else layer = layerList.value( i ); emit identifyProgress( i, mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying on %1..." ).arg( layer->name() ) ); if ( noIdentifyLayerIdList.contains( layer->id() ) ) continue; if ( identifyLayer( &results, layer, mLastPoint, mLastExtent, mLastMapUnitsPerPixel, layerType ) ) { if ( mode == TopDownStopAtFirst ) break; } } emit identifyProgress( mCanvas->layerCount(), mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying done." ) ); } QApplication::restoreOverrideCursor(); return results; }
QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, int y, IdentifyMode mode, QList<QgsMapLayer*> layerList, LayerType layerType ) { QList<IdentifyResult> results; mLastPoint = mCanvas->getCoordinateTransform()->toMapCoordinates( x, y ); mLastExtent = mCanvas->extent(); mLastMapUnitsPerPixel = mCanvas->mapUnitsPerPixel(); if ( mode == DefaultQgsSetting ) { QSettings settings; mode = static_cast<IdentifyMode>( settings.value( "/Map/identifyMode", 0 ).toInt() ); } if ( mode == LayerSelection ) { // fill map of layer / identify results mLayerIdResults.clear(); QList<IdentifyResult> idResult = identify( x, y, TopDownAll ); QList<IdentifyResult>::const_iterator it = idResult.constBegin(); for ( ; it != idResult.constEnd(); ++it ) { QgsMapLayer *layer = it->mLayer; if ( mLayerIdResults.contains( layer ) ) { mLayerIdResults[layer].append( *it ); } else { mLayerIdResults.insert( layer, QList<IdentifyResult>() << *it ); } } //fill selection menu with entries from mmLayerIdResults QMenu layerSelectionMenu; QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator resultIt = mLayerIdResults.constBegin(); for ( ; resultIt != mLayerIdResults.constEnd(); ++resultIt ) { QAction* action = new QAction( QString( "%1 (%2)" ).arg( resultIt.key()->name() ).arg( resultIt.value().size() ), 0 ); action->setData( resultIt.key()->id() ); //add point/line/polygon icon QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( resultIt.key() ); if ( vl ) { switch ( vl->geometryType() ) { case QGis::Point: action->setIcon( QgsApplication::getThemeIcon( "/mIconPointLayer.png" ) ); break; case QGis::Line: action->setIcon( QgsApplication::getThemeIcon( "/mIconLineLayer.png" ) ); break; case QGis::Polygon: action->setIcon( QgsApplication::getThemeIcon( "/mIconPolygonLayer.png" ) ); break; default: break; } } else if ( resultIt.key()->type() == QgsMapLayer::RasterLayer ) { action->setIcon( QgsApplication::getThemeIcon( "/mIconRaster.png" ) ); } connect( action, SIGNAL( hovered() ), this, SLOT( handleMenuHover() ) ); layerSelectionMenu.addAction( action ); } if ( mLayerIdResults.size() > 1 ) { QAction *action = new QAction( tr( "All (%1)" ).arg( idResult.size() ), 0 ); connect( action, SIGNAL( hovered() ), this, SLOT( handleMenuHover() ) ); layerSelectionMenu.addAction( action ); } // exec layer selection menu QPoint globalPos = mCanvas->mapToGlobal( QPoint( x + 5, y + 5 ) ); QAction* selectedAction = layerSelectionMenu.exec( globalPos ); if ( selectedAction ) { if ( selectedAction->data().toString().isEmpty() ) { results = idResult; } else { QgsMapLayer* selectedLayer = QgsMapLayerRegistry::instance()->mapLayer( selectedAction->data().toString() ); QMap< QgsMapLayer*, QList<IdentifyResult> >::const_iterator sIt = mLayerIdResults.find( selectedLayer ); if ( sIt != mLayerIdResults.constEnd() ) { results = sIt.value(); } } } deleteRubberBands(); } else if ( mode == ActiveLayer && layerList.isEmpty() ) { QgsMapLayer *layer = mCanvas->currentLayer(); if ( !layer ) { emit identifyMessage( tr( "No active layer. To identify features, you must choose an active layer." ) ); return results; } QApplication::setOverrideCursor( Qt::WaitCursor ); identifyLayer( &results, layer, mLastPoint, mLastExtent, mLastMapUnitsPerPixel, layerType ); } else { QApplication::setOverrideCursor( Qt::WaitCursor ); QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); int layerCount; if ( layerList.isEmpty() ) layerCount = mCanvas->layerCount(); else layerCount = layerList.count(); for ( int i = 0; i < layerCount; i++ ) { QgsMapLayer *layer ; if ( layerList.isEmpty() ) layer = mCanvas->layer( i ); else layer = layerList.value( i ); emit identifyProgress( i, mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying on %1..." ).arg( layer->name() ) ); if ( noIdentifyLayerIdList.contains( layer->id() ) ) continue; if ( identifyLayer( &results, layer, mLastPoint, mLastExtent, mLastMapUnitsPerPixel, layerType ) ) { if ( mode == TopDownStopAtFirst ) break; } } emit identifyProgress( mCanvas->layerCount(), mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying done." ) ); } QApplication::restoreOverrideCursor(); return results; }
void QgsMapToolIdentify::canvasReleaseEvent( QMouseEvent *e ) { if ( !mCanvas || mCanvas->isDrawing() ) { return; } results()->clear(); QSettings settings; int identifyMode = settings.value( "/Map/identifyMode", 0 ).toInt(); bool res = false; if ( identifyMode == 0 ) { QgsMapLayer *layer = mCanvas->currentLayer(); if ( !layer ) { QMessageBox::warning( mCanvas, tr( "No active layer" ), tr( "To identify features, you must choose an active layer by clicking on its name in the legend" ) ); return; } QApplication::setOverrideCursor( Qt::WaitCursor ); res = identifyLayer( layer, e->x(), e->y() ); QApplication::restoreOverrideCursor(); } else { connect( this, SIGNAL( identifyProgress( int, int ) ), QgisApp::instance(), SLOT( showProgress( int, int ) ) ); connect( this, SIGNAL( identifyMessage( QString ) ), QgisApp::instance(), SLOT( showStatusMessage( QString ) ) ); QApplication::setOverrideCursor( Qt::WaitCursor ); QStringList noIdentifyLayerIdList = QgsProject::instance()->readListEntry( "Identify", "/disabledLayers" ); for ( int i = 0; i < mCanvas->layerCount(); i++ ) { QgsMapLayer *layer = mCanvas->layer( i ); emit identifyProgress( i, mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying on %1..." ).arg( layer->name() ) ); if ( noIdentifyLayerIdList.contains( layer->id() ) ) continue; if ( identifyLayer( layer, e->x(), e->y() ) ) { res = true; if ( identifyMode == 1 ) break; } } emit identifyProgress( mCanvas->layerCount(), mCanvas->layerCount() ); emit identifyMessage( tr( "Identifying done." ) ); disconnect( this, SIGNAL( identifyProgress( int, int ) ), QgisApp::instance(), SLOT( showProgress( int, int ) ) ); disconnect( this, SIGNAL( identifyMessage( QString ) ), QgisApp::instance(), SLOT( showStatusMessage( QString ) ) ); QApplication::restoreOverrideCursor(); } if ( res ) { results()->show(); } else { QSettings mySettings; bool myDockFlag = mySettings.value( "/qgis/dockIdentifyResults", false ).toBool(); if ( !myDockFlag ) { results()->hide(); } else { results()->clear(); } QgisApp::instance()->statusBar()->showMessage( tr( "No features at this position found." ) ); } }
/// Function name : dlgprocVariablesPage // Description : Window procedure for the 'VariableDependencies' properties dialog page // // INT_PTR dlgprocVariablesPage(HWND hPage, UINT iMessage, WPARAM wParam, LPARAM lParam) { PROPERTIES_DATA* pDialogData; NMHDR* pMessage; TRY { // Get properties dialog data pDialogData = getPropertiesDialogData(hPage); switch (iMessage) { /// [COMMAND PROCESSING] case WM_COMMAND: switch (LOWORD(wParam)) { // [REFRESH VARIABLE DEPENDENCIES] case IDM_VARIABLES_REFRESH: // menu item case IDC_REFRESH_VARIABLES: // button updateScriptVariablesPage_List(pDialogData, hPage); return TRUE; // [PROJECT VARIABLES] case IDC_PROJECT_VARIABLES: displayProjectVariablesDialog(pDialogData->hSheetDlg); return TRUE; } break; /// [CONTEXT MENU] case WM_CONTEXTMENU: return onDependenciesPage_ContextMenu(pDialogData->pScriptDocument, (HWND)wParam, LOWORD(lParam), HIWORD(lParam)); /// [NOTIFICATION] - Handle ListView notifications case WM_NOTIFY: pMessage = (NMHDR*)lParam; // Examine notification switch (pMessage->code) { // [REQUEST DEPENDENCY DATA] Supply VariableDependency data case LVN_GETDISPINFO: onVariablesPage_RequestData(pDialogData, hPage, (NMLVDISPINFO*)lParam); return TRUE; // [CUSTOM DRAW] Draw Refresh button and ListView case NM_CUSTOMDRAW: switch (pMessage->idFrom) { case IDC_REFRESH_VARIABLES: onCustomDrawButton(hPage, pMessage, ITS_MEDIUM, TEXT("REFRESH_ICON"), TRUE); return TRUE; case IDC_PROJECT_VARIABLES: onCustomDrawButton(hPage, pMessage, ITS_MEDIUM, TEXT("VARIABLE_ICON"), TRUE); return TRUE; case IDC_VARIABLES_LIST: SetWindowLong(hPage, DWL_MSGRESULT, onCustomDrawListView(hPage, pMessage->hwndFrom, (NMLVCUSTOMDRAW*)pMessage)); return TRUE; } break; } break; /// [THEME CHANGED] Update ListView background colour case WM_THEMECHANGED: ListView_SetBkColor(GetControl(hPage, IDC_VARIABLES_LIST), getThemeSysColour(TEXT("TAB"), COLOR_WINDOW)); return TRUE; } // Pass to base proc return dlgprocPropertiesPage(hPage, iMessage, wParam, lParam, PP_SCRIPT_VARIABLES); } /// [EXCEPTION HANDLER] CATCH3("iMessage=%s wParam=%d lParam=%d", identifyMessage(iMessage), wParam, lParam); // Pass to base proc return dlgprocPropertiesPage(hPage, iMessage, wParam, lParam, PP_SCRIPT_VARIABLES); }