/src/libreoffice/svx/source/sdr/contact/viewobjectcontactofe3dscene.cxx
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | |
21 | | #include <sdr/contact/viewobjectcontactofe3dscene.hxx> |
22 | | #include <svx/sdr/contact/displayinfo.hxx> |
23 | | #include <svx/sdr/contact/objectcontact.hxx> |
24 | | #include <svx/sdr/contact/viewcontactofe3dscene.hxx> |
25 | | #include <basegfx/color/bcolormodifier.hxx> |
26 | | #include <drawinglayer/primitive2d/modifiedcolorprimitive2d.hxx> |
27 | | |
28 | | |
29 | | using namespace com::sun::star; |
30 | | |
31 | | |
32 | | namespace |
33 | | { |
34 | | // Helper method to recursively travel the DrawHierarchy for 3D objects contained in |
35 | | // the 2D Scene. This will create all VOCs for the current OC which are needed |
36 | | // for ActionChanged() functionality |
37 | | void impInternalSubHierarchyTraveller(const sdr::contact::ViewObjectContact& rVOC) |
38 | 0 | { |
39 | 0 | const sdr::contact::ViewContact& rVC = rVOC.GetViewContact(); |
40 | 0 | const sal_uInt32 nSubHierarchyCount(rVC.GetObjectCount()); |
41 | |
|
42 | 0 | for(sal_uInt32 a(0); a < nSubHierarchyCount; a++) |
43 | 0 | { |
44 | 0 | const sdr::contact::ViewObjectContact& rCandidate(rVC.GetViewContact(a).GetViewObjectContact(rVOC.GetObjectContact())); |
45 | 0 | impInternalSubHierarchyTraveller(rCandidate); |
46 | 0 | } |
47 | 0 | } |
48 | | } // end of anonymous namespace |
49 | | |
50 | | |
51 | | namespace sdr::contact |
52 | | { |
53 | | ViewObjectContactOfE3dScene::ViewObjectContactOfE3dScene(ObjectContact& rObjectContact, ViewContact& rViewContact) |
54 | 0 | : ViewObjectContactOfSdrObj(rObjectContact, rViewContact) |
55 | 0 | { |
56 | 0 | } |
57 | | |
58 | | ViewObjectContactOfE3dScene::~ViewObjectContactOfE3dScene() |
59 | 0 | { |
60 | 0 | } |
61 | | |
62 | | void ViewObjectContactOfE3dScene::createPrimitive2DSequence(const DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const |
63 | 0 | { |
64 | | // handle ghosted, else the whole 3d group will be encapsulated to a ghosted primitive set (see below) |
65 | 0 | const bool bHandleGhostedDisplay(GetObjectContact().DoVisualizeEnteredGroup() && !GetObjectContact().isOutputToPrinter() && rDisplayInfo.IsGhostedDrawModeActive()); |
66 | 0 | const bool bIsActiveVC(bHandleGhostedDisplay && GetObjectContact().getActiveViewContact() == &GetViewContact()); |
67 | |
|
68 | 0 | if(bIsActiveVC) |
69 | 0 | { |
70 | | // switch off ghosted, display contents normal |
71 | 0 | const_cast< DisplayInfo& >(rDisplayInfo).ClearGhostedDrawMode(); |
72 | 0 | } |
73 | | |
74 | | // create 2d primitive with content, use layer visibility test |
75 | | // this uses no ghosted mode, so scenes in scenes and entering them will not |
76 | | // support ghosted for now. This is no problem currently but would need to be |
77 | | // added when sub-groups in 3d will be added one day. |
78 | 0 | const ViewContactOfE3dScene& rViewContact = dynamic_cast< ViewContactOfE3dScene& >(GetViewContact()); |
79 | 0 | const SdrLayerIDSet& rVisibleLayers = rDisplayInfo.GetProcessLayers(); |
80 | 0 | drawinglayer::primitive2d::Primitive2DContainer xRetval(rViewContact.createScenePrimitive2DSequence(&rVisibleLayers)); |
81 | |
|
82 | 0 | if(!xRetval.empty()) |
83 | 0 | { |
84 | | // allow evtl. embedding in object-specific infos, e.g. Name, Title, Description |
85 | 0 | xRetval = rViewContact.embedToObjectSpecificInformation(std::move(xRetval)); |
86 | | |
87 | | // handle GluePoint |
88 | 0 | if(!GetObjectContact().isOutputToPrinter() && GetObjectContact().AreGluePointsVisible()) |
89 | 0 | { |
90 | 0 | drawinglayer::primitive2d::Primitive2DContainer xGlue(GetViewContact().createGluePointPrimitive2DSequence()); |
91 | |
|
92 | 0 | if(!xGlue.empty()) |
93 | 0 | { |
94 | 0 | xRetval.append(std::move(xGlue)); |
95 | 0 | } |
96 | 0 | } |
97 | | |
98 | | // handle ghosted |
99 | 0 | if(isPrimitiveGhosted(rDisplayInfo)) |
100 | 0 | { |
101 | 0 | const ::basegfx::BColor aRGBWhite(1.0, 1.0, 1.0); |
102 | 0 | const ::basegfx::BColorModifierSharedPtr aBColorModifier = |
103 | 0 | std::make_shared<basegfx::BColorModifier_interpolate>( |
104 | 0 | aRGBWhite, |
105 | 0 | 0.5); |
106 | 0 | const drawinglayer::primitive2d::Primitive2DReference xReference( |
107 | 0 | new drawinglayer::primitive2d::ModifiedColorPrimitive2D( |
108 | 0 | std::move(xRetval), |
109 | 0 | aBColorModifier)); |
110 | |
|
111 | 0 | xRetval = drawinglayer::primitive2d::Primitive2DContainer { xReference }; |
112 | 0 | } |
113 | 0 | } |
114 | |
|
115 | 0 | if(bIsActiveVC) |
116 | 0 | { |
117 | | // set back, display ghosted again |
118 | 0 | const_cast< DisplayInfo& >(rDisplayInfo).SetGhostedDrawMode(); |
119 | 0 | } |
120 | |
|
121 | 0 | rVisitor.visit(xRetval); |
122 | 0 | } |
123 | | |
124 | | void ViewObjectContactOfE3dScene::getPrimitive2DSequenceHierarchy(DisplayInfo& rDisplayInfo, drawinglayer::primitive2d::Primitive2DDecompositionVisitor& rVisitor) const |
125 | 0 | { |
126 | | // To get the VOCs for the contained 3D objects created to get the correct |
127 | | // Draw hierarchy and ActionChanged() working properly, travel the DrawHierarchy |
128 | | // using a local tooling method |
129 | 0 | impInternalSubHierarchyTraveller(*this); |
130 | | |
131 | | // call parent |
132 | 0 | ViewObjectContactOfSdrObj::getPrimitive2DSequenceHierarchy(rDisplayInfo, rVisitor); |
133 | 0 | } |
134 | | |
135 | | } // end of namespace |
136 | | |
137 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |