Skip to content

Commit

Permalink
adding some options to Ribbon
Browse files Browse the repository at this point in the history
  • Loading branch information
danheeks committed Jun 15, 2020
1 parent 4711d1a commit 7825c9d
Show file tree
Hide file tree
Showing 11 changed files with 422 additions and 220 deletions.
15 changes: 14 additions & 1 deletion App.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def OnInit(self):
height = -1
x = -1
y = -1

self.LoadConfig()

self.frame = self.NewFrame(wx.Point(x, y), wx.Size(width, height))
self.frame.Show()
self.LoadConfig()
self.OnNewOrOpen(False)
cad.ClearHistory()
cad.SetLikeNewFile()
Expand All @@ -103,6 +104,17 @@ def LoadConfig(self):
config = HeeksConfig(self.settings_restored)
self.LoadRecentFiles(config)

# snapping
cad.SetDigitizeEnd(config.ReadBool("Endof", True))
cad.SetDigitizeInters(config.ReadBool("Inters", False))
cad.SetDigitizeCentre(config.ReadBool("Centre", True))
cad.SetDigitizeMidpoint(config.ReadBool("Midpoint", False))
cad.SetDigitizeSnapToGrid(config.ReadBool("Grid", True))

cad.SetRotateUpright(config.ReadBool("RotateUpright", False))
cad.SetGraphicsTextMode(cad.GraphicsTextMode(config.ReadInt("TextMode", int(cad.GraphicsTextMode.FullHelp))))


def GetDefaultDir(self):
default_directory = os.getcwd()

Expand Down Expand Up @@ -368,6 +380,7 @@ def InputLength(self, prompt, name, value):
static_label = wx.StaticText(dlg, label = prompt)
sizerMain.Add( static_label, 0, wx.ALL, wx.ALIGN_LEFT, control_border )
value_control = LengthCtrl(dlg)
value_control.SetValue(value)
dlg.AddLabelAndControl( sizerMain, name, value_control )
dlg.MakeOkAndCancel( wx.HORIZONTAL ).AddToSizer( sizerMain )
dlg.SetSizer( sizerMain )
Expand Down
4 changes: 1 addition & 3 deletions CAD/CadApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ CCadApp::CCadApp()
for (int i = 0; i<NUM_BACKGROUND_COLORS; i++)background_color[i] = HeeksColor(0, 0, 0);
background_color[0] = HeeksColor(255, 255, 255);
background_color[1] = HeeksColor(181, 230, 29);
m_background_mode = BackgroundModeOneColor;
m_background_mode = BackgroundModeTwoColors;
current_color = HeeksColor(0, 0, 0);
input_mode_object = NULL;
cur_mouse_pos = IPoint(0, 0);
Expand Down Expand Up @@ -125,8 +125,6 @@ CCadApp::CCadApp()
m_revolve_angle = 360.0;
m_fit_arcs_on_solid_outline = false;
m_stl_save_as_binary = true;
m_mouse_move_highlighting = true;
m_highlight_color = HeeksColor(128, 255, 0);

InitializeCreateFunctions();

Expand Down
2 changes: 0 additions & 2 deletions CAD/CadApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ class CCadApp : public CApp
bool m_allow_opengl_stippling;
SolidViewMode m_solid_view_mode;
bool m_stl_save_as_binary;
bool m_mouse_move_highlighting;
HeeksColor m_highlight_color;
bool m_stl_solid_random_colors;
bool m_svg_unite;

Expand Down
163 changes: 163 additions & 0 deletions CAD/PythonStuff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include "KeyCode.h"
#include "Gripper.h"
#include "GripperSelTransform.h"
#include "CoordinateSystem.h"

void OnExit()
{
Expand Down Expand Up @@ -1824,6 +1825,129 @@ void SetBackgroundColor(int index, const HeeksColor& color)
theApp->background_color[index] = color;
}

BackgroundMode GetBackgroundMode()
{
return theApp->m_background_mode;
}

void SetBackgroundMode(BackgroundMode mode)
{
theApp->m_background_mode = mode;
}

bool GetRotateUpright()
{
return theApp->m_rotate_mode == 0;
}

void SetRotateUpright(bool upright)
{
theApp->m_rotate_mode = upright ? 0:1;
}

GraphicsTextMode GetGraphicsTextMode()
{
return theApp->m_graphics_text_mode;
}

void SetGraphicsTextMode(GraphicsTextMode mode)
{
theApp->m_graphics_text_mode = mode;
}

bool GetReverseZooming()
{
return ViewZooming::m_reversed;
}

void SetReverseZooming(bool reversed)
{
ViewZooming::m_reversed = reversed;
}

bool GetShowDatum()
{
return theApp->m_show_datum_coords_system;
}

void SetShowDatum(bool show)
{
theApp->m_show_datum_coords_system = show;
}

bool GetDatumSolid()
{
return theApp->m_datum_coords_system_solid_arrows;
}

void SetDatumSolid(bool solid)
{
theApp->m_datum_coords_system_solid_arrows = solid;
}

double GetDatumSize()
{
return CoordinateSystem::size;
}

void SetDatumSize(double size)
{
CoordinateSystem::size = size;
}

bool GetDatumSizeIsPixelsNotMm()
{
return CoordinateSystem::size_is_pixels;
}

void SetDatumSizeIsPixelsNotMm(bool p)
{
CoordinateSystem::size_is_pixels = p;
}

bool GetShowRuler()
{
return theApp->m_show_ruler;
}

void SetShowRuler(bool show)
{
theApp->m_show_ruler = show;
}

int GetGridMode()
{
return theApp->grid_mode;
}

void SetGridMode(int mode)
{
theApp->grid_mode = mode;
}

bool GetPerspective()
{
return theApp->m_current_viewport->m_view_point.GetPerspective();
}

void SetPerspective(bool p)
{
theApp->m_current_viewport->m_view_point.SetPerspective(p);
}


HeeksColor GetCurrentColor()
{
return theApp->current_color;
}

void SetCurrentColor(const HeeksColor& color)
{
theApp->current_color = color;
}




BOOST_PYTHON_MODULE(cad) {
boost::python::class_<BaseObject, boost::noncopyable >("BaseObject", "derive your custom CAD objects from this")
Expand Down Expand Up @@ -2025,6 +2149,7 @@ void SetBackgroundColor(int index, const HeeksColor& color)
.def("Unproject", &CViewPoint::glUnproject)
.def("ShiftI", &CViewPoint::ShiftI)
.def("TurnI", &CViewPoint::TurnI)
.def("TurnVerticalI", &CViewPoint::TurnVerticalI)
.def("Rightwards", &CViewPoint::rightwards_vector)
.def("Forwards", &CViewPoint::forwards_vector)
.def_readwrite("lens_point", &CViewPoint::m_lens_point)
Expand Down Expand Up @@ -2309,6 +2434,20 @@ void SetBackgroundColor(int index, const HeeksColor& color)
.value("MaxSketchOrderTypes", MaxSketchOrderTypes)
;

boost::python::enum_<GraphicsTextMode>("GraphicsTextMode")
.value("None", GraphicsTextModeNone)
.value("InputTitle", GraphicsTextModeInputTitle)
.value("FullHelp", GraphicsTextModeWithHelp)
;

boost::python::enum_<BackgroundMode>("BackgroundMode")
.value("OneColor", BackgroundModeOneColor)
.value("TwoColors", BackgroundModeTwoColors)
.value("TwoColorsLeftToRight", BackgroundModeTwoColorsLeftToRight)
.value("FourColors", BackgroundModeFourColors)
.value("SkyDome", BackgroundModeSkyDome)
;

boost::python::class_<DigitizedPoint>("DigitizedPoint")
.def(boost::python::init<DigitizedPoint>())
.def_readwrite("point", &DigitizedPoint::m_point)
Expand Down Expand Up @@ -2464,6 +2603,30 @@ void SetBackgroundColor(int index, const HeeksColor& color)
boost::python::def("SetDigitizeGridSize", SetDigitizeGridSize);
boost::python::def("GetBackgroundColor", GetBackgroundColor);
boost::python::def("SetBackgroundColor", SetBackgroundColor);
boost::python::def("GetBackgroundMode", GetBackgroundMode);
boost::python::def("SetBackgroundMode", SetBackgroundMode);
boost::python::def("GetRotateUpright", GetRotateUpright);
boost::python::def("SetRotateUpright", SetRotateUpright);
boost::python::def("GetGraphicsTextMode", GetGraphicsTextMode);
boost::python::def("SetGraphicsTextMode", SetGraphicsTextMode);
boost::python::def("GetReverseZooming", GetReverseZooming);
boost::python::def("SetReverseZooming", SetReverseZooming);
boost::python::def("GetShowDatum", GetShowDatum);
boost::python::def("SetShowDatum", SetShowDatum);
boost::python::def("GetDatumSolid", GetDatumSolid);
boost::python::def("SetDatumSolid", SetDatumSolid);
boost::python::def("GetDatumSize", GetDatumSize);
boost::python::def("SetDatumSize", SetDatumSize);
boost::python::def("GetDatumSizeIsPixelsNotMm", GetDatumSizeIsPixelsNotMm);
boost::python::def("SetDatumSizeIsPixelsNotMm", SetDatumSizeIsPixelsNotMm);
boost::python::def("GetShowRuler", GetShowRuler);
boost::python::def("SetShowRuler", SetShowRuler);
boost::python::def("GetGridMode", GetGridMode);
boost::python::def("SetGridMode", SetGridMode);
boost::python::def("GetPerspective", GetPerspective);
boost::python::def("SetPerspective", SetPerspective);
boost::python::def("GetCurrentColor", GetCurrentColor);
boost::python::def("SetCurrentColor", SetCurrentColor);
boost::python::scope().attr("OBJECT_TYPE_UNKNOWN") = (int)UnknownType;
boost::python::scope().attr("OBJECT_TYPE_SKETCH") = (int)SketchType;
boost::python::scope().attr("OBJECT_TYPE_SKETCH_LINE") = (int)LineType;
Expand Down
2 changes: 1 addition & 1 deletion CAD/ViewPoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void CViewPoint::Turn(double ang_x, double ang_y){
m_vertical = m_vertical - uu * (1-cos(ang_y));
}

void CViewPoint::TurnVertical(IPoint point_diff){
void CViewPoint::TurnVerticalI(IPoint point_diff){
if(point_diff.x > 100)point_diff.x = 100;
else if(point_diff.x < -100)point_diff.x = -100;
if(point_diff.y > 100)point_diff.y = 100;
Expand Down
2 changes: 1 addition & 1 deletion CAD/ViewPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CViewPoint{
void Turn(double ang_x, double ang_y);
void TurnI(IPoint point_diff);
void TurnVertical(double ang_x, double ang_y);
void TurnVertical(IPoint point_diff);
void TurnVerticalI(IPoint point_diff);
void Shift(const Point3d &tv);
void ShiftI(const IPoint &point_diff);
void Scale(double multiplier, bool use_initial_pixel_scale = false);
Expand Down
2 changes: 1 addition & 1 deletion CAD/ViewRotating.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void ViewRotating::OnMouse( MouseEvent& event )
}
else
{
theApp->m_current_viewport->m_view_point.TurnVertical(dm);
theApp->m_current_viewport->m_view_point.TurnVerticalI(dm);
}
}
else if(event.m_middleDown)
Expand Down
Loading

0 comments on commit 7825c9d

Please sign in to comment.