FreeCAD

Форк
0
/
DAGFilter.cpp 
83 строки · 3.1 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2015 Thomas Anderson <blobfish[at]gmx.com>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

25
#include <App/DocumentObject.h>
26
#include <Base/Type.h>
27

28
#include "DAGFilter.h"
29

30

31
using namespace Gui;
32
using namespace DAG;
33

34
FilterBase::FilterBase() : name(QString::fromLatin1("empty name"))
35
{
36

37
}
38

39
FilterOrigin::FilterOrigin() : FilterBase()
40
{
41
  name = QObject::tr("Origin");
42
}
43

44
bool FilterOrigin::goFilter(const Vertex &vertexIn, const Graph &graphIn, const GraphLinkContainer &linkIn) const
45
{
46
  Base::Type originType = Base::Type::fromName("App::Origin");
47
  assert (originType != Base::Type::badType());
48
  //if child of origin hide.
49
  InEdgeIterator it, itEnd;
50
  for (boost::tie(it, itEnd) = boost::in_edges(vertexIn, graphIn); it != itEnd; ++it)
51
  {
52
    Vertex source = boost::source(*it, graphIn);
53
    const GraphLinkRecord &sourceRecord = findRecord(source, linkIn);
54
    if
55
    (
56
      (sourceRecord.DObject->getTypeId() == originType) &&
57
      (boost::in_degree(vertexIn, graphIn) == 1)
58
    )
59
      return true;
60
  }
61
  return false;
62
}
63

64
FilterTyped::FilterTyped(const std::string &typeIn) : FilterBase(), type(typeIn)
65
{
66
  name = QString::fromStdString(typeIn);
67
}
68

69
bool FilterTyped::goFilter(const Gui::DAG::Vertex& vertexIn, const Graph& graphIn, const GraphLinkContainer& linkIn) const
70
{
71
  Q_UNUSED(graphIn);
72
  if (type.empty())
73
    return false;
74
  Base::Type theType = Base::Type::fromName(type.c_str());
75
  if (theType == Base::Type::badType())
76
    return false;
77

78
  const GraphLinkRecord &sourceRecord = findRecord(vertexIn, linkIn);
79
  if (sourceRecord.DObject->getTypeId() == theType)
80
    return true;
81

82
  return false;
83
}
84

85

86

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.