Hide menu
Loading...
Searching...
No Matches
visualization/qtquick_qml/exploder/main.cxx

Refer to Exploder Example

ExploderApplication.hxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#ifndef __ExploderApplication_HeaderFile
#define __ExploderApplication_HeaderFile
#include "../baseviewer/BaseViewerApplication.hxx"
class ExploderApplication : public BaseViewerApplication
{
Q_OBJECT
public:
ExploderApplication();
public slots:
void onExplodeValueChanged (const QVariant& theValue);
void onInitialized();
};
#endif // __ExploderApplication_HeaderFile

ExploderApplication.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include "ExploderApplication.hxx"
#include <cadex/ModelPrsQtQuick_ViewPort.hxx>
#include <cadex/ModelPrs_Exploder.hxx>
#include <QtQuick/QQuickWindow>
using namespace cadex;
ExploderApplication::ExploderApplication()
{
connect (this, &BaseViewerApplication::initialized, this, &ExploderApplication::onInitialized);
}
void ExploderApplication::onInitialized()
{
connect (myMainWindow, SIGNAL (explodeValueChanged (const QVariant&)),
this, SLOT (onExplodeValueChanged (const QVariant&)));
}
void ExploderApplication::onExplodeValueChanged (const QVariant& theValue)
{
myViewPort->Exploder().SetValue (theValue.toFloat());
}
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22

ExploderWindow.qml

import QtQuick 2.12
import QtQuick.Controls 2.3
import CadEx 1.2
BaseViewerWindow {
id: root
signal explodeValueChanged(var value)
Rectangle {
id: exploderBar
radius: 3
width: 300
height: column.implicitHeight
anchors.margins: 10
anchors.top: parent.top
anchors.right: parent.right
color: "#CCFFFFFF"
border.color: "#55000000"
readonly property string textColor: "#BB000000"
Column {
id: column
padding: 20
spacing: 20
width: parent.width
Text {
width: parent.width - 40
horizontalAlignment: Text.AlignHCenter
font.pointSize: 14
font.bold: true
color: exploderBar.textColor
text: qsTr ("Explode value")
}
Row {
width: parent.width - 40
spacing: 10
Slider {
id: slider
from: 0
to: 1
value: 0
stepSize: 0.02
onValueChanged: {
root.explodeValueChanged (value);
}
onPressedChanged: {
if (autoFitAll.checked && !pressed) {
viewPort.animatedFitAll();
}
}
}
Text {
text: Math.round (slider.value * 100) + " %"
anchors.verticalCenter: parent.verticalCenter
font.pointSize: 12
}
}
Row {
Button {
width: 180
text: qsTr ("Fit-all")
onClicked: {
viewPort.animatedFitAll();
}
}
CheckBox {
id: autoFitAll
text: qsTr ("Auto")
}
}
}
}
}

main.cxx

// ****************************************************************************
// $Id$
//
// Copyright (C) 2008-2014, Roman Lygin. All rights reserved.
// Copyright (C) 2014-2023, CADEX. All rights reserved.
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include "ExploderApplication.hxx"
#include <cadex/LicenseManager_Activate.h>
#include <QtCore/QUrl>
#include <QtWidgets/QApplication>
#include "../../../cadex_license.cxx"
using namespace cadex;
int main (int argc, char *argv[])
{
auto aKey = LicenseKey::Value();
//activate the license (aKey must be defined in cadex_license.cxx)
if (!CADExLicense_Activate (aKey)) {
qCritical ("Failed to activate CAD Exchanger license.");
return 1;
}
// Must set dpi scaling before creating an application.
QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
// Create QApplication because Qt.labs.platform module requires Qt Widgets library.
// For more information see https://doc.qt.io/qt-5.10/qml-qt-labs-platform-filedialog.html
QApplication app (argc, argv);
ExploderApplication anApp;
if (anApp.Initialize (QUrl ("qrc:/qml/ExploderWindow.qml"), "viewPort")) {
return app.exec();
}
return 0;
}