Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add point operation & Solid hatch load from file #312

Merged
merged 20 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lcUI/lcadpaperviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using namespace lc::ui;
using namespace lc::viewer;

#define PAPER_WIDTH 300
#define PAPER_HEIGHT 200
#define PAPER_HEIGHT -200

LCADPaperViewer::LCADPaperViewer(QWidget* parent,int id = 0):LCADViewer(parent),_id(id){
_gradientBackground = std::make_shared<drawable::PaperBackground>(PAPER_WIDTH, PAPER_HEIGHT);
Expand Down Expand Up @@ -47,4 +47,4 @@ void LCADPaperViewer::setDocument(std::shared_ptr<lc::storage::Document> documen

void LCADPaperViewer::onMouseMoveEvent(){
emit setActive(_id);
};
};
12 changes: 9 additions & 3 deletions lcUI/lcadviewerproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ LCADViewerProxy::LCADViewerProxy(QWidget* parent=0){
gridLayout->addWidget(_tabWidget, 0, 0, 1, 1);

_tabWidget->addTab(_modelViewerImpl, tr("Model"));
_tabWidget->addTab(_modelViewerImpl, tr("Paper 1"));//Just for init, removed later
_tabWidget->addTab(_modelViewerImpl, tr("Paper 2"));

_paperViewers = new LCADPaperViewerImpl(this);

//Connections to receive active View
Expand All @@ -44,16 +47,19 @@ void LCADViewerProxy::setDocument(std::shared_ptr<lc::storage::Document> documen
_modelViewerImpl->setDocument(document);
_paperViewers->setDocument(document);

_tabWidget->removeTab(1);
_tabWidget->removeTab(1);

//For each block create viewport
auto view = document->blockByName("*Paper_Space");
auto x = _paperViewers->getViewer();
x->setDocument(document,view);
_tabWidget->addTab(x,"Paper 1");
_tabWidget->addTab(x,tr("Paper 1"));

view = document->blockByName("*Paper_Space0");
x = _paperViewers->getViewer();
x->setDocument(document,view);
_tabWidget->addTab(x,"Paper 2");
_tabWidget->addTab(x,tr("Paper 2"));
}

void LCADViewerProxy::setActive(LCADViewer* view,bool isModel){
Expand All @@ -70,4 +76,4 @@ void LCADViewerProxy::setActive(LCADViewer* view,bool isModel){
connect(_activeView, SIGNAL(mouseReleaseEvent()), this, SIGNAL(mouseReleaseEvent()));
connect(_activeView, SIGNAL(keyPressEvent(int)), this, SIGNAL(keyPressEvent(int)));
}
}
}
11 changes: 11 additions & 0 deletions lcUI/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void MainWindow::ConnectInputEvents()
QObject::connect(findMenuItemByObjectName("actionSelect_All"), &QAction::triggered, this, &MainWindow::selectAll);
QObject::connect(findMenuItemByObjectName("actionSelect_None"), &QAction::triggered, this, &MainWindow::selectNone);
QObject::connect(findMenuItemByObjectName("actionInvert_Selection"), &QAction::triggered, this, &MainWindow::invertSelection);
QObject::connect(findMenuItemByObjectName("actionClear_Undoable_Stack"), &QAction::triggered, this, &MainWindow::clearUndoableStack);
}

/* Menu functions */
Expand Down Expand Up @@ -534,24 +535,34 @@ void MainWindow::openFile()
void MainWindow::undo()
{
_cadMdiChild.undoManager()->undo();
_cadMdiChild.viewer()->update();
}

void MainWindow::clearUndoableStack()
{
_cadMdiChild.undoManager()->removeUndoables();
}

void MainWindow::redo()
{
_cadMdiChild.undoManager()->redo();
_cadMdiChild.viewer()->update();
}

void MainWindow::selectAll()
{
_cadMdiChild.viewer()->docCanvas()->selectAll();
_cadMdiChild.viewer()->update();
}

void MainWindow::selectNone()
{
_cadMdiChild.viewer()->docCanvas()->removeSelection();
_cadMdiChild.viewer()->update();
}

void MainWindow::invertSelection()
{
_cadMdiChild.viewer()->docCanvas()->inverseSelection();
_cadMdiChild.viewer()->update();
}
1 change: 1 addition & 0 deletions lcUI/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ namespace lc
void selectAll();
void selectNone();
void invertSelection();
void clearUndoableStack();

signals:
void point(lc::geo::Coordinate coordinate);
Expand Down
6 changes: 6 additions & 0 deletions lcUI/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
<addaction name="actionClear_Undoable_Stack"/>
<addaction name="separator"/>
<addaction name="actionPolyline"/>
<addaction name="actionPoint"/>
<addaction name="actionSpline"/>
</widget>
</widget>
Expand Down Expand Up @@ -289,6 +290,11 @@
<string>&amp;Polyline</string>
</property>
</action>
<action name="actionPoint">
<property name="text">
<string>P&amp;oint</string>
</property>
</action>
<action name="actionSpline">
<property name="text">
<string>&amp;Spline</string>
Expand Down
76 changes: 76 additions & 0 deletions lcUI/ui/icons/point.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions lcUI/ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<addaction name="menuEllipse"/>
<addaction name="menuDimension"/>
<addaction name="actionPolyline"/>
<addaction name="actionPoint"/>
<addaction name="actionSpline"/>
</widget>
<addaction name="menuDemo_Project"/>
Expand Down Expand Up @@ -294,6 +295,11 @@
<string>&amp;Polyline</string>
</property>
</action>
<action name="actionPoint">
<property name="text">
<string>P&amp;oint</string>
</property>
</action>
<action name="actionSpline">
<property name="text">
<string>&amp;Spline</string>
Expand Down
1 change: 1 addition & 0 deletions lcUI/ui/resource.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
<file alias="snap_grid.svg">icons/snap_grid.svg</file>
<file alias="snap_intersection.svg">icons/snap_intersection.svg</file>
<file alias="snap_middle.svg">icons/snap_middle.svg</file>
<file alias="point.svg">icons/point.svg</file>
</qresource>
</RCC>
2 changes: 1 addition & 1 deletion lcUILua/createActions/createOperations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function CreateOperations:_init(builder, step)

self.prevEntity = nil
if(builder ~= nil) then
self.builder = builder() -- is it working?
self.builder = builder()
end

self.step = step
Expand Down
39 changes: 39 additions & 0 deletions lcUILua/createActions/pointoperations.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
PointOperations = {
command_line = "POINT",
icon = "point.svg",
descreption = "Point",
menu_actions = {
default = "actionPoint"
}
}
PointOperations.__index = PointOperations

setmetatable(PointOperations, {
__index = CreateOperations,
__call = function (o, ...)
local self = setmetatable({}, o)
self:_init(...)
return self
end,
})

function PointOperations:_init()
CreateOperations._init(self, lc.builder.PointBuilder, "enterPoint")
mainWindow:cliCommand():commandActive(true)
message("Add a new point")
end

--function PointOperations:_init_default()
-- message("<b>POINT</b>")
-- message("Provide Point")
-- self.step = "enterPoint"
--end

function PointOperations:enterPoint(eventName, data)
if(eventName == "mouseMove") then
self.builder:setCoordinate(data["position"])
elseif (eventName == "point") then
self.builder:setCoordinate(data["position"])
self:createEntity()
end
end
7 changes: 3 additions & 4 deletions lckernel/cad/geometry/geoarc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ Arc::Arc(Coordinate center, double radius, double startAngle, double endAngle, b
Base(),
_center(std::move(center)),
_radius(radius),
_startAngle(maths::Math::correctAngle(startAngle)),
_endAngle(maths::Math::correctAngle(endAngle)),
_startAngle(startAngle),
_endAngle(endAngle),
_CCW(isCCW) {

if (radius <= 0.0) {
throw std::runtime_error("Invalid radius");
}
Expand Down Expand Up @@ -169,4 +168,4 @@ double Arc::bulge() const {
}

return bulge;
}
}
Loading