Replace RiaScheduler with caf:Scheduler

Remove ProgressState
Use caf::SchedulerCallable to communicate state for the progress dialog.
Use std::atomic to ensure thread safety
This commit is contained in:
Magne Sjaastad 2025-01-04 09:15:44 +01:00
parent 207294c446
commit 1251a2750e
13 changed files with 22 additions and 133 deletions

View File

@ -31,7 +31,6 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaRftDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaDateTimeDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaPlotCollectionScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.h
@ -73,7 +72,6 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaRftDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaDateTimeDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaPlotCollectionScheduler.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaOsduDefines.cpp
@ -86,15 +84,6 @@ list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES})
set(QT_MOC_HEADERS
${QT_MOC_HEADERS}
${CMAKE_CURRENT_LIST_DIR}/RiaConsoleApplication.h
${CMAKE_CURRENT_LIST_DIR}/RiaGuiApplication.h
${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaPlotWindowRedrawScheduler.h
${CMAKE_CURRENT_LIST_DIR}/RiaScheduler.h
)
source_group(
"Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES}
${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake

View File

@ -32,7 +32,6 @@
#include "RiuViewer.h"
#include "cafPdmUiTreeView.h"
#include "cafProgressState.h"
#include <QTimer>
#include <QTreeView>

View File

@ -18,9 +18,8 @@
#pragma once
#include "RiaScheduler.h"
#include "cafPdmPointer.h"
#include "cafScheduler.h"
#include <vector>
@ -29,7 +28,7 @@ class RimEclipseCase;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiaCompletionTypeCalculationScheduler : public RiaScheduler
class RiaCompletionTypeCalculationScheduler : public caf::Scheduler
{
Q_OBJECT;

View File

@ -21,8 +21,6 @@
#include "RimAbstractPlotCollection.h"
#include "RimViewWindow.h"
#include "cafProgressState.h"
#include <QTimer>
//--------------------------------------------------------------------------------------------------

View File

@ -18,14 +18,14 @@
#pragma once
#include "RiaScheduler.h"
#include "cafScheduler.h"
class RimPlotCollection;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RiaPlotCollectionScheduler : public RiaScheduler
class RiaPlotCollectionScheduler : public caf::Scheduler
{
public:
RiaPlotCollectionScheduler();

View File

@ -18,7 +18,8 @@
#pragma once
#include "RiaDefines.h"
#include "RiaScheduler.h"
#include "cafScheduler.h"
#include <QPointer>
@ -29,7 +30,7 @@ class RiuMultiPlotPage;
class RiuMultiPlotBook;
class RiuPlotWidget;
class RiaPlotWindowRedrawScheduler : public RiaScheduler
class RiaPlotWindowRedrawScheduler : public caf::Scheduler
{
Q_OBJECT

View File

@ -18,9 +18,9 @@
#pragma once
#include "RiaScheduler.h"
#include "cafScheduler.h"
class RiaQuickAccessScheduler : public RiaScheduler
class RiaQuickAccessScheduler : public caf::Scheduler
{
public:
RiaQuickAccessScheduler();

View File

@ -18,7 +18,7 @@
#pragma once
#include "RiaScheduler.h"
#include "cafScheduler.h"
#include "cafPdmPointer.h"
@ -26,7 +26,7 @@
class Rim3dView;
class RiaViewRedrawScheduler : public RiaScheduler
class RiaViewRedrawScheduler : public caf::Scheduler
{
public:
RiaViewRedrawScheduler();

View File

@ -23,7 +23,7 @@
#include "RicHoloLensSessionManager.h"
#include "cafCmdFeatureManager.h"
#include "cafProgressState.h"
#include "cafScheduler.h"
#include <QCoreApplication>
#include <QTimer>
@ -86,7 +86,7 @@ void RicExportToSharingServerScheduler::triggerUpdateSession()
//--------------------------------------------------------------------------------------------------
void RicExportToSharingServerScheduler::slotTriggerUpdateSessionWhenReady()
{
if ( caf::ProgressState::isActive() )
if ( caf::SchedulerCallable::instance()->isScheduledTaskBlocked() )
{
startTimer( 100 );
return;

View File

@ -11,51 +11,6 @@ if(MSVC)
add_definitions(-DNOMINMAX)
endif(MSVC)
# These headers need to go through Qt's MOC compiler
set(MOC_HEADER_FILES
cafPdmUiCheckBoxDelegate.h
cafPdmUiCheckBoxEditor.h
cafPdmUiCheckBoxTristateEditor.h
cafPdmUiColorEditor.h
cafPdmUiComboBoxEditor.h
cafPdmUiDateEditor.h
cafPdmUiTimeEditor.h
cafPdmUiDefaultObjectEditor.h
cafPdmUiDoubleSliderEditor.h
cafPdmUiFilePathEditor.h
cafPdmUiLineEditor.h
cafPdmUiListEditor.h
cafPdmUiListView.h
cafPdmUiListViewEditor.h
cafPdmUiPropertyView.h
cafPdmUiPushButtonEditor.h
cafPdmUiActionPushButtonEditor.h
cafPdmUiSliderEditor.h
cafPdmUiTableView.h
cafPdmUiTableViewDelegate.h
cafPdmUiTableViewEditor.h
cafPdmUiTableViewQModel.h
cafPdmUiTextEditor.h
cafPdmUiToolButtonEditor.h
cafPdmUiToolButtonCallbackEditor.h
cafPdmUiTreeView.h
cafPdmUiTreeViewQModel.h
cafPdmUiTreeViewEditor.h
cafUiProcess.h
QMinimizePanel.h
cafQStyledProgressBar.h
cafPdmUiTreeSelectionEditor.h
cafPdmUiTreeSelectionQModel.h
cafPdmUiFormLayoutObjectEditor.h
cafPdmUiDoubleValueEditor.h
cafPdmUniqueIdValidator.h
cafPdmDoubleStringValidator.h
cafPdmUiPickableLineEditor.h
cafPdmUiLabelEditor.h
cafPdmUiCheckBoxAndTextEditor.h
cafPdmUiValueRangeEditor.h
)
find_package(
Qt6
COMPONENTS
@ -184,9 +139,7 @@ set(PROJECT_FILES
cafPdmUiFieldLabelEditorHandle.cpp
)
add_library(
${PROJECT_NAME} ${PROJECT_FILES} ${MOC_SOURCE_FILES} ${QRC_FILES_CPP}
)
add_library(${PROJECT_NAME} ${PROJECT_FILES} ${QRC_FILES_CPP})
if(MSVC)
set_target_properties(

View File

@ -43,7 +43,7 @@
#include "cafAssert.h"
#include "cafMemoryInspector.h"
#include "cafProgressState.h"
#include "cafScheduler.h"
#include <QApplication>
#include <QCoreApplication>
@ -375,14 +375,6 @@ static QString currentComposedLabel()
return labelText;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool ProgressState::isActive()
{
return !maxProgressStack().empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -476,8 +468,9 @@ ProgressInfoBlocker::~ProgressInfoBlocker()
///
//==================================================================================================
std::atomic<bool> ProgressInfoStatic::s_running = false;
bool ProgressInfoStatic::s_disabled = false;
bool ProgressInfoStatic::s_running = false;
bool ProgressInfoStatic::s_isButtonConnected = false;
bool ProgressInfoStatic::s_shouldProcessEvents = true;
@ -536,6 +529,8 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo,
titleStack().push_back( title );
descriptionStack().push_back( "" );
caf::SchedulerCallable::instance()->registerCallable( []() { return s_running.load(); } );
if ( dialog )
{
dialog->setMaximum( static_cast<int>( currentTotalMaxProgressValue() ) );

View File

@ -114,7 +114,9 @@ private:
private:
friend class ProgressInfoBlocker;
friend class ProgressInfoEventProcessingBlocker;
static bool s_running;
static std::atomic<bool> s_running;
static bool s_disabled;
static bool s_isButtonConnected;
static bool s_shouldProcessEvents;

View File

@ -1,47 +0,0 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library 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.
//
// This library 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.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library 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 Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace caf
{
class ProgressState
{
public:
static bool isActive();
};
} // namespace caf