FEM Post: Command for creation of post pipeline from result
This commit is contained in:
@@ -1023,6 +1023,53 @@ Gui::Action * CmdFemPostApllyChanges::createAction(void)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostPipelineFromResult);
|
||||
|
||||
CmdFemPostPipelineFromResult::CmdFemPostPipelineFromResult()
|
||||
: Command("Fem_PostPipelineFromResult")
|
||||
{
|
||||
sAppModule = "Fem";
|
||||
sGroup = QT_TR_NOOP("Fem");
|
||||
sMenuText = QT_TR_NOOP("Creates a post processing pipeline from a result object");
|
||||
sToolTipText = QT_TR_NOOP("Creates a post processing pipeline from a result object");
|
||||
sWhatsThis = "Fem_PostPipelineFromResult";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
}
|
||||
|
||||
void CmdFemPostPipelineFromResult::activated(int iMsg)
|
||||
{
|
||||
Gui::SelectionFilter ResultFilter("SELECT Fem::FemResultObject COUNT 1");
|
||||
|
||||
if (ResultFilter.match()) {
|
||||
|
||||
Fem::FemResultObject* result = static_cast<Fem::FemResultObject*>(ResultFilter.Result[0][0].getObject());
|
||||
std::string FeatName = getUniqueObjectName("Pipeline");
|
||||
|
||||
openCommand("Create pipeline from result");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Fem::FemPostPipeline','%s')",FeatName.c_str());
|
||||
|
||||
//TODO: use python function call for this
|
||||
static_cast<Fem::FemPostPipeline*>(getDocument()->getObject(FeatName.c_str()))->load(result);
|
||||
|
||||
this->updateActive();
|
||||
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("CmdFemPostCreateClipFilter", "Wrong selection"),
|
||||
qApp->translate("CmdFemPostCreateClipFilter", "Select a result, please."));
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdFemPostPipelineFromResult::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -1047,5 +1094,6 @@ void CreateFemCommands(void)
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateScalarClipFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostFunctions);
|
||||
rcCmdMgr.addCommand(new CmdFemPostApllyChanges);
|
||||
rcCmdMgr.addCommand(new CmdFemPostPipelineFromResult);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<<<<<<< 387862dfe753cf0cb062032e97840353b14dcbae
|
||||
<<<<<<< 146d87b88ef2e7376f2633828c2341a44c146220
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2008 Jürgen Riegel (juergen.riegel@web.de) *
|
||||
* *
|
||||
@@ -776,8 +776,8 @@ CmdFemPostCreateClipFilter::CmdFemPostCreateClipFilter()
|
||||
{
|
||||
sAppModule = "Fem";
|
||||
sGroup = QT_TR_NOOP("Fem");
|
||||
sMenuText = QT_TR_NOOP("Define/create a clip filter for a post processing pipeline...");
|
||||
sToolTipText = QT_TR_NOOP("Define/create a clip filter for a post processing pipeline...");
|
||||
sMenuText = QT_TR_NOOP("Define/create a clip filter which uses functions to define the cliped region");
|
||||
sToolTipText = QT_TR_NOOP("Define/create a clip filter which uses functions to define the cliped region");
|
||||
sWhatsThis = "Fem_PostCreateClipFilter";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
@@ -785,10 +785,9 @@ CmdFemPostCreateClipFilter::CmdFemPostCreateClipFilter()
|
||||
|
||||
void CmdFemPostCreateClipFilter::activated(int iMsg)
|
||||
{
|
||||
Gui::SelectionFilter ObjectFilter("SELECT Fem::FemPostPipeline COUNT 1");
|
||||
|
||||
if (ObjectFilter.match()) {
|
||||
Fem::FemPostPipeline *pipeline = static_cast<Fem::FemPostPipeline*>(ObjectFilter.Result[0][0].getObject());
|
||||
std::vector<Fem::FemPostPipeline*> pipelines = App::GetApplication().getActiveDocument()->getObjectsOfType<Fem::FemPostPipeline>();
|
||||
if (!pipelines.empty()) {
|
||||
Fem::FemPostPipeline *pipeline = pipelines.front();
|
||||
|
||||
std::string FeatName = getUniqueObjectName("Clip");
|
||||
|
||||
@@ -800,6 +799,8 @@ void CmdFemPostCreateClipFilter::activated(int iMsg)
|
||||
doCommand(Doc,"del __list__");
|
||||
|
||||
this->updateActive();
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
@@ -813,6 +814,50 @@ bool CmdFemPostCreateClipFilter::isActive(void)
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostCreateScalarClipFilter);
|
||||
|
||||
CmdFemPostCreateScalarClipFilter::CmdFemPostCreateScalarClipFilter()
|
||||
: Command("Fem_PostCreateScalarClipFilter")
|
||||
{
|
||||
sAppModule = "Fem";
|
||||
sGroup = QT_TR_NOOP("Fem");
|
||||
sMenuText = QT_TR_NOOP("Define/create a clip filter which clips a field with a scalar value");
|
||||
sToolTipText = QT_TR_NOOP("Define/create a clip filter which clips a field with a scalar value");
|
||||
sWhatsThis = "Fem_PostCreateScalarClipFilter";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
}
|
||||
|
||||
void CmdFemPostCreateScalarClipFilter::activated(int iMsg)
|
||||
{
|
||||
std::vector<Fem::FemPostPipeline*> pipelines = App::GetApplication().getActiveDocument()->getObjectsOfType<Fem::FemPostPipeline>();
|
||||
if (!pipelines.empty()) {
|
||||
Fem::FemPostPipeline *pipeline = pipelines.front();
|
||||
|
||||
std::string FeatName = getUniqueObjectName("ScalarClip");
|
||||
|
||||
openCommand("Create scalar clip filter");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Fem::FemPostScalarClipFilter','%s')",FeatName.c_str());
|
||||
doCommand(Doc,"__list__ = App.ActiveDocument.%s.Filter", pipeline->getNameInDocument());
|
||||
doCommand(Doc,"__list__.append(App.ActiveDocument.%s)", FeatName.c_str());
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Filter = __list__", pipeline->getNameInDocument());
|
||||
doCommand(Doc,"del __list__");
|
||||
|
||||
this->updateActive();
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("CmdFemPostCreateScalarClipFilter", "Wrong selection"),
|
||||
qApp->translate("CmdFemPostCreateScalarClipFilter", "Select a pipeline, please."));
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdFemPostCreateScalarClipFilter::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
// #####################################################################################################
|
||||
|
||||
|
||||
@@ -827,31 +872,30 @@ CmdFemPostFunctions::CmdFemPostFunctions()
|
||||
sToolTipText = QT_TR_NOOP("Functions for use in postprocessing filter...");
|
||||
sWhatsThis = "Fem_PostCreateFunctions";
|
||||
sStatusTip = sToolTipText;
|
||||
eType = eType|ForEdit;
|
||||
}
|
||||
|
||||
void CmdFemPostFunctions::activated(int iMsg)
|
||||
{
|
||||
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
|
||||
|
||||
std::string name;
|
||||
if (iMsg==0)
|
||||
name = "Plane";
|
||||
else if (iMsg==1)
|
||||
rcCmdMgr.runCommandByName("Part_JoinEmbed");
|
||||
else if (iMsg==2)
|
||||
rcCmdMgr.runCommandByName("Part_JoinCutout");
|
||||
name = "Sphere";
|
||||
else
|
||||
return;
|
||||
|
||||
//create the object
|
||||
Gui::SelectionFilter ObjectFilter("SELECT Fem::FemPostPipeline COUNT 1");
|
||||
if (ObjectFilter.match()) {
|
||||
Fem::FemPostPipeline *pipeline = static_cast<Fem::FemPostPipeline*>(ObjectFilter.Result[0][0].getObject());
|
||||
std::vector<Fem::FemPostPipeline*> pipelines = App::GetApplication().getActiveDocument()->getObjectsOfType<Fem::FemPostPipeline>();
|
||||
if (!pipelines.empty()) {
|
||||
Fem::FemPostPipeline *pipeline = pipelines.front();
|
||||
|
||||
openCommand("Create function");
|
||||
|
||||
//check if the pipeline has a filter provider and add one if needed
|
||||
Fem::FemPostFunctionProvider* provider;
|
||||
if(!pipeline->Function.getValue() || pipeline->Function.getValue()->getTypeId() == Fem::FemPostFunctionProvider::getClassTypeId()) {
|
||||
if(!pipeline->Function.getValue() || pipeline->Function.getValue()->getTypeId() != Fem::FemPostFunctionProvider::getClassTypeId()) {
|
||||
std::string FuncName = getUniqueObjectName("Functions");
|
||||
doCommand(Doc,"App.ActiveDocument.addObject('Fem::FemPostFunctionProvider','%s')", FuncName.c_str());
|
||||
doCommand(Doc,"App.ActiveDocument.%s.Function = App.ActiveDocument.%s", pipeline->getNameInDocument(), FuncName.c_str());
|
||||
@@ -869,6 +913,7 @@ void CmdFemPostFunctions::activated(int iMsg)
|
||||
doCommand(Doc,"del __list__");
|
||||
|
||||
this->updateActive();
|
||||
doCommand(Gui,"Gui.activeDocument().setEdit('%s')",FeatName.c_str());
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
@@ -892,7 +937,7 @@ Gui::Action * CmdFemPostFunctions::createAction(void)
|
||||
applyCommandData(this->className(), pcAction);
|
||||
|
||||
QAction* cmd0 = pcAction->addAction(QString());
|
||||
//cmd0->setIcon(Gui::BitmapFactory().pixmap("Part_JoinConnect"));
|
||||
pcAction->addAction(QString());
|
||||
|
||||
_pcAction = pcAction;
|
||||
languageChange();
|
||||
@@ -913,10 +958,15 @@ void CmdFemPostFunctions::languageChange()
|
||||
Gui::ActionGroup* pcAction = qobject_cast<Gui::ActionGroup*>(_pcAction);
|
||||
QList<QAction*> a = pcAction->actions();
|
||||
|
||||
QAction* cmd0 = a[0];
|
||||
cmd0->setText(QApplication::translate("CmdFemPostFunctions","Plane"));
|
||||
cmd0->setToolTip(QApplication::translate("Fem_PostCreateFunctions","Create a plane function, defined by its orgin and normal"));
|
||||
cmd0->setStatusTip(cmd0->toolTip());
|
||||
QAction* cmd = a[0];
|
||||
cmd->setText(QApplication::translate("CmdFemPostFunctions","Plane"));
|
||||
cmd->setToolTip(QApplication::translate("Fem_PostCreateFunctions","Create a plane function, defined by its orgin and normal"));
|
||||
cmd->setStatusTip(cmd->toolTip());
|
||||
|
||||
cmd = a[1];
|
||||
cmd->setText(QApplication::translate("CmdFemPostFunctions","Sphere"));
|
||||
cmd->setToolTip(QApplication::translate("Fem_PostCreateFunctions","Create a phere function, defined by its center and radius"));
|
||||
cmd->setStatusTip(cmd->toolTip());
|
||||
|
||||
}
|
||||
|
||||
@@ -928,6 +978,7 @@ bool CmdFemPostFunctions::isActive(void)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
DEF_STD_CMD_AC(CmdFemPostApllyChanges);
|
||||
|
||||
CmdFemPostApllyChanges::CmdFemPostApllyChanges()
|
||||
@@ -940,6 +991,7 @@ CmdFemPostApllyChanges::CmdFemPostApllyChanges()
|
||||
sWhatsThis = "Fem_PostApplyChanges";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "view-refresh";
|
||||
eType = eType|ForEdit;
|
||||
}
|
||||
|
||||
void CmdFemPostApllyChanges::activated(int iMsg)
|
||||
@@ -993,6 +1045,7 @@ void CreateFemCommands(void)
|
||||
|
||||
#ifdef FC_USE_VTK
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateClipFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateScalarClipFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostFunctions);
|
||||
rcCmdMgr.addCommand(new CmdFemPostApllyChanges);
|
||||
#endif
|
||||
@@ -2023,6 +2076,53 @@ Gui::Action * CmdFemPostApllyChanges::createAction(void)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
DEF_STD_CMD_A(CmdFemPostPipelineFromResult);
|
||||
|
||||
CmdFemPostPipelineFromResult::CmdFemPostPipelineFromResult()
|
||||
: Command("Fem_PostPipelineFromResult")
|
||||
{
|
||||
sAppModule = "Fem";
|
||||
sGroup = QT_TR_NOOP("Fem");
|
||||
sMenuText = QT_TR_NOOP("Creates a post processing pipeline from a result object");
|
||||
sToolTipText = QT_TR_NOOP("Creates a post processing pipeline from a result object");
|
||||
sWhatsThis = "Fem_PostPipelineFromResult";
|
||||
sStatusTip = sToolTipText;
|
||||
sPixmap = "fem-fem-mesh-create-node-by-poly";
|
||||
}
|
||||
|
||||
void CmdFemPostPipelineFromResult::activated(int iMsg)
|
||||
{
|
||||
Gui::SelectionFilter ResultFilter("SELECT Fem::FemResultObject COUNT 1");
|
||||
|
||||
if (ResultFilter.match()) {
|
||||
|
||||
Fem::FemResultObject* result = static_cast<Fem::FemResultObject*>(ResultFilter.Result[0][0].getObject());
|
||||
std::string FeatName = getUniqueObjectName("Pipeline");
|
||||
|
||||
openCommand("Create pipeline from result");
|
||||
doCommand(Doc,"App.activeDocument().addObject('Fem::FemPostPipeline','%s')",FeatName.c_str());
|
||||
|
||||
//TODO: use python function call for this
|
||||
static_cast<Fem::FemPostPipeline*>(getDocument()->getObject(FeatName.c_str()))->load(result);
|
||||
|
||||
this->updateActive();
|
||||
|
||||
}
|
||||
else {
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("CmdFemPostCreateClipFilter", "Wrong selection"),
|
||||
qApp->translate("CmdFemPostCreateClipFilter", "Select a result, please."));
|
||||
}
|
||||
}
|
||||
|
||||
bool CmdFemPostPipelineFromResult::isActive(void)
|
||||
{
|
||||
return hasActiveDocument();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -2047,6 +2147,7 @@ void CreateFemCommands(void)
|
||||
rcCmdMgr.addCommand(new CmdFemPostCreateScalarClipFilter);
|
||||
rcCmdMgr.addCommand(new CmdFemPostFunctions);
|
||||
rcCmdMgr.addCommand(new CmdFemPostApllyChanges);
|
||||
rcCmdMgr.addCommand(new CmdFemPostPipelineFromResult);
|
||||
#endif
|
||||
}
|
||||
>>>>>>> Detail filter infrastructure
|
||||
>>>>>>> Command for creation of post pipeline from result
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <Inventor/nodes/SoCoordinate3.h>
|
||||
#include <Inventor/nodes/SoIndexedMarkerSet.h>
|
||||
#include <Inventor/nodes/SoIndexedPointSet.h>
|
||||
#include <Inventor/nodes/SoIndexedLineSet.h>
|
||||
#include <Inventor/nodes/SoIndexedFaceSet.h>
|
||||
#include <Inventor/nodes/SoIndexedTriangleStripSet.h>
|
||||
@@ -85,7 +85,7 @@ ViewProviderFemPostObject::ViewProviderFemPostObject() : m_blockPropertyChanges(
|
||||
m_faces->ref();
|
||||
m_triangleStrips = new SoIndexedTriangleStripSet();
|
||||
m_triangleStrips->ref();
|
||||
m_markers = new SoIndexedMarkerSet();
|
||||
m_markers = new SoIndexedPointSet();
|
||||
m_markers->ref();
|
||||
m_lines = new SoIndexedLineSet();
|
||||
m_lines->ref();
|
||||
@@ -155,8 +155,8 @@ void ViewProviderFemPostObject::setDisplayMode(const char* ModeName)
|
||||
m_currentAlgorithm = static_cast<Fem::FemPostObject*>(getObject())->getPolyAlgorithm();
|
||||
else if (strcmp("Wireframe",ModeName)==0)
|
||||
m_currentAlgorithm = m_wireframe;
|
||||
/*else if (strcmp("Nodes",ModeName)==0)
|
||||
setDisplayMaskMode("Nodes");*/
|
||||
else if (strcmp("Nodes",ModeName)==0)
|
||||
m_currentAlgorithm = m_points;
|
||||
|
||||
update();
|
||||
|
||||
@@ -167,7 +167,7 @@ std::vector<std::string> ViewProviderFemPostObject::getDisplayModes(void) const
|
||||
{
|
||||
std::vector<std::string> StrList;
|
||||
StrList.push_back("Outline");
|
||||
// StrList.push_back("Points");
|
||||
StrList.push_back("Nodes");
|
||||
StrList.push_back("Surface");
|
||||
StrList.push_back("Surface with Edges");
|
||||
StrList.push_back("Wireframe");
|
||||
@@ -344,22 +344,17 @@ void ViewProviderFemPostObject::update3D() {
|
||||
m_lines->coordIndex.setNum(0);
|
||||
|
||||
// write out verts if any
|
||||
// (more complex because there is no IndexedPointSet)
|
||||
if (pd->GetNumberOfVerts() > 0){
|
||||
|
||||
Base::Console().Message("render verts\n");
|
||||
Base::Console().Message("render verts: %i\n", pd->GetNumberOfVerts());
|
||||
int soidx = 0;
|
||||
cells = pd->GetVerts();
|
||||
m_markers->coordIndex.startEditing();
|
||||
m_markers->coordIndex.setNum(pd->GetNumberOfVerts());
|
||||
for (cells->InitTraversal(); cells->GetNextCell(npts,indx); ) {
|
||||
for (int i = 0; i < npts; i++) {
|
||||
m_markers->coordIndex.set1Value(soidx, static_cast<int>(indx[i]));
|
||||
++soidx;
|
||||
}
|
||||
m_markers->coordIndex.set1Value(soidx, -1);
|
||||
++soidx;
|
||||
m_markers->coordIndex.set1Value(soidx, static_cast<int>(indx[0]));
|
||||
++soidx;
|
||||
}
|
||||
m_markers->coordIndex.setNum(soidx);
|
||||
m_markers->coordIndex.finishEditing();
|
||||
}
|
||||
else
|
||||
@@ -487,6 +482,9 @@ bool ViewProviderFemPostObject::setupPipeline() {
|
||||
m_outline = vtkOutlineCornerFilter::New();
|
||||
m_outline->SetInputConnection(algorithm->GetOutputPort());
|
||||
|
||||
m_points = vtkVertexGlyphFilter::New();
|
||||
m_points->SetInputConnection(algorithm->GetOutputPort());
|
||||
|
||||
m_surface = vtkGeometryFilter::New();
|
||||
m_surface->SetInputConnection(algorithm->GetOutputPort());
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@
|
||||
#include <vtkExtractEdges.h>
|
||||
#include <vtkAppendPolyData.h>
|
||||
#include <vtkGeometryFilter.h>
|
||||
#include <vtkVertexGlyphFilter.h>
|
||||
|
||||
class SoIndexedPointSet;
|
||||
class vtkUnsignedCharArray;
|
||||
class vtkDataArray;
|
||||
class vtkPoints;
|
||||
@@ -107,7 +109,7 @@ protected:
|
||||
void update();
|
||||
|
||||
SoCoordinate3* m_coordinates;
|
||||
SoIndexedMarkerSet* m_markers;
|
||||
SoIndexedPointSet* m_markers;
|
||||
SoIndexedLineSet* m_lines;
|
||||
SoIndexedFaceSet* m_faces;
|
||||
SoIndexedTriangleStripSet* m_triangleStrips;
|
||||
@@ -124,6 +126,7 @@ protected:
|
||||
vtkSmartPointer<vtkAppendPolyData> m_surfaceEdges;
|
||||
vtkSmartPointer<vtkOutlineCornerFilter> m_outline;
|
||||
vtkSmartPointer<vtkExtractEdges> m_wireframe;
|
||||
vtkSmartPointer<vtkVertexGlyphFilter> m_points;
|
||||
vtkSmartPointer<vtkLookupTable> m_lookup;
|
||||
|
||||
private:
|
||||
|
||||
@@ -83,6 +83,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
|
||||
Gui::ToolBarItem* post = new Gui::ToolBarItem(root);
|
||||
post->setCommand("Post Processing");
|
||||
*post << "Fem_PostApplyChanges"
|
||||
<< "Fem_PostPipelineFromResult"
|
||||
<< "Separator"
|
||||
<< "Fem_PostCreateClipFilter"
|
||||
<< "Fem_PostCreateScalarClipFilter"
|
||||
|
||||
Reference in New Issue
Block a user