Remove unused DAGFilter

This commit is contained in:
Jiří Pinkava
2025-08-24 09:14:03 +02:00
committed by Chris Hennes
parent e5518f9ad1
commit c72d3f706b
6 changed files with 2 additions and 216 deletions

View File

@@ -774,7 +774,6 @@ SET(Dock_Windows_CPP_SRCS
DAGView/DAGModel.cpp
DAGView/DAGRectItem.cpp
DAGView/DAGModelGraph.cpp
DAGView/DAGFilter.cpp
)
SET(Dock_Windows_HPP_SRCS
ComboView.h
@@ -789,7 +788,6 @@ SET(Dock_Windows_HPP_SRCS
DAGView/DAGModel.h
DAGView/DAGRectItem.h
DAGView/DAGModelGraph.h
DAGView/DAGFilter.h
)
SET(Dock_Windows_SRCS
${Dock_Windows_CPP_SRCS}

View File

@@ -1,85 +0,0 @@
/***************************************************************************
* Copyright (c) 2015 Thomas Anderson <blobfish[at]gmx.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#include <App/DocumentObject.h>
#include <Base/Type.h>
#include "DAGFilter.h"
using namespace Gui;
using namespace DAG;
FilterBase::FilterBase() : name(QStringLiteral("empty name"))
{
}
FilterOrigin::FilterOrigin() : FilterBase()
{
name = QObject::tr("Origin");
}
bool FilterOrigin::goFilter(const Vertex &vertexIn, const Graph &graphIn, const GraphLinkContainer &linkIn) const
{
Base::Type originType = Base::Type::fromName("App::Origin");
assert (!originType.isBad());
//if child of origin hide.
InEdgeIterator it, itEnd;
for (boost::tie(it, itEnd) = boost::in_edges(vertexIn, graphIn); it != itEnd; ++it)
{
Vertex source = boost::source(*it, graphIn);
const GraphLinkRecord &sourceRecord = findRecord(source, linkIn);
if
(
(sourceRecord.DObject->getTypeId() == originType) &&
(boost::in_degree(vertexIn, graphIn) == 1)
)
return true;
}
return false;
}
FilterTyped::FilterTyped(const std::string &typeIn) : FilterBase(), type(typeIn)
{
name = QString::fromStdString(typeIn);
}
bool FilterTyped::goFilter(const Gui::DAG::Vertex& vertexIn, const Graph& graphIn, const GraphLinkContainer& linkIn) const
{
Q_UNUSED(graphIn);
if (type.empty())
return false;
Base::Type theType = Base::Type::fromName(type.c_str());
if (theType.isBad())
return false;
const GraphLinkRecord &sourceRecord = findRecord(vertexIn, linkIn);
if (sourceRecord.DObject->getTypeId() == theType)
return true;
return false;
}

View File

@@ -1,73 +0,0 @@
/***************************************************************************
* Copyright (c) 2015 Thomas Anderson <blobfish[at]gmx.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef DAGFILTER_H
#define DAGFILTER_H
#include <QString>
#include "DAGModelGraph.h"
namespace Gui
{
class ViewProviderDocumentObject;
namespace DAG
{
class FilterBase
{
public:
enum class Type
{
None = 0, //!< no type designation. shouldn't be used.
Inclusion,
Exclusion
};
FilterBase();
//! @return is whether we have a match or not.
virtual bool goFilter(const Vertex &vertexIn, const Graph &graphIn, const GraphLinkContainer &linkIn) const = 0;
QString name;
bool enabled = true;
Type type = Type::Exclusion;
};
/*! Hide all children of app::origin that are not
* used by subsequent features
*/
class FilterOrigin : public FilterBase
{
public:
FilterOrigin();
bool goFilter(const Vertex &vertexIn, const Graph &graphIn, const GraphLinkContainer &linkIn) const override;
};
/*! Hide nodes of type*/
class FilterTyped : public FilterBase
{
public:
explicit FilterTyped(const std::string &typeIn);
std::string type;
bool goFilter(const Vertex &vertexIn, const Graph &graphIn, const GraphLinkContainer &linkIn) const override;
};
}
}
#endif // DAGFILTER_H

View File

@@ -102,7 +102,6 @@ Model::Model(QObject *parentIn, const Gui::Document &documentIn) : QGraphicsScen
theGraph = std::make_shared<Graph>();
graphLink = std::make_shared<GraphLinkContainer>();
setupViewConstants();
setupFilters();
graphDirty = false;
currentPrehighlight = nullptr;
@@ -168,13 +167,6 @@ Model::~Model()
removeAllItems();
}
void Model::setupFilters()
{
// filters.push_back(std::shared_ptr<FilterOrigin>(new FilterOrigin()));
// filters.push_back(std::shared_ptr<FilterTyped>(new FilterTyped("PartDesign::Body")));
// filters.push_back(std::shared_ptr<FilterTyped>(new FilterTyped("App::Part")));
}
void Model::setupViewConstants()
{
ParameterGrp::handle group = App::GetApplication().GetUserParameter().
@@ -490,39 +482,10 @@ void Model::updateSlot()
}
}
//apply filters.
BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph)
{
(*theGraph)[currentVertex].dagVisible = true; //default to shown.
for (const auto &currentFilter : filters)
{
if (!currentFilter->enabled || currentFilter->type != FilterBase::Type::Exclusion)
continue;
if (currentFilter->goFilter(currentVertex, *theGraph, *graphLink))
(*theGraph)[currentVertex].dagVisible = false;
}
}
//inclusion takes precedence. Separate loop because filters might probe
//children and parents. So we want to ensure all exclusions are done
//before inclusions start.
BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph)
{
for (const auto &currentFilter : filters)
{
if (!currentFilter->enabled || currentFilter->type != FilterBase::Type::Inclusion)
continue;
if (currentFilter->goFilter(currentVertex, *theGraph, *graphLink))
(*theGraph)[currentVertex].dagVisible = true;
}
}
//sync scene items to graph vertex dagVisible.
BGL_FORALL_VERTICES(currentVertex, *theGraph, Graph)
{
if ((*theGraph)[currentVertex].dagVisible && (!(*theGraph)[currentVertex].rectangle->scene()))
if (!(*theGraph)[currentVertex].rectangle->scene())
addVertexItemsToScene(currentVertex);
if ((!(*theGraph)[currentVertex].dagVisible) && (*theGraph)[currentVertex].rectangle->scene())
removeVertexItemsFromScene(currentVertex);
}
//sync scene items for graph edge.
@@ -531,11 +494,8 @@ void Model::updateSlot()
Vertex source = boost::source(currentEdge, *theGraph);
Vertex target = boost::target(currentEdge, *theGraph);
bool edgeVisible = (*theGraph)[source].dagVisible && (*theGraph)[target].dagVisible;
if (edgeVisible && (!(*theGraph)[currentEdge].connector->scene()))
if (!(*theGraph)[currentEdge].connector->scene())
this->addItem((*theGraph)[currentEdge].connector.get());
if ((!edgeVisible) && (*theGraph)[currentEdge].connector->scene())
this->removeItem((*theGraph)[currentEdge].connector.get());
}
indexVerticesEdges();
@@ -566,9 +526,6 @@ void Model::updateSlot()
qreal maxTextLength = 0;
for (const auto &currentVertex : sorted)
{
if (!(*theGraph)[currentVertex].dagVisible)
continue;
if (boost::out_degree(currentVertex, *theGraph) == 0)
currentColumn = 0;
else
@@ -618,8 +575,6 @@ void Model::updateSlot()
if (((*theGraph)[currentParent].column & columnMask).none())
{
//go with first visible parent for now.
if (!(*theGraph)[currentParent].dagVisible)
continue;
destinationColumn = static_cast<int>(columnFromMask((*theGraph)[currentParent].column));
break;
}
@@ -690,8 +645,6 @@ void Model::updateSlot()
for (; it != itEnd; ++it)
{
Vertex target = boost::target(*it, *theGraph);
if (!(*theGraph)[target].dagVisible)
continue; //we don't make it here if source isn't visible. So don't have to worry about that.
qreal dependentX = pointSpacing * static_cast<int>(columnFromMask((*theGraph)[target].column)) + pointSize / 2.0; //on center.
columnFromMask((*theGraph)[target].column);
qreal dependentY = rowHeight * (*theGraph)[target].row + rowHeight / 2.0;

View File

@@ -32,7 +32,6 @@
#include <QGraphicsScene>
#include <QLineEdit>
#include "DAGFilter.h"
#include "DAGModelGraph.h"
#include "DAGRectItem.h"
@@ -159,11 +158,6 @@ namespace Gui
QAction *editingFinishedAction;
QGraphicsProxyWidget *proxy = nullptr;
void finishRename();
//filters
void setupFilters();
using FilterContainer = std::vector<std::shared_ptr<FilterBase> >;
FilterContainer filters;
};
}
}

View File

@@ -87,7 +87,6 @@ namespace Gui
int topoSortIndex = 0;
VisibilityState lastVisibleState = VisibilityState::None; //!< visibility test.
FeatureState lastFeatureState = FeatureState::None; //!< feature state test.
bool dagVisible = true; //!< should entry be visible in the DAG view.
};
/*! @brief boost data for each vertex.
*