| 1 |
/*************************************************************************** |
| 2 |
* Copyright (c) 2015 Alexander Golubev (Fat-Zer) <[email protected]> * |
| 3 |
* Copyright (c) 2016 Stefan Tröger <[email protected]> * |
| 4 |
* * |
| 5 |
* This file is part of the FreeCAD CAx development system. * |
| 6 |
* * |
| 7 |
* This library is free software; you can redistribute it and/or * |
| 8 |
* modify it under the terms of the GNU Library General Public * |
| 9 |
* License as published by the Free Software Foundation; either * |
| 10 |
* version 2 of the License, or (at your option) any later version. * |
| 11 |
* * |
| 12 |
* This library is distributed in the hope that it will be useful, * |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 15 |
* GNU Library General Public License for more details. * |
| 16 |
* * |
| 17 |
* You should have received a copy of the GNU Library General Public * |
| 18 |
* License along with this library; see the file COPYING.LIB. If not, * |
| 19 |
* write to the Free Software Foundation, Inc., 59 Temple Place, * |
| 20 |
* Suite 330, Boston, MA 02111-1307, USA * |
| 21 |
* * |
| 22 |
***************************************************************************/ |
| 23 |
|
| 24 |
|
| 25 |
#include <Inventor/actions/SoGetBoundingBoxAction.h> |
| 26 |
#include <Inventor/nodes/SoSeparator.h> |
| 27 |
|
| 28 |
|
| 29 |
#include <App/Document.h> |
| 30 |
#include <App/Origin.h> |
| 31 |
#include <App/OriginGroupExtension.h> |
| 32 |
#include <Base/Console.h> |
| 33 |
|
| 34 |
#include "ViewProviderOriginGroupExtension.h" |
| 35 |
#include "Application.h" |
| 36 |
#include "Document.h" |
| 37 |
#include "View3DInventor.h" |
| 38 |
#include "View3DInventorViewer.h" |
| 39 |
#include "ViewProviderCoordinateSystem.h" |
| 40 |
#include "ViewProviderDatum.h" |
| 41 |
|
| 42 |
|
| 43 |
using namespace Gui; |
| 44 |
namespace sp = std::placeholders; |
| 45 |
|
| 46 |
|
| 47 |
EXTENSION_PROPERTY_SOURCE(Gui::ViewProviderOriginGroupExtension, Gui::ViewProviderGeoFeatureGroupExtension) |
| 48 |
|
| 49 |
ViewProviderOriginGroupExtension::ViewProviderOriginGroupExtension() |
| 50 |
{ |
| 51 |
initExtensionType(ViewProviderOriginGroupExtension::getExtensionClassTypeId()); |
| 52 |
} |
| 53 |
|
| 54 |
ViewProviderOriginGroupExtension::~ViewProviderOriginGroupExtension() |
| 55 |
{} |
| 56 |
|
| 57 |
std::vector<App::DocumentObject*> ViewProviderOriginGroupExtension::constructChildren( |
| 58 |
const std::vector<App::DocumentObject*>& children |
| 59 |
) const |
| 60 |
{ |
| 61 |
auto* obj = getExtendedViewProvider()->getObject(); |
| 62 |
auto* group = obj ? obj->getExtensionByType<App::OriginGroupExtension>() : nullptr; |
| 63 |
if (!group) { |
| 64 |
return children; |
| 65 |
} |
| 66 |
|
| 67 |
App::DocumentObject* originObj = group->Origin.getValue(); |
| 68 |
|
| 69 |
// Origin must be first |
| 70 |
if (originObj) { |
| 71 |
std::vector<App::DocumentObject*> rv; |
| 72 |
rv.push_back(originObj); |
| 73 |
std::copy(children.begin(), children.end(), std::back_inserter(rv)); |
| 74 |
return rv; |
| 75 |
} |
| 76 |
else { // Generally shouldn't happen but must be handled in case origin is lost |
| 77 |
return children; |
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
|
| 82 |
std::vector<App::DocumentObject*> ViewProviderOriginGroupExtension::extensionClaimChildren() const |
| 83 |
{ |
| 84 |
return constructChildren(ViewProviderGeoFeatureGroupExtension::extensionClaimChildren()); |
| 85 |
} |
| 86 |
|
| 87 |
std::vector<App::DocumentObject*> ViewProviderOriginGroupExtension::extensionClaimChildren3D() const |
| 88 |
{ |
| 89 |
return constructChildren(ViewProviderGeoFeatureGroupExtension::extensionClaimChildren3D()); |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
namespace Gui |
| 94 |
{ |
| 95 |
EXTENSION_PROPERTY_SOURCE_TEMPLATE( |
| 96 |
Gui::ViewProviderOriginGroupExtensionPython, |
| 97 |
Gui::ViewProviderOriginGroupExtension |
| 98 |
) |
| 99 |
|
| 100 |
// explicit template instantiation |
| 101 |
template class GuiExport ViewProviderExtensionPythonT<ViewProviderOriginGroupExtension>; |
| 102 |
} // namespace Gui |