Commit 8a42ee6e authored by Haocheng LIU's avatar Haocheng LIU

Change Auxiliary geometry Operator and add AddImage Operator

In Auxiliary geometry Operator now the name of model item is
**filename**, URL labels to filename and is not optional. AddImage
Operator is introduced to SMTK which inherits Auxiliary geometry Operator.

Address SMTK issue #102 and #101.
parent b9e1ea57
......@@ -48,6 +48,7 @@ set(modelSrcs
Volume.cxx
VolumeUse.cxx
operators/AddAuxiliaryGeometry.cxx
operators/AddImage.cxx
operators/CloseModel.cxx
operators/EntityGroupOperator.cxx
operators/SetProperty.cxx
......@@ -115,6 +116,7 @@ set(modelHeaders
Volume.h
VolumeUse.h
operators/AddAuxiliaryGeometry.h
operators/AddImage.h
operators/CloseModel.h
operators/EntityGroupOperator.h
operators/SetProperty.h
......@@ -127,6 +129,7 @@ set(modelHeaders
)
smtk_session_json("${CMAKE_CURRENT_SOURCE_DIR}/DefaultSession.json" defSessionJSON)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/AddImage.sbt" defOpXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/AddAuxiliaryGeometry.sbt" defOpXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/CloseModel.sbt" defOpXML)
smtk_operator_xml("${CMAKE_CURRENT_SOURCE_DIR}/operators/EntityGroupOperator.sbt" defOpXML)
......
......@@ -21,6 +21,11 @@
#include "smtk/attribute/ModelEntityItem.h"
#include "smtk/attribute/VoidItem.h"
SMTK_THIRDPARTY_PRE_INCLUDE
#include "boost/filesystem.hpp"
SMTK_THIRDPARTY_POST_INCLUDE
using namespace boost::filesystem;
using namespace smtk::model;
using smtk::attribute::FileItem;
using smtk::attribute::StringItem;
......@@ -41,7 +46,7 @@ smtk::model::OperatorResult AddAuxiliaryGeometry::operateInternal()
smtk::attribute::FileItemPtr urlItem = this->findFile("url");
smtk::attribute::StringItemPtr dtypeItem = this->findString("type");
smtk::attribute::IntItemPtr dimItem = this->findInt("dimension");
int dim = dimItem->value(0);
int dim = dimItem != nullptr ? dimItem->value(0) : -1;
smtk::attribute::VoidItem::Ptr separateRepOption =
this->findVoid("separate representation");
......@@ -59,11 +64,15 @@ smtk::model::OperatorResult AddAuxiliaryGeometry::operateInternal()
auxGeom.assignDefaultName();
auxGeom.setIntegerProperty("display as separate representation", bSeparateRep ? 1 : 0);
if (urlItem->numberOfValues() > 0 && !urlItem->value(0).empty())
if (!urlItem->value().empty())
{
auxGeom.setUrl(urlItem->value(0));
path filePath(urlItem->value());
auxGeom.setUrl(filePath.string());
// Grab the file name as the name for the aux geometry
auxGeom.setName(filePath.filename().string());
}
if (!dtypeItem->value(0).empty())
// nullptr check for AddImage operator
if (dtypeItem != nullptr && !dtypeItem->value(0).empty())
{
auxGeom.setStringProperty("type", dtypeItem->value(0));
}
......
......@@ -22,8 +22,8 @@
scene as if they were a single file.
</DetailedDescription>
<ItemDefinitions>
<File Name="url" Optional="true" NumberOfRequiredValues="1" IsEnabledByDefault="true" ShouldExist="true"
FileFilters="Image files (*.tif *.tiff *.dem);;VTK files (*.vti *.vtp *.vtu *.vtm);;Wavefront OBJ files (*.obj);;Point Cloud Files (*.pts);;All files (*.*)">>
<File Name="url" Label = "Filename" Optional="true" NumberOfRequiredValues="1" IsEnabledByDefault="true" ShouldExist="true"
FileFilters="Image files (*.tif *.tiff *.dem);;VTK files (*.vti *.vtp *.vtu *.vtm);;Wavefront OBJ files (*.obj);;Point Cloud Files (*.pts);;All files (*.*)">
<BriefDescription>The file containing the auxiliary scene geometry.</BriefDescription>
</File>
<String Name="type" NumberOfRequiredValues="1" AdvanceLevel="1">
......
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/model/operators/AddImage.h"
#include "smtk/model/AddImage_xml.h"
smtkImplementsModelOperator(
SMTKCORE_EXPORT,
smtk::model::AddImage,
add_image,
"add image",
AddImage_xml,
smtk::model::Session);
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef __smtk_model_AddImage_h
#define __smtk_model_AddImage_h
#include "smtk/model/operators/AddAuxiliaryGeometry.h"
namespace smtk {
namespace model {
class SMTKCORE_EXPORT AddImage : public AddAuxiliaryGeometry
{
public:
smtkTypeMacro(AddImage);
smtkCreateMacro(AddImage);
smtkSharedFromThisMacro(AddAuxiliaryGeometry);
smtkDeclareModelOperator();
};
} //namespace model
} // namespace smtk
#endif // __smtk_model_AddImage_h
<?xml version="1.0" encoding="utf-8" ?>
<!-- Description of the model "AddImage" Operator -->
<SMTK_AttributeSystem Version="2">
<Definitions>
<!-- Operator -->
<AttDef Type="add image" BaseType="operator" Label=" Model - Add Image">
<AssociationsDef Name="entities" NumberOfRequiredValues="1">
<MembershipMask>model|aux_geom</MembershipMask>
</AssociationsDef>
<BriefDescription>
Add am image as auxiliary geometry (scene geometry not part of the model domain)
to a model or to another auxiliary geometry instance.
</BriefDescription>
<DetailedDescription>
Add am image as auxiliary geometry (scene geometry not part of the model domain)
to a model or to another auxiliary geometry instance.
Auxiliary geometry may be made hierarchical, by adding an auxiliary
geometry instance with no URL to a model and then adding 1 or more
auxiliary geometry instances to the first instance above.
This is useful when you wish to instance multiple files into the
scene as if they were a single file.
</DetailedDescription>
<ItemDefinitions>
<File Name="url" Label="Image File Name" Optional="true" NumberOfRequiredValues="1"
IsEnabledByDefault="true" ShouldExist="true"
FileFilters="Image files (*.tif *.tiff *.dem *.vti);;All files (*.*)">
<BriefDescription>The file containing the image.</BriefDescription>
</File>
<Void Name="separate representation" AdvanceLevel="1" Optional="true" IsEnabledByDefault="true"
Label="Display as separate representation from model">
<BriefDescription>
Should the auxiliary geometry's representation be separate from its owning model's?
</BriefDescription>
<DetailedDescription>
Should the auxiliary geometry's representation be separate from its owning model's?
If yes, a separate rendering pipeline will be created for auxiliary geometry and
its representation will be controlled with its own set of display properties;
if no, the geometry will be shown and controlled as sub-blocks in the model's multiblock dataset,
which may be less flexible.
</DetailedDescription>
</Void>
</ItemDefinitions>
</AttDef>
<!-- Result -->
<AttDef Type="result(add image)" BaseType="result">
<ItemDefinitions>
<!-- The modified entities are stored in the base result's "modified" item. -->
<ModelEntity Name="tess_changed" NumberOfRequiredValues="1"/>
</ItemDefinitions>
</AttDef>
</Definitions>
</SMTK_AttributeSystem>
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