| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2014 Klaralvdalens Datakonsult AB (KDAB). | 
| 4 | ** Copyright (C) 2016 The Qt Company Ltd and/or its subsidiary(-ies). | 
| 5 | ** Contact: https://www.qt.io/licensing/ | 
| 6 | ** | 
| 7 | ** This file is part of the Qt3D module of the Qt Toolkit. | 
| 8 | ** | 
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 10 | ** Commercial License Usage | 
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 12 | ** accordance with the commercial license agreement provided with the | 
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 17 | ** | 
| 18 | ** GNU Lesser General Public License Usage | 
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 20 | ** General Public License version 3 as published by the Free Software | 
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 22 | ** packaging of this file. Please review the following information to | 
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 25 | ** | 
| 26 | ** GNU General Public License Usage | 
| 27 | ** Alternatively, this file may be used under the terms of the GNU | 
| 28 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 29 | ** Public license version 3 or any later version approved by the KDE Free | 
| 30 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 32 | ** included in the packaging of this file. Please review the following | 
| 33 | ** information to ensure the GNU General Public License requirements will | 
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 36 | ** | 
| 37 | ** $QT_END_LICENSE$ | 
| 38 | ** | 
| 39 | ****************************************************************************/ | 
| 40 |  | 
| 41 | #include "qscissortest.h" | 
| 42 | #include "qscissortest_p.h" | 
| 43 | #include <Qt3DRender/private/qrenderstatecreatedchange_p.h> | 
| 44 |  | 
| 45 | QT_BEGIN_NAMESPACE | 
| 46 |  | 
| 47 | namespace Qt3DRender { | 
| 48 |  | 
| 49 | /*! | 
| 50 |     \class Qt3DRender::QScissorTest | 
| 51 |     \brief The QScissorTest class discards fragments that fall outside of a | 
| 52 |     certain rectangular portion of the screen. | 
| 53 |     \since 5.7 | 
| 54 |     \ingroup renderstates | 
| 55 |     \inmodule Qt3DRender | 
| 56 |  | 
| 57 |     A QScissorTest class enables scissor test, which discards fragments outside | 
| 58 |     the rectangular area of the screen specified by the left, bottom, width and | 
| 59 |     height properties. | 
| 60 |  */ | 
| 61 |  | 
| 62 | /*! | 
| 63 |     \qmltype ScissorTest | 
| 64 |     \brief The ScissorTest type discards fragments that fall outside of a | 
| 65 |     certain rectangular portion of the screen. | 
| 66 |     \since 5.7 | 
| 67 |     \ingroup renderstates | 
| 68 |     \inqmlmodule Qt3D.Render | 
| 69 |     \instantiates Qt3DRender::QScissorTest | 
| 70 |     \inherits RenderState | 
| 71 |  | 
| 72 |     A ScissorTest type enables scissor test, which discards fragments outside | 
| 73 |     the rectangular area of the screen specified by the left, bottom, width and | 
| 74 |     height properties. | 
| 75 |  */ | 
| 76 |  | 
| 77 | /*! | 
| 78 |     \qmlproperty int ScissorTest::left | 
| 79 |     Holds the left coordinate of the scissor box. | 
| 80 | */ | 
| 81 |  | 
| 82 | /*! | 
| 83 |     \qmlproperty int ScissorTest::bottom | 
| 84 |     Holds the bottom coordinate of the scissor box. | 
| 85 | */ | 
| 86 |  | 
| 87 | /*! | 
| 88 |     \qmlproperty int ScissorTest::width | 
| 89 |     Holds the width of the scissor box. | 
| 90 | */ | 
| 91 |  | 
| 92 | /*! | 
| 93 |     \qmlproperty int ScissorTest::height | 
| 94 |     Holds the height of the scissor box. | 
| 95 | */ | 
| 96 |  | 
| 97 | /*! | 
| 98 |     \property QScissorTest::left | 
| 99 |     Holds the left coordinate of the scissor box. | 
| 100 | */ | 
| 101 |  | 
| 102 | /*! | 
| 103 |     \property QScissorTest::bottom | 
| 104 |     Holds the bottom coordinate of the scissor box. | 
| 105 | */ | 
| 106 |  | 
| 107 | /*! | 
| 108 |     \property QScissorTest::width | 
| 109 |     Holds the width of the scissor box. | 
| 110 | */ | 
| 111 |  | 
| 112 | /*! | 
| 113 |     \property QScissorTest::height | 
| 114 |     Holds the height of the scissor box. | 
| 115 | */ | 
| 116 |  | 
| 117 | /*! | 
| 118 |     The constructor creates a new QScissorTest::QScissorTest instance with the | 
| 119 |     specified \a parent | 
| 120 |  */ | 
| 121 | QScissorTest::QScissorTest(QNode *parent) | 
| 122 |     : QRenderState(*new QScissorTestPrivate, parent) | 
| 123 | { | 
| 124 | } | 
| 125 |  | 
| 126 | /*! \internal */ | 
| 127 | QScissorTest::~QScissorTest() | 
| 128 | { | 
| 129 | } | 
| 130 |  | 
| 131 | int QScissorTest::left() const | 
| 132 | { | 
| 133 |     Q_D(const QScissorTest); | 
| 134 |     return d->m_left; | 
| 135 | } | 
| 136 |  | 
| 137 | void QScissorTest::setLeft(int left) | 
| 138 | { | 
| 139 |     Q_D(QScissorTest); | 
| 140 |     if (d->m_left != left) { | 
| 141 |         d->m_left = left; | 
| 142 |         emit leftChanged(left); | 
| 143 |     } | 
| 144 | } | 
| 145 |  | 
| 146 | int QScissorTest::bottom() const | 
| 147 | { | 
| 148 |     Q_D(const QScissorTest); | 
| 149 |     return d->m_bottom; | 
| 150 | } | 
| 151 |  | 
| 152 | void QScissorTest::setBottom(int bottom) | 
| 153 | { | 
| 154 |     Q_D(QScissorTest); | 
| 155 |     if (d->m_bottom != bottom) { | 
| 156 |         d->m_bottom = bottom; | 
| 157 |         emit bottomChanged(bottom); | 
| 158 |     } | 
| 159 | } | 
| 160 |  | 
| 161 | int QScissorTest::width() const | 
| 162 | { | 
| 163 |     Q_D(const QScissorTest); | 
| 164 |     return d->m_width; | 
| 165 | } | 
| 166 |  | 
| 167 | void QScissorTest::setWidth(int width) | 
| 168 | { | 
| 169 |     Q_D(QScissorTest); | 
| 170 |     if (d->m_width != width) { | 
| 171 |         d->m_width = width; | 
| 172 |         emit widthChanged(width); | 
| 173 |     } | 
| 174 | } | 
| 175 |  | 
| 176 | int QScissorTest::height() const | 
| 177 | { | 
| 178 |     Q_D(const QScissorTest); | 
| 179 |     return d->m_height; | 
| 180 | } | 
| 181 |  | 
| 182 | void QScissorTest::setHeight(int height) | 
| 183 | { | 
| 184 |     Q_D(QScissorTest); | 
| 185 |     if (d->m_height != height) { | 
| 186 |         d->m_height = height; | 
| 187 |         emit heightChanged(height); | 
| 188 |     } | 
| 189 | } | 
| 190 |  | 
| 191 | Qt3DCore::QNodeCreatedChangeBasePtr QScissorTest::createNodeCreationChange() const | 
| 192 | { | 
| 193 |     auto creationChange = QRenderStateCreatedChangePtr<QScissorTestData>::create(arguments: this); | 
| 194 |     auto &data = creationChange->data; | 
| 195 |     Q_D(const QScissorTest); | 
| 196 |     data.left = d->m_left; | 
| 197 |     data.bottom = d->m_bottom; | 
| 198 |     data.width = d->m_width; | 
| 199 |     data.height = d->m_height; | 
| 200 |     return creationChange; | 
| 201 | } | 
| 202 |  | 
| 203 | } // namespace Qt3DRender | 
| 204 |  | 
| 205 | QT_END_NAMESPACE | 
| 206 |  |