Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual dicom browser enhs #1217

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Libs/Core/ctkAbstractJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ctkAbstractJob::ctkAbstractJob()
this->MaximumConcurrentJobsPerType = 20;
this->Priority = QThread::Priority::LowPriority;
this->CreationDateTime = QDateTime::currentDateTime();
this->DestroyAfterUse = false;
}

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -212,20 +213,27 @@ void ctkAbstractJob::setRunningThreadID(QString runningThreadID)
}

//----------------------------------------------------------------------------
QString ctkAbstractJob::loggedText() const
QString ctkAbstractJob::log() const
{
return this->LoggedText;
return this->Log;
}

//----------------------------------------------------------------------------
void ctkAbstractJob::setLoggedText(QString loggedText)
void ctkAbstractJob::addLog(QString log)
{
if (loggedText.isEmpty())
{
return;
}
this->Log += log;
}

this->LoggedText += loggedText;
//----------------------------------------------------------------------------
bool ctkAbstractJob::destroyAfterUse() const
{
return this->DestroyAfterUse;
}

//----------------------------------------------------------------------------
void ctkAbstractJob::setDestroyAfterUse(bool destroyAfterUse)
{
this->DestroyAfterUse = destroyAfterUse;
}

//----------------------------------------------------------------------------
Expand Down
24 changes: 18 additions & 6 deletions Libs/Core/ctkAbstractJob.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class CTK_CORE_EXPORT ctkAbstractJob : public QObject
Q_PROPERTY(QDateTime startDateTime READ startDateTime);
Q_PROPERTY(QDateTime completionDateTime READ completionDateTime);
Q_PROPERTY(QString runningThreadID READ runningThreadID WRITE setRunningThreadID);
Q_PROPERTY(QString loggedText READ loggedText WRITE setLoggedText);
Q_PROPERTY(QString log READ log);
Q_PROPERTY(bool destroyAfterUse READ destroyAfterUse WRITE setDestroyAfterUse);

public:
explicit ctkAbstractJob();
Expand Down Expand Up @@ -157,8 +158,8 @@ class CTK_CORE_EXPORT ctkAbstractJob : public QObject

///@{
/// Logged Text
QString loggedText() const;
void setLoggedText(QString loggedText);
QString log() const;
void addLog(QString log);
///@}

/// Generate worker for job
Expand All @@ -168,7 +169,7 @@ class CTK_CORE_EXPORT ctkAbstractJob : public QObject
Q_INVOKABLE virtual ctkAbstractJob* clone() const = 0;

/// Logger report string formatting for specific job
Q_INVOKABLE virtual QString loggerReport(const QString& status) const = 0;
Q_INVOKABLE virtual QString loggerReport(const QString& status) = 0;

/// Return the QVariant value of this job.
///
Expand All @@ -177,6 +178,16 @@ class CTK_CORE_EXPORT ctkAbstractJob : public QObject
/// \sa ctkJobDetail
Q_INVOKABLE virtual QVariant toVariant();

/// Free used resources from job after worker is done
Q_INVOKABLE virtual void releaseResources() = 0;

///@{
/// Destroy job object after worker is done
/// default: false
bool destroyAfterUse() const;
void setDestroyAfterUse(bool destroyAfterUse);
///@}

Q_SIGNALS:
void started();
void userStopped();
Expand All @@ -197,7 +208,8 @@ class CTK_CORE_EXPORT ctkAbstractJob : public QObject
QDateTime StartDateTime;
QDateTime CompletionDateTime;
QString RunningThreadID;
QString LoggedText;
QString Log;
bool DestroyAfterUse;

private:
Q_DISABLE_COPY(ctkAbstractJob)
Expand All @@ -215,7 +227,7 @@ struct CTK_CORE_EXPORT ctkJobDetail {
this->StartDateTime = job.startDateTime().toString("HH:mm:ss.zzz ddd dd MMM yyyy");
this->CompletionDateTime = job.completionDateTime().toString("HH:mm:ss.zzz ddd dd MMM yyyy");
this->RunningThreadID = job.runningThreadID();
this->Logging = job.loggedText();
this->Logging = job.log();
}
virtual ~ctkJobDetail() = default;

Expand Down
133 changes: 132 additions & 1 deletion Libs/Core/ctkCorePythonQtDecorators.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
// CTK includes
#include <ctkAbstractJob.h> // For ctkJobDetail
#include <ctkBooleanMapper.h>
#include <ctkUtils.h>
#include <ctkErrorLogContext.h>
#include <ctkLogger.h>
#include <ctkUtils.h>
#include <ctkWorkflowStep.h>
#include <ctkWorkflowTransitions.h>

Expand All @@ -39,6 +40,8 @@
// for non-static methods.
//

static ctkLogger logger("org.commontk.core.ctkCorePythonQtDecorators");

/// \ingroup Core
class ctkCorePythonQtDecorators : public QObject
{
Expand Down Expand Up @@ -245,21 +248,149 @@ public Q_SLOTS:

void setJobClass(ctkJobDetail* td, const QString& jobClass)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::setJobClass - Invalid ctkJobDetail");
return;
}

td->JobClass = jobClass;
}
QString jobClass(ctkJobDetail* td)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::jobClass - Invalid ctkJobDetail");
return "";
}

return td->JobClass;
}

void setJobUID(ctkJobDetail* td, const QString& jobUID)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::setJobUID - Invalid ctkJobDetail");
return;
}

td->JobUID = jobUID;
}
QString JobUID(ctkJobDetail* td)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::JobUID - Invalid ctkJobDetail");
return "";
}

return td->JobUID;
}

void setCreationDateTime(ctkJobDetail* td, QString creationDateTime)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::setCreationDateTime - Invalid ctkJobDetail");
return;
}

td->CreationDateTime = creationDateTime;
}
QString creationDateTime(ctkJobDetail* td)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::creationDateTime - Invalid ctkJobDetail");
return "";
}

return td->CreationDateTime;
}

void setStartDateTime(ctkJobDetail* td, QString startDateTime)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::setStartDateTime - Invalid ctkJobDetail");
return;
}

td->StartDateTime = startDateTime;
}
QString startDateTime(ctkJobDetail* td)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::startDateTime - Invalid ctkJobDetail");
return "";
}

return td->StartDateTime;
}

void setCompletionDateTime(ctkJobDetail* td, QString completionDateTime)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::setCompletionDateTime - Invalid ctkJobDetail");
return;
}

td->CompletionDateTime = completionDateTime;
}
QString completionDateTime(ctkJobDetail* td)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::completionDateTime - Invalid ctkJobDetail");
return "";
}

return td->CompletionDateTime;
}

void setRunningThreadID(ctkJobDetail* td, QString runningThreadID)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::setRunningThreadID - Invalid ctkJobDetail");
return;
}

td->RunningThreadID = runningThreadID;
}
QString runningThreadID(ctkJobDetail* td)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::runningThreadID - Invalid ctkJobDetail");
return "";
}

return td->RunningThreadID;
}

void setLogging(ctkJobDetail* td, QString logging)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::setLogging - Invalid ctkJobDetail");
return;
}
td->Logging = logging;
}
QString logging(ctkJobDetail* td)
{
if (td == nullptr)
{
logger.error("ctkJobDetail::logging - Invalid ctkJobDetail");
return "";
}

return td->Logging;
}
};

//-----------------------------------------------------------------------------
Expand Down
Loading
Loading