Skip to content

Commit

Permalink
add command for creating APLAN analysis container
Browse files Browse the repository at this point in the history
  • Loading branch information
martcram committed Nov 9, 2021
1 parent fefaab0 commit a43b79e
Show file tree
Hide file tree
Showing 9 changed files with 304 additions and 4 deletions.
8 changes: 8 additions & 0 deletions App/AppAplan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

#include <CXX/Extensions.hxx>

#include "AplanAnalysis.hpp"

namespace Aplan
{
extern PyObject *initModule();
Expand All @@ -43,5 +45,11 @@ PyMOD_INIT_FUNC(Aplan)
PyObject *mod = Aplan::initModule();
Base::Console().Log("Loading the APLAN module... done\n");

Aplan::DocumentObject::init();
Aplan::FeaturePython::init();

Aplan::AplanAnalysis::init();
Aplan::AplanAnalysisPython::init();

PyMOD_Return(mod);
}
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ endif(BUILD_GUI)
SET(AplanBaseModules_SRCS
Init.py
InitGui.py
ObjectsAplan.py
)

SET(AplanCommands_SRCS
Expand Down
4 changes: 4 additions & 0 deletions Gui/AppAplanGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <Gui/Application.h>
#include <Gui/Language/Translator.h>

#include "ViewProviderAnalysis.hpp"
#include "Workbench.hpp"

void CreateAplanCommands(void);
Expand Down Expand Up @@ -66,6 +67,9 @@ PyMOD_INIT_FUNC(AplanGui)
// addition objects
AplanGui::Workbench::init();

AplanGui::ViewProviderAplanAnalysis::init();
AplanGui::ViewProviderAplanAnalysisPython::init();

// add resources and reloads the translators
loadAplanResource();

Expand Down
34 changes: 33 additions & 1 deletion Gui/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,42 @@ void CmdAplanTest::activated(int)
Base::Console().Message("Hello, World!\n");
}
//================================================================================================
DEF_STD_CMD_A(CmdAplanAnalysis)

CmdAplanAnalysis::CmdAplanAnalysis()
: Command("APLAN_Analysis")
{
sAppModule = "Aplan";
sGroup = QT_TR_NOOP("Aplan");
sMenuText = QT_TR_NOOP("Analysis container");
sToolTipText = QT_TR_NOOP("Creates an APLAN analysis container with a standard solver");
sWhatsThis = "APLAN_Analysis";
sStatusTip = sToolTipText;
sPixmap = "APLAN_Analysis";
sAccel = "S, A";
}

void CmdAplanAnalysis::activated(int)
{
std::string analysisName = getUniqueObjectName("Analysis");
openCommand(QT_TRANSLATE_NOOP("Command", "Create an APLAN analysis container"));
addModule(Doc, "AplanGui");
addModule(Doc, "ObjectsAplan");
doCommand(Doc, "ObjectsAplan.makeAnalysis(FreeCAD.ActiveDocument, \"%s\")", analysisName.c_str());
doCommand(Doc, "AplanGui.setActiveAnalysis(FreeCAD.ActiveDocument.ActiveObject)");
updateActive();
}

bool CmdAplanAnalysis::isActive(void)
{
return Gui::Application::Instance->activeDocument();
}
//================================================================================================

void CreateAplanCommands(void)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();

rcCmdMgr.addCommand(new CmdAplanTest());
// rcCmdMgr.addCommand(new CmdAplanTest());
rcCmdMgr.addCommand(new CmdAplanAnalysis());
}
1 change: 1 addition & 0 deletions Gui/Resources/Aplan.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<!-- gui command icons -->
<file>icons/APLAN_Analysis.svg</file>

</qresource>
</RCC>
195 changes: 195 additions & 0 deletions Gui/Resources/icons/APLAN_Analysis.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 19 additions & 3 deletions Gui/Workbench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
#include <qobject.h>
#endif

#include "Workbench.hpp"
#include <Gui/MenuManager.h>
#include <Gui/ToolBarManager.h>

#include "ActiveAnalysisObserver.hpp"
#include "Workbench.hpp"

using namespace AplanGui;

#if 0 // needed for Qt's lupdate utility
Expand All @@ -53,6 +55,17 @@ Workbench::~Workbench()
{
}

void Workbench::activated()
{
Gui::Workbench::activated();
}

void Workbench::deactivated()
{
AplanGui::ActiveAnalysisObserver::instance()->unsetActiveObject();
Gui::Workbench::deactivated();
}

Gui::MenuItem *Workbench::setupMenuBar() const
{
Gui::MenuItem *root = StdWorkbench::setupMenuBar();
Expand All @@ -61,6 +74,8 @@ Gui::MenuItem *Workbench::setupMenuBar() const
Gui::MenuItem *model = new Gui::MenuItem;
root->insertItem(item, model);
model->setCommand("M&odel");
*model << "APLAN_Analysis"
<< "Separator";

return root;
}
Expand All @@ -71,8 +86,9 @@ Gui::ToolBarItem *Workbench::setupToolBars() const

Gui::ToolBarItem *model = new Gui::ToolBarItem(root);
model->setCommand("Model");
*model << "APLAN_ToggleTransparency"
<< "APLAN_Test";
*model << "APLAN_Analysis"
<< "Separator"
<< "APLAN_ToggleTransparency";

return root;
}
5 changes: 5 additions & 0 deletions Gui/Workbench.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ namespace AplanGui
Workbench();
virtual ~Workbench();

// Run some actions when the workbench gets activated.
virtual void activated();
// Run some actions when the workbench gets deactivated.
virtual void deactivated();

protected:
Gui::MenuItem *setupMenuBar() const;
Gui::ToolBarItem *setupToolBars() const;
Expand Down
38 changes: 38 additions & 0 deletions ObjectsAplan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# ***************************************************************************
# * *
# * Copyright (c) 2016 Bernd Hahnebach <bernd@bimstatik.org> *
# * Copyright (c) 2021 Martijn Cramer <martijn.cramer@outlook.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************

__title__ = "Objects APLAN"
__author__ = "Martijn Cramer, Bernd Hahnebach"
__url__ = "https://www.freecadweb.org"

# \addtogroup APLAN
# @{

# ********* analysis objects ************************************************
def makeAnalysis(doc, name="Analysis"):
"""makeAnalysis(document, [name]):
makes a APLAN analysis object"""
obj = doc.addObject("Aplan::AplanAnalysis", name)
return obj

0 comments on commit a43b79e

Please sign in to comment.