mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 06:38:13 -05:00
Migrate all assert macros in ApplicationLibCode to CAF_ASSERT and remove every use of cvfAssert.h. CVF_ASSERT is replaced one to one. CVF_TIGHT_ASSERT is also replaced by CAF_ASSERT, which is semantically exact: CVF_ENABLE_TIGHT_ASSERTS is 1 only under _DEBUG, and that is what CAF_ASSERT now does. The two CVF_FAIL_MSG sites become CAF_ASSERT( false && "message" ), preserving the message with the idiom already used elsewhere in the code base. Counts before and after: CVF_ASSERT 1044 to 0, CVF_TIGHT_ASSERT 66 to 0, CVF_FAIL_MSG 2 to 0, cvfAssert.h references 154 to 0. Include handling: files that included cvfAssert.h directly now include cafAssert.h instead, includes left dead by the migration are removed, and files that were relying on cvfAssert.h transitively get an explicit cafAssert.h. Files that reach cafAssert.h through another caf header are left unchanged; a missing include here is a compile error, not a silently disabled assert. ResultStatisticsCache links only LibCore and therefore had no path to cafAssert.h. Add the cafPdmCore directory as a private include path rather than linking the library, since cafAssert.h is header only. Note that this stops these asserts from firing in Release and RelWithDebInfo, where CVF_ASSERT was previously active.
203 lines
7.5 KiB
C++
203 lines
7.5 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2018- Equinor ASA
|
|
//
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicToggleMeasurementModeFeature.h"
|
|
|
|
#include "RiaGuiApplication.h"
|
|
|
|
#include "Rim3dView.h"
|
|
#include "RimGridView.h"
|
|
#include "RimMeasurement.h"
|
|
#include "RimProject.h"
|
|
|
|
#include "cafAssert.h"
|
|
#include "cafCmdFeatureManager.h"
|
|
#include "cafPdmUiPropertyViewDialog.h"
|
|
#include "cafSelectionManager.h"
|
|
|
|
#include <QAction>
|
|
|
|
CAF_CMD_SOURCE_INIT( RicToggleMeasurementModeFeature, "RicToggleMeasurementModeFeature" );
|
|
CAF_CMD_SOURCE_INIT( RicTogglePolyMeasurementModeFeature, "RicTogglePolyMeasurementModeFeature" );
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleMeasurementModeFeature::refreshActionLook()
|
|
{
|
|
setupActionLook( action() );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicToggleMeasurementModeFeature::isCommandEnabled() const
|
|
{
|
|
return activeView() != nullptr;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleMeasurementModeFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
auto meas = measurement();
|
|
if ( meas->measurementMode() == RimMeasurement::MEASURE_REGULAR )
|
|
{
|
|
meas->setMeasurementMode( RimMeasurement::MEASURE_DISABLED );
|
|
}
|
|
else
|
|
{
|
|
meas->setMeasurementMode( RimMeasurement::MEASURE_REGULAR );
|
|
}
|
|
|
|
refreshActionLook();
|
|
refreshPolyMeasuremeantActionLook();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleMeasurementModeFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Measurement" );
|
|
actionToSetup->setToolTip( "Single Line Measurement (Ctrl+M)" );
|
|
actionToSetup->setIcon( QIcon( ":/Ruler.svg" ) );
|
|
actionToSetup->setCheckable( true );
|
|
|
|
auto* meas = measurement();
|
|
if ( meas && meas->measurementMode() == RimMeasurement::MEASURE_REGULAR )
|
|
{
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence( Qt::Key_Escape ) );
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+M" ) ) );
|
|
}
|
|
else
|
|
{
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+M" ) ) );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicToggleMeasurementModeFeature::isCommandChecked() const
|
|
{
|
|
auto meas = measurement();
|
|
if ( meas )
|
|
{
|
|
return meas->measurementMode() == RimMeasurement::MEASURE_REGULAR;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RimMeasurement* RicToggleMeasurementModeFeature::measurement() const
|
|
{
|
|
RiaGuiApplication* app = RiaGuiApplication::instance();
|
|
if ( !app->project() ) return nullptr;
|
|
|
|
return app->project()->measurement();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
Rim3dView* RicToggleMeasurementModeFeature::activeView() const
|
|
{
|
|
RiaApplication* app = RiaApplication::instance();
|
|
CAF_ASSERT( app );
|
|
auto view = dynamic_cast<Rim3dView*>( app->activeMainOrComparisonGridView() );
|
|
return view;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicToggleMeasurementModeFeature::refreshPolyMeasuremeantActionLook()
|
|
{
|
|
auto cmdFeature = caf::CmdFeatureManager::instance()->getCommandFeature( "RicTogglePolyMeasurementModeFeature" );
|
|
static_cast<RicTogglePolyMeasurementModeFeature*>( cmdFeature )->refreshActionLook();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTogglePolyMeasurementModeFeature::onActionTriggered( bool isChecked )
|
|
{
|
|
auto meas = measurement();
|
|
if ( meas->measurementMode() == RimMeasurement::MEASURE_POLYLINE )
|
|
{
|
|
meas->setMeasurementMode( RimMeasurement::MEASURE_DISABLED );
|
|
}
|
|
else
|
|
{
|
|
meas->setMeasurementMode( RimMeasurement::MEASURE_POLYLINE );
|
|
}
|
|
|
|
refreshActionLook();
|
|
refreshMeasurementActionLook();
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTogglePolyMeasurementModeFeature::setupActionLook( QAction* actionToSetup )
|
|
{
|
|
actionToSetup->setText( "Poly Line Measurement" );
|
|
actionToSetup->setToolTip( "Poly Line Measurement (Ctrl+Shift+M)" );
|
|
actionToSetup->setIcon( QIcon( ":/RulerPoly.svg" ) );
|
|
actionToSetup->setCheckable( true );
|
|
|
|
auto* meas = measurement();
|
|
if ( meas && meas->measurementMode() == RimMeasurement::MEASURE_POLYLINE )
|
|
{
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence( Qt::Key_Escape ) );
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+Shift+M" ) ) );
|
|
}
|
|
else
|
|
{
|
|
applyShortcutWithHintToAction( actionToSetup, QKeySequence( tr( "Ctrl+Shift+M" ) ) );
|
|
}
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicTogglePolyMeasurementModeFeature::isCommandChecked() const
|
|
{
|
|
auto meas = measurement();
|
|
if ( meas )
|
|
{
|
|
return meas->measurementMode() == RimMeasurement::MEASURE_POLYLINE;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicTogglePolyMeasurementModeFeature::refreshMeasurementActionLook()
|
|
{
|
|
auto cmdFeature = caf::CmdFeatureManager::instance()->getCommandFeature( "RicToggleMeasurementModeFeature" );
|
|
static_cast<RicToggleMeasurementModeFeature*>( cmdFeature )->refreshActionLook();
|
|
}
|