Commit bd10405d authored by T.J. Corona's avatar T.J. Corona

NewOp, Operator -> Operation.

parent 2dcfcf90
......@@ -121,7 +121,7 @@ function(smtk_prepend_string prefix result)
set(${result} ${newNames} PARENT_SCOPE)
endfunction(smtk_prepend_string)
include(SMTKOperatorXML)
include(SMTKOperationXML)
include(SMTKSessionJSON)
# Builds source groups for the smtk files so that they show up nicely in
......@@ -182,4 +182,3 @@ MACRO(ADD_SMTK_UI_VIEW OUTIFACES OUTSRCS)
${VIEW_MOC_SRCS}
)
ENDMACRO()
include("${CMAKE_CURRENT_LIST_DIR}/EncodeStringFunctions.cmake")
# Given a list of filenames (opSpecs) containing XML descriptions of
# operators, configure C++ source that encodes the XML as a string.
# operations, configure C++ source that encodes the XML as a string.
# The resulting files are placed in the current binary directory and
# appended to genFiles.
function(smtk_operator_xml opSpecs genFiles)
function(smtk_operation_xml opSpecs genFiles)
foreach (opSpec ${opSpecs})
get_filename_component(genFileBase "${opSpec}" NAME_WE)
set(genFile "${CMAKE_CURRENT_BINARY_DIR}/${genFileBase}_xml.h")
......@@ -15,10 +15,10 @@ function(smtk_operator_xml opSpecs genFiles)
endfunction()
# Given a list of filenames (opSpecs) containing XML descriptions of
# operators, configure Python source that encodes the XML as a string.
# operations, configure Python source that encodes the XML as a string.
# The resulting files are placed in the current binary directory and
# appended to genFiles.
function(smtk_pyoperator_xml opSpecs genFiles)
function(smtk_pyoperation_xml opSpecs genFiles)
foreach (opSpec ${opSpecs})
get_filename_component(genFileBase "${opSpec}" NAME_WE)
set(genFile "${CMAKE_CURRENT_BINARY_DIR}/${genFileBase}_xml.py")
......
......@@ -584,7 +584,7 @@ install (FILES ${PROJECT_BINARY_DIR}/smtk/Options.h
install(
FILES
${PROJECT_SOURCE_DIR}/CMake/EncodeStringFunctions.cmake
${PROJECT_SOURCE_DIR}/CMake/SMTKOperatorXML.cmake
${PROJECT_SOURCE_DIR}/CMake/SMTKOperationXML.cmake
${PROJECT_SOURCE_DIR}/CMake/SMTKSessionJSON.cmake
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/SMTK
......
......@@ -2,15 +2,15 @@ project(ex_implement_an_operator)
cmake_minimum_required(VERSION 3.5)
# ++ 1 ++
include(SMTKOperatorXML) # defines smtk_operator_xml()
include(SMTKOperationXML) # defines smtk_operation_xml()
# The smtk_operator_xml() function writes a file to the current
# The smtk_operation_xml() function writes a file to the current
# binary directory sharing the same name as the input file
# but with "_xml.h" replacing the file extension. For this
# example, that filename is "implement_an_operator_xml.h".
# smtk_operator_xml() appends the exact filename to the
# smtk_operation_xml() appends the exact filename to the
# "operatorXML" variable.
smtk_operator_xml(
smtk_operation_xml(
"${CMAKE_CURRENT_SOURCE_DIR}/implement_an_operator.xml"
operatorXML
)
......
......@@ -35,10 +35,10 @@ namespace ex
{
// ++ 2 ++
OperatorResult CounterOperator::operateInternal()
OperationResult CounterOperator::operateInternal()
{
// Get the attribute holding parameter values:
OperatorSpecification params = this->specification();
OperationSpecification params = this->specification();
// Get the input model to be processed:
Model model = params->findModelEntity("model")->value();
......@@ -49,9 +49,9 @@ OperatorResult CounterOperator::operateInternal()
// Create the attribute holding the results of
// our operation using a convenience method
// provided by the Operator base class.
// provided by the Operation base class.
// Our operation is simple; we always succeed.
OperatorResult result = this->createResult(OPERATION_SUCCEEDED);
OperationResult result = this->createResult(OPERATION_SUCCEEDED);
// Fetch the item to store our output:
smtk::attribute::IntItemPtr cellCount = result->findInt("count");
......@@ -65,26 +65,26 @@ OperatorResult CounterOperator::operateInternal()
} // namespace ex
// ++ 3 ++
// Implement methods from smtkDeclareModelOperator()
// Implement methods from smtkDeclareModelOperation()
// and provide an auto-init object for registering the
// operator with the session.
smtkImplementsModelOperator(
smtkImplementsModelOperation(
/* no export symbol */, // Export symbol (none here)
ex::CounterOperator, // The class name (include all namespaces)
ex::CounterOperation, // The class name (include all namespaces)
ex_counter, // The "component" name (for auto-init)
"counter", // The user-printable operator name.
implement_an_operator_xml, // An XML description (or NULL).
smtk::model::DefaultSession); // The modeling kernel this operator uses.
// -- 3 --
void testOperator(Model model)
void testOperation(Model model)
{
// Get the default session for our model manager:
smtk::model::SessionPtr session = model.session().session();
// Ask the session to create an operator:
ex::CounterOperator::Ptr op =
smtk::dynamic_pointer_cast<ex::CounterOperator>(session->op("counter"));
ex::CounterOperation::Ptr op =
smtk::dynamic_pointer_cast<ex::CounterOperation>(session->op("counter"));
op->ensureSpecification();
smtk::attribute::ModelEntityItemPtr input = op->specification()->findModelEntity("model");
......@@ -115,7 +115,7 @@ int main()
try
{
testOperator(model);
testOperation(model);
}
catch (const std::string& msg)
{
......
#ifndef __smtk_ex_CounterOperator_h
#define __smtk_ex_CounterOperator_h
#ifndef __smtk_ex_CounterOperation_h
#define __smtk_ex_CounterOperation_h
#include "smtk/model/Operator.h"
#include "smtk/model/Operation.h"
#include <string>
......@@ -9,13 +9,13 @@
namespace ex
{
class CounterOperator : public smtk::model::Operator
class CounterOperation : public smtk::model::Operator
{
public:
smtkTypeMacro(CounterOperator);
smtkCreateMacro(CounterOperator);
smtkSharedFromThisMacro(Operator);
smtkDeclareModelOperator();
smtkTypeMacro(CounterOperation);
smtkCreateMacro(CounterOperation);
smtkSharedFromThisMacro(Operation);
smtkDeclareModelOperation();
// ...
// -- 1 --
......@@ -23,10 +23,10 @@ public:
bool ableToOperate() override { return this->ensureSpecification(); }
protected:
smtk::model::OperatorResult operateInternal() override;
smtk::model::OperationResult operateInternal() override;
// -- 2 --
};
} // namespace ex
#endif // __smtk_ex_CounterOperator_h
#endif // __smtk_ex_CounterOperation_h
......@@ -84,7 +84,7 @@ class VoidItemDefinition;
namespace operation
{
class NewOp;
class Operation;
class Manager;
}
......@@ -234,7 +234,7 @@ namespace io
{
class SaveJSON;
class LoadJSON;
class OperatorLog;
class OperationLog;
class Logger;
typedef smtk::shared_ptr<smtk::io::Logger> LoggerPtr;
}
......@@ -258,8 +258,8 @@ typedef std::set<ComponentPtr> ComponentSet;
namespace operation
{
typedef smtk::shared_ptr<smtk::operation::NewOp> NewOpPtr;
typedef smtk::weak_ptr<smtk::operation::NewOp> WeakNewOpPtr;
typedef smtk::shared_ptr<smtk::operation::Operation> OperationPtr;
typedef smtk::weak_ptr<smtk::operation::Operation> WeakOperationPtr;
typedef smtk::shared_ptr<smtk::operation::Manager> ManagerPtr;
typedef smtk::weak_ptr<smtk::operation::Manager> WeakManagerPtr;
}
......
......@@ -6,7 +6,7 @@ set(cgmSrcs
Engines.cxx
ExportSolid.cxx
ImportSolid.cxx
Operator.cxx
Operation.cxx
operators/BooleanIntersection.cxx
operators/BooleanSubtraction.cxx
operators/BooleanUnion.cxx
......@@ -36,7 +36,7 @@ set(cgmHeaders
Engines.h
ExportSolid.h
ImportSolid.h
Operator.h
Operation.h
operators/BooleanIntersection.h
operators/BooleanSubtraction.h
operators/BooleanUnion.h
......@@ -91,31 +91,31 @@ smtk_install_library(smtkCGMSession)
# build a program at configure-time to conditionally create the JSON and/or header.
# But this is simpler.
# Operators which have XML descriptions in separate files
# Operations which have XML descriptions in separate files
# need to have it encoded as a string in a header.
# We do not need the path to the generated header (appended
# to cgmOperatorXML) since the operators themselves include
# to cgmOperationXML) since the operators themselves include
# the header in their implementations.
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/BooleanIntersection.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/BooleanSubtraction.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/BooleanUnion.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Copy.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateBody.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateBrick.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateCylinder.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateEdge.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateFace.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreatePrism.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateSphere.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateVertex.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Read.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Reflect.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/RemoveModel.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Rotate.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Scale.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Sweep.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Translate.sbt" cgmOperatorXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Write.sbt" cgmOperatorXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/BooleanIntersection.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/BooleanSubtraction.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/BooleanUnion.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Copy.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateBody.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateBrick.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateCylinder.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateEdge.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateFace.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreatePrism.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateSphere.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CreateVertex.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Read.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Reflect.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/RemoveModel.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Rotate.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Scale.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Sweep.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Translate.sbt" cgmOperationXML)
smtk_operation_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/Write.sbt" cgmOperationXML)
# Install the headers
smtk_public_headers(${cgmHeaders})
......
......@@ -7,7 +7,7 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/bridge/cgm/Operator.h"
#include "smtk/bridge/cgm/Operation.h"
#include "smtk/bridge/cgm/Session.h"
#include "smtk/bridge/cgm/TDUUID.h"
......@@ -23,7 +23,7 @@ namespace cgm
{
/// Return a shared pointer to the session backing a CGM operator.
SessionPtr Operator::cgmSession()
SessionPtr Operation::cgmSession()
{
return smtk::dynamic_pointer_cast<smtk::bridge::cgm::Session>(this->session());
}
......@@ -32,17 +32,17 @@ SessionPtr Operator::cgmSession()
*
* The ToolDataUser is the simplest instance of anything
* that can be directly associated with a UUID in CGM.
* Normally you will be more interested in Operator::cgmEntity
* Normally you will be more interested in Operation::cgmEntity
* as it returns the result of this method dynamically cast to
* the much more useful RefEntity.
*/
ToolDataUser* Operator::cgmData(const smtk::model::EntityRef& smtkEntity)
ToolDataUser* Operation::cgmData(const smtk::model::EntityRef& smtkEntity)
{
return TDUUID::findEntityById(smtkEntity.entity());
}
/// A helper to return the CGM entity associated with \a smtkEntity.
RefEntity* Operator::cgmEntity(const smtk::model::EntityRef& smtkEntity)
RefEntity* Operation::cgmEntity(const smtk::model::EntityRef& smtkEntity)
{
ToolDataUser* tdu = TDUUID::findEntityById(smtkEntity.entity());
RefEntity* ent = dynamic_cast<RefEntity*>(tdu);
......
......@@ -7,8 +7,8 @@
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef __smtk_session_cgm_Operator_h
#define __smtk_session_cgm_Operator_h
#ifndef __smtk_session_cgm_Operation_h
#define __smtk_session_cgm_Operation_h
#include "smtk/bridge/cgm/Exports.h"
#include "smtk/bridge/cgm/Session.h"
......@@ -39,7 +39,7 @@ class Session;
* It provides convenience methods for accessing CGM-specific data
* for its subclasses to use internally.
*/
class SMTKCGMSESSION_EXPORT Operator : public smtk::operation::NewOp
class SMTKCGMSESSION_EXPORT Operation : public smtk::operation::Operation
{
protected:
SessionPtr cgmSession();
......@@ -60,7 +60,7 @@ protected:
/// A convenience method for returning the CGM counterpart of an SMTK entity already cast to a subtype.
template <typename T>
T Operator::cgmEntityAs(const smtk::model::EntityRef& smtkEntity)
T Operation::cgmEntityAs(const smtk::model::EntityRef& smtkEntity)
{
return dynamic_cast<T>(this->cgmEntity(smtkEntity));
}
......@@ -77,7 +77,7 @@ T Operator::cgmEntityAs(const smtk::model::EntityRef& smtkEntity)
* added to \a expunged.
*/
template <typename T, typename U>
bool Operator::cgmEntities(const T& smtkContainer, DLIList<U>& cgmContainer, int keepInputs,
bool Operation::cgmEntities(const T& smtkContainer, DLIList<U>& cgmContainer, int keepInputs,
smtk::model::EntityRefArray& expunged)
{
bool ok = true;
......@@ -107,7 +107,7 @@ bool Operator::cgmEntities(const T& smtkContainer, DLIList<U>& cgmContainer, int
}
template <typename T>
void Operator::addEntitiesToResult(
void Operation::addEntitiesToResult(
DLIList<T>& cgmContainer, Result result, ResultEntityOrigin origin)
{
SessionPtr session = this->cgmSession();
......@@ -148,4 +148,4 @@ void Operator::addEntitiesToResult(
} // namespace bridge
} // namespace smtk
#endif // __smtk_session_cgm_Operator_h
#endif // __smtk_session_cgm_Operation_h
......@@ -78,7 +78,7 @@ Session::Session()
{
this->m_maxRelChordErr = 0.01; // fraction of longest edge.
this->m_maxAngleErr = 2.0; // maximum angle in degrees.
this->initializeOperatorCollection(Session::s_operators);
this->initializeOperationCollection(Session::s_operators);
if (!Engines::areInitialized())
{
Engines::isInitialized("");
......
......@@ -68,7 +68,7 @@ bool BooleanIntersection::ableToOperate()