Commit c581b6d6 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED force CCC: if an action return with status ABORTED, a CAMITK_WARNING should be logged

parent a59a9ce6
......@@ -96,7 +96,7 @@ Action::ApplyStatus RegionGrowing::apply() {
// this call works only with a GUI (i.e. if theWidget exists)
if ((input == NULL) || (rgWidget == NULL)) {
CAMITK_WARNING("RegionGrowing::apply(): this action cannot be called without a GUI (input data are required to be set manually.")
CAMITK_WARNING("RegionGrowing cannot be called without a GUI (input data are required to be set manually.")
return ABORTED;
}
......
......@@ -78,7 +78,7 @@ Action::ApplyStatus GenerateModel::apply() {
// ask the user
originalFilename = QFileDialog::getSaveFileName( NULL, "Generate Model", "", "ModelingML (*.mml)" );
if ( originalFilename.isNull() ) {
CAMITK_WARNING("GenerateModel::apply(): filename required.")
CAMITK_WARNING("Generate Model: filename required.")
return ABORTED;
}
}
......
......@@ -25,6 +25,7 @@
#include "CloseAction.h"
#include <Application.h>
#include <Log.h>
using namespace camitk;
......@@ -72,5 +73,7 @@ Action::ApplyStatus CloseAction::apply() {
it++;
}
// CCC Exception: just a trace message as the user voluntarily aborted the action
CAMITK_TRACE_IF((it == allTopLevel.constEnd()), "Close: action aborted by user")
return (it == allTopLevel.constEnd()) ? SUCCESS : ABORTED;
}
......@@ -73,8 +73,8 @@ Action::ApplyStatus CloseAllAction::apply() {
return SUCCESS;
}
else {
// just an information as the user volontarily canceled the action
CAMITK_INFO("CloseAllAction::apply(): action canceled by user")
// CCC Exception: just a trace message as the user voluntarily aborted the action
CAMITK_TRACE("CloseAllAction: action canceled by user")
return ABORTED;
}
}
......
......@@ -98,8 +98,8 @@ Action::ApplyStatus OpenAction::apply() {
}
else {
Application::showStatusBarMessage(tr ("Open aborted."));
// just info as the user voluntarily did not fill the filename
CAMITK_INFO("OpenAction::apply(): file is required. Action aborted.")
// CCC Exception: just a trace message as the user voluntarily aborted the action
CAMITK_TRACE("Open: a file is required. Action aborted.")
return ABORTED;
}
}
......
......@@ -122,7 +122,7 @@ Action::ApplyStatus OpenFile::apply() {
return SUCCESS;
}
else {
CAMITK_WARNING("OpenFile::apply(): filename is required. Action aborted.")
CAMITK_WARNING("Open File: a filename is required. Action aborted.")
return ABORTED;
}
}
......
......@@ -199,8 +199,8 @@ Action::ApplyStatus SaveAsAction::apply() {
}
else {
Application::showStatusBarMessage( tr ( "Saving aborted" ), 2000 );
// just an information as the user volontarily canceled the action
CAMITK_INFO("SaveAsAction::apply(): filename is required. Action aborted.")
// CCC Exception: just a trace message as the user voluntarily aborted the action
CAMITK_TRACE("SaveAsAction: a filename is required. Action aborted.")
return ABORTED;
}
......
......@@ -88,8 +88,8 @@ Action::ApplyStatus BoxVOI::apply() {
ImageComponent* input = dynamic_cast<ImageComponent*>(getTargets().last());
// this call works only with a GUI (i.e. if theWidget exists)
if ((input == NULL) || (rgWidget == NULL)) {
CAMITK_WARNING("BoxVOI::apply(): this action cannot be called without a GUI (input data are required to be set manually). Action Aborted.")
if ((input == nullptr) || (rgWidget == nullptr)) {
CAMITK_WARNING("BoxVOI: this action cannot be called without a GUI (input data are required to be set manually). Action Aborted.")
return ABORTED;
}
......@@ -101,7 +101,7 @@ Action::ApplyStatus BoxVOI::apply() {
process(input);
}
else {
CAMITK_WARNING("BoxVOI::apply(): it is required to select 2 or 6 seeds to apply this action. Action Aborted.")
CAMITK_WARNING("BoxVOI: it is required to select 2 or 6 seeds to apply this action. Action Aborted.")
return ABORTED;
}
return SUCCESS;
......@@ -120,7 +120,7 @@ Action::ApplyStatus BoxVOI::apply(QList<QVector3D>* seedPoints) {
process(input);
}
else {
CAMITK_WARNING("BoxVOI::apply(): it is required to select 2 or 6 seeds to apply this action. Action Aborted.")
CAMITK_WARNING("BoxVOI: 2 or 6 seeds are required to apply this action. Action Aborted.")
return ABORTED;
}
......
......@@ -254,7 +254,7 @@ QWidget* ReorientImage::getWidget() {
Action::ApplyStatus ReorientImage::apply() {
if (!dialog) {
CAMITK_ERROR("ReorientImage::process: Calling apply() without having initializing its QWidget => this is prohibited at the moment, aborting ...");
CAMITK_WARNING("ReorientImage: cannot apply the method before the QWidget initialization. Action aborted.");
return ABORTED;
}
......@@ -264,9 +264,9 @@ Action::ApplyStatus ReorientImage::apply() {
}
// --------------- process -------------------
Action::ApplyStatus ReorientImage::process( ImageComponent* image) {
Action::ApplyStatus ReorientImage::process(ImageComponent* image) {
if (image == nullptr) {
CAMITK_WARNING("ReorientImage::apply(): ImageComponent is null. Action Aborted.")
CAMITK_WARNING("ReorientImage: an ImageComponent is required. Action Aborted.")
return ABORTED;
}
......
......@@ -70,7 +70,7 @@ Action::ApplyStatus ChangeColor::apply() {
return SUCCESS;
}
else {
CAMITK_WARNING("ChangeColor::apply(): invalid color. Action Aborted.")
CAMITK_WARNING("ChangeColor: invalid color. Action Aborted.")
return ABORTED;
}
}
......@@ -39,23 +39,23 @@ Action::ApplyStatus ComputeNormals::apply() {
MeshComponent* mesh = dynamic_cast<MeshComponent*>(getTargets().first());
if (mesh == nullptr) {
CAMITK_WARNING("ComputeNormals::apply(): mesh " + getTargets().first()->getName() + " is not a MeshComponent")
CAMITK_WARNING("Compute Normals: mesh " + getTargets().first()->getName() + " is not a MeshComponent. Action aborted.")
return ABORTED;
}
if (mesh->getPointSet() == nullptr) {
CAMITK_WARNING("ComputeNormals::apply(): the mesh point set of " + getTargets().first()->getName() + " does not have a vtkPointSet")
CAMITK_WARNING("Compute Normals: the mesh point set of " + getTargets().first()->getName() + " does not have a vtkPointSet. Action aborted.")
return ABORTED;
}
vtkSmartPointer<vtkPolyData> pData = vtkPolyData::SafeDownCast(mesh->getPointSet());
if (pData == nullptr) {
CAMITK_WARNING("ComputeNormals::apply(): the mesh point set of " + getTargets().first()->getName() + " is not a vtkPolyData")
CAMITK_WARNING("Compute Normals: the mesh point set of " + getTargets().first()->getName() + " is not a vtkPolyData. Action aborted.")
return ABORTED;
}
CAMITK_TRACE("ComputeNormals::apply(): Compute normals for mesh " + getTargets().first()->getName())
CAMITK_TRACE("Compute Normals: compute normals for mesh " + getTargets().first()->getName())
// compute normals
vtkSmartPointer<vtkPolyDataNormals> polyNormals = vtkSmartPointer<vtkPolyDataNormals>::New();
......@@ -64,8 +64,8 @@ Action::ApplyStatus ComputeNormals::apply() {
polyNormals->Update();
if (polyNormals->GetOutput()->GetPointData()->GetScalars("Normals") == nullptr) {
CAMITK_WARNING("ComputeNormals::apply(): no normals can be computed for: "
+ getTargets().first()->getName() + " (probably no 3D surface in this mesh)")
CAMITK_WARNING("Compute Normals: no normals can be computed for: "
+ getTargets().first()->getName() + " (probably no 3D surface in this mesh). Action aborted.")
return ABORTED;
}
......
......@@ -59,23 +59,23 @@ Action::ApplyStatus ExtractSelection::apply() {
MeshComponent* targetMesh = dynamic_cast<MeshComponent*>(getTargets().last());
if (targetMesh == nullptr) {
CAMITK_WARNING("ExtractSelection::apply(): mesh " + getTargets().first()->getName() + " is not a MeshComponent")
CAMITK_WARNING("ExtractSelection: mesh " + getTargets().first()->getName() + " is not a MeshComponent. Action aborted.")
return ABORTED;
}
CAMITK_TRACE("ExtractSelection::apply(): Extract selection of " + getTargets().last()->getName());
CAMITK_TRACE("ExtractSelection: extract selection of " + getTargets().last()->getName());
vtkSmartPointer<vtkExtractSelection> extractSelection = vtkSmartPointer<vtkExtractSelection>::New();
if (targetMesh->getPointSet() == nullptr) {
CAMITK_WARNING("ExtractSelection::apply(): mesh "
+ getTargets().first()->getName() + " does not have any vtkPointSet.")
CAMITK_WARNING("ExtractSelection: mesh "
+ getTargets().first()->getName() + " does not have any vtkPointSet. Action aborted.")
return ABORTED;
}
if (targetMesh->getActiveSelection()->GetNumberOfNodes() == 0) {
CAMITK_WARNING("ExtractSelection::apply(): mesh " +
getTargets().first()->getName() + " does not have anything currently selected.")
CAMITK_WARNING("ExtractSelection: mesh " +
getTargets().first()->getName() + " does not have anything currently selected. Action aborted.")
return ABORTED;
}
......
......@@ -102,14 +102,14 @@ Action::ApplyStatus MeshToImageStencil::process(MeshComponent* comp) {
// get mesh as polydata
if (comp->getPointSet() == nullptr) {
CAMITK_WARNING("ComputeNormal::apply(): the mesh point set of " + comp->getName() + " does not have a vtkPointSet.")
CAMITK_WARNING(getName() + ": the mesh point set of " + comp->getName() + " does not have a vtkPointSet. Action aborted.")
return ABORTED;
}
vtkSmartPointer<vtkPolyData> pData = vtkPolyData::SafeDownCast(comp->getPointSet());
if (pData == nullptr) {
CAMITK_WARNING("ComputeNormals::apply(): the mesh point set of " + comp->getName() + " is not a vtkPolyData.")
CAMITK_WARNING(getName() + ": the mesh point set of " + comp->getName() + " is not a vtkPolyData. Action aborted.")
return ABORTED;
}
......
......@@ -202,7 +202,7 @@ Action::ApplyStatus RigidTransform::apply() {
comp->setModified();
}
else {
CAMITK_INFO("RigidTransform::applyTransform: Error: filter output is of type: " + QString(filterList[i]->GetOutputDataObject(0)->GetClassName()));
CAMITK_WARNING("Rigid Transform: filter output is of type: " + QString(filterList[i]->GetOutputDataObject(0)->GetClassName()) + ". Action aborted")
return ABORTED;
}
// next filter
......
......@@ -62,7 +62,7 @@ camitk::Action::ApplyStatus AppendMeshes::apply() {
// at least 2 targets must be selected
if (getTargets().size() < 2) {
CAMITK_WARNING( "AppendMeshes::apply(): at least 2 mesh components must be selected" )
CAMITK_WARNING( "Append Meshes: at least 2 mesh components must be selected. Action aborted." )
QApplication::restoreOverrideCursor();
return ABORTED;
}
......@@ -74,14 +74,14 @@ camitk::Action::ApplyStatus AppendMeshes::apply() {
for (int i = 0; i < getTargets().size(); i++) {
meshComp = dynamic_cast<MeshComponent*>(getTargets().at(i));
if (meshComp == nullptr) {
CAMITK_WARNING( "AppendMeshes::apply()" + getTargets().at(i)->getName() + " is not a MeshComponent" );
QApplication::restoreOverrideCursor();
CAMITK_WARNING( "AppendMeshes: \"" + getTargets().at(i)->getName() + "\" is not a MeshComponent. Action aborted." );
return ABORTED;
}
appendFilter->AddInputData(meshComp->getPointSet());
}
CAMITK_TRACE( "AppendMeshes::apply(): append meshes" );
CAMITK_TRACE( "AppendMeshes: append meshes" );
appendFilter->AddObserver(vtkCommand::ProgressEvent, progressCallback);
appendFilter->Modified();
......
......@@ -40,18 +40,18 @@ Action::ApplyStatus ComputeCurvatures::apply() {
MeshComponent* mesh = dynamic_cast<MeshComponent*>(getTargets().first());
if (mesh == nullptr) {
CAMITK_TRACE("ComputeCurvatures::apply(): mesh " + getTargets().first()->getName() + " is not a MeshComponent")
CAMITK_TRACE("Compute Curvatures: mesh " + getTargets().first()->getName() + " is not a MeshComponent. Action aborted.")
return ABORTED;
}
vtkPolyData* pData = vtkPolyData::SafeDownCast(mesh->getPointSet());
if (pData == nullptr) {
CAMITK_WARNING("ComputeCurvatures::apply(): the mesh point set of " + getTargets().first()->getName() + " is not a vtkPolyData")
CAMITK_WARNING("Compute Curvatures: the mesh point set of " + getTargets().first()->getName() + " is not a vtkPolyData. Action aborted.")
return ABORTED;
}
CAMITK_TRACE("ComputeCurvatures::apply(): Compute curvatures for mesh " + getTargets().first()->getName())
CAMITK_TRACE("Compute Curvatures: compute curvatures for mesh " + getTargets().first()->getName())
// set up curvatures
vtkSmartPointer<vtkCurvatures> curv = vtkSmartPointer<vtkCurvatures>::New();
......@@ -69,9 +69,9 @@ Action::ApplyStatus ComputeCurvatures::apply() {
break;
case GAUSSIAN :
if (curv->GetOutput()->GetPointData()->GetScalars("Gauss_Curvature") == nullptr) {
CAMITK_WARNING("ComputeCurvatures::apply(): no Gauss Curvature can be computed for: " +
CAMITK_ERROR("Compute Curvatures: no Gauss Curvature can be computed for: " +
getTargets().first()->getName() + " (probably no 3D surface in this mesh).")
return ABORTED;
return ERROR;
}
mesh->addPointData("Gauss Curvature", curv->GetOutput()->GetPointData()->GetScalars("Gauss_Curvature"));
break;
......@@ -79,8 +79,8 @@ Action::ApplyStatus ComputeCurvatures::apply() {
mesh->addPointData("Mean Curvature", curv->GetOutput()->GetPointData()->GetScalars("Mean_Curvature"));
break;
default :
CAMITK_WARNING("ComputeCurvatures::apply(): invalid Curvature type value. Action aborted.")
return ABORTED;
CAMITK_ERROR("Compute Curvatures: invalid Curvature type value.")
return ERROR;
break;
}
......
......@@ -120,8 +120,8 @@ Action::ApplyStatus ExportAsMDL::apply() {
returnStatus = process(input);
}
else {
CAMITK_ERROR("ExportAsMDL::apply(): target component \"" + comp->getName() + "\" is of type \"" + comp->getHierarchy().value(0) + "\", expecting MeshComponent");
returnStatus = ERROR; // Bad input (should not be possible)
CAMITK_WARNING("Export As MDL: target component \"" + comp->getName() + "\" is of type \"" + comp->getHierarchy().value(0) + "\", expecting MeshComponent. Action aborted.");
returnStatus = ABORTED; // Bad input (should not be possible)
}
}
......@@ -140,7 +140,7 @@ Action::ApplyStatus ExportAsMDL::process(MeshComponent* comp) {
return SUCCESS;
}
else {
CAMITK_WARNING("ExportAsMDL::process(): output file is missing, please provide one.");
CAMITK_WARNING("Export As MDL: output file is missing, please provide one. Action aborted.");
return ABORTED;
}
}
......
......@@ -72,7 +72,7 @@ camitk::Action::ApplyStatus ICPRegistration::apply() {
// at least 2 targets must be selected
if (getTargets().size() < 2) {
CAMITK_WARNING("ICPRegistration::apply(): at least 2 mesh components must be selected")
CAMITK_WARNING("ICP Registration: at least 2 mesh components must be selected. Action aborted.")
return ABORTED;
}
......@@ -82,7 +82,7 @@ camitk::Action::ApplyStatus ICPRegistration::apply() {
// check if targets are MeshComponents
if ((targetMesh == nullptr) || (sourceMesh == nullptr)) {
CAMITK_WARNING("ICPRegistration::apply(): mesh " + getTargets().first()->getName() + " and/or " + getTargets().last()->getName() + " is not a MeshComponent" )
CAMITK_WARNING("ICP Registration: mesh " + getTargets().first()->getName() + " and/or " + getTargets().last()->getName() + " is not a MeshComponent. Action aborted.")
return ABORTED;
}
......
......@@ -85,18 +85,18 @@ Action::ApplyStatus MergeMeshs::apply() {
//check cases
if (getTargets().size() < 2) {
CAMITK_ERROR("MergeMeshs::apply(): Number of targets is insufficient (at least 2 meshs)");
// restore the normal cursor and progress bar
Application::resetProgressBar();
QApplication::restoreOverrideCursor();
CAMITK_WARNING("Merge Meshs: number of targets is insufficient (at least 2 meshs). Action aborted.");
return ABORTED;
}
else if (getTargets().size() > 2) {
CAMITK_ERROR("MergeMeshs::apply(): Merge meshs works only with 2 meshs");
// restore the normal cursor and progress bar
Application::resetProgressBar();
QApplication::restoreOverrideCursor();
CAMITK_WARNING("Merge Meshs: merge meshs works only with 2 meshs. Action aborted.");
return ABORTED;
}
......
......@@ -343,13 +343,13 @@ Action::ApplyStatus MeshClipping::clipMesh(MeshComponent* mesh, vtkSmartPointer
break;
default:
//-- Not implemented
CAMITK_WARNING(tr("Mesh Clipping aborted: cannot clip mesh \"") + mesh->getName() + tr("\": it is not a vtkPolyData, a vtkUnstructuredGrid nor a vtkStructuredGrid."))
return Action::ABORTED;
CAMITK_WARNING(tr("Mesh Clipping: aborted cannot clip mesh \"") + mesh->getName() + tr("\": it is not a vtkPolyData, a vtkUnstructuredGrid nor a vtkStructuredGrid. Action aborted."))
return ABORTED;
break;
}
// if everything went well
return Action::SUCCESS;
return SUCCESS;
}
// --------------- restoreMeshes -------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment