Permalink
Browse files

initial add

  • Loading branch information...
0 parents commit 1563bf14649c3252b1db066212e0eca55b0d41bc danheeks committed Mar 10, 2009
@@ -0,0 +1,13 @@
+// ArtConfig.h
+// Copyright (c) 2009, Dan Heeks
+// This program is released under the BSD license. See the file COPYING for details.
+#include <wx/config.h>
+#include <wx/confbase.h>
+#include <wx/fileconf.h>
+
+class ArtConfig: public wxConfig
+{
+public:
+ ArtConfig():wxConfig(_T("HeeksArt")){}
+ ~ArtConfig(){}
+};
@@ -0,0 +1,175 @@
+// HeeksArt.cpp
+// Copyright (c) 2009, Dan Heeks
+// This program is released under the BSD license. See the file COPYING for details.
+//
+
+#include "stdafx.h"
+
+#include <wx/stdpaths.h>
+#include <wx/dynlib.h>
+#include <wx/aui/aui.h>
+#include "interface/PropertyString.h"
+#include "interface/PropertyList.h"
+#include "interface/PropertyInt.h"
+#include "interface/Observer.h"
+#include "interface/ToolImage.h"
+#include "ArtConfig.h"
+#include "Mesh.h"
+
+CHeeksCADInterface* heeksCAD = NULL;
+
+CHeeksArtApp theApp;
+
+CHeeksArtApp::CHeeksArtApp(){
+ m_meshBar = NULL;
+ m_num_facets_on_edge = 8;
+}
+
+CHeeksArtApp::~CHeeksArtApp(){
+}
+
+void CHeeksArtApp::OnInitDLL()
+{
+}
+
+void CHeeksArtApp::OnDestroyDLL()
+{
+#if !defined WXUSINGDLL
+ wxUninitialize();
+#endif
+
+ heeksCAD = NULL;
+}
+
+void OnMeshBar( wxCommandEvent& event )
+{
+ wxAuiManager* aui_manager = heeksCAD->GetAuiManager();
+ wxAuiPaneInfo& pane_info = aui_manager->GetPane(theApp.m_meshBar);
+ if(pane_info.IsOk()){
+ pane_info.Show(event.IsChecked());
+ aui_manager->Update();
+ }
+}
+
+void OnUpdateMeshBar( wxUpdateUIEvent& event )
+{
+ wxAuiManager* aui_manager = heeksCAD->GetAuiManager();
+ event.Check(aui_manager->GetPane(theApp.m_meshBar).IsShown());
+}
+
+#define MESH_CENTRE_VAL 9
+#define MESH_CONTROL_VAL 6
+
+static void OnSimpleMesh(wxCommandEvent& event)
+{
+ CMesh* mesh = new CMesh;
+ mesh->AddTriangle(Point(0, 0, -10), Point(0, 10, 0), Point(10, 0, 0), Point(0, MESH_CONTROL_VAL, -10), Point(0, 10, -MESH_CONTROL_VAL), Point(MESH_CONTROL_VAL, 10, 0), Point(10, MESH_CONTROL_VAL, 0), Point(10, 0, -MESH_CONTROL_VAL), Point(MESH_CONTROL_VAL, 0, -10), Point(MESH_CENTRE_VAL, MESH_CENTRE_VAL, -MESH_CENTRE_VAL));
+ mesh->AddTriangle(Point(0, 0, -10), Point(-10, 0, 0), Point(0, 10, 0), Point(-MESH_CONTROL_VAL, 0, -10), Point(-10, 0, -MESH_CONTROL_VAL), Point(-10, MESH_CONTROL_VAL, 0), Point(-MESH_CONTROL_VAL, 10, 0), Point(0, 10, -MESH_CONTROL_VAL), Point(0, MESH_CONTROL_VAL, -10), Point(-MESH_CENTRE_VAL, MESH_CENTRE_VAL, -MESH_CENTRE_VAL));
+ mesh->AddTriangle(Point(0, 0, -10), Point(0, -10, 0), Point(-10, 0, 0), Point(0, -MESH_CONTROL_VAL, -10), Point(0, -10, -MESH_CONTROL_VAL), Point(-MESH_CONTROL_VAL, -10, 0), Point(-10, -MESH_CONTROL_VAL, 0), Point(-10, 0, -MESH_CONTROL_VAL), Point(-MESH_CONTROL_VAL, 0, -10), Point(-MESH_CENTRE_VAL, -MESH_CENTRE_VAL, -MESH_CENTRE_VAL));
+ mesh->AddTriangle(Point(0, 0, -10), Point(10, 0, 0), Point(0, -10, 0), Point(MESH_CONTROL_VAL, 0, -10), Point(10, 0, -MESH_CONTROL_VAL), Point(10, -MESH_CONTROL_VAL, 0), Point(MESH_CONTROL_VAL, -10, 0), Point(0, -10, -MESH_CONTROL_VAL), Point(0, -MESH_CONTROL_VAL, -10), Point(MESH_CENTRE_VAL, -MESH_CENTRE_VAL, -MESH_CENTRE_VAL));
+ mesh->AddTriangle(Point(0, 0, 10), Point(10, 0, 0), Point(0, 10, 0), Point(MESH_CONTROL_VAL, 0, 10), Point(10, 0, MESH_CONTROL_VAL), Point(10, MESH_CONTROL_VAL, 0), Point(MESH_CONTROL_VAL, 10, 0), Point(0, 10, MESH_CONTROL_VAL), Point(0, MESH_CONTROL_VAL, 10), Point(MESH_CENTRE_VAL, MESH_CENTRE_VAL, MESH_CENTRE_VAL));
+ mesh->AddTriangle(Point(0, 0, 10), Point(0, 10, 0), Point(-10, 0, 0), Point(0, MESH_CONTROL_VAL, 10), Point(0, 10, MESH_CONTROL_VAL), Point(-MESH_CONTROL_VAL, 10, 0), Point(-10, MESH_CONTROL_VAL, 0), Point(-10, 0, MESH_CONTROL_VAL), Point(-MESH_CONTROL_VAL, 0, 10), Point(-MESH_CENTRE_VAL, MESH_CENTRE_VAL, MESH_CENTRE_VAL));
+ mesh->AddTriangle(Point(0, 0, 10), Point(-10, 0, 0), Point(0, -10, 0), Point(-MESH_CONTROL_VAL, 0, 10), Point(-10, 0, MESH_CONTROL_VAL), Point(-10, -MESH_CONTROL_VAL, 0), Point(-MESH_CONTROL_VAL, -10, 0), Point(0, -10, MESH_CONTROL_VAL), Point(0, -MESH_CONTROL_VAL, 10), Point(-MESH_CENTRE_VAL, -MESH_CENTRE_VAL, MESH_CENTRE_VAL));
+ mesh->AddTriangle(Point(0, 0, 10), Point(0, -10, 0), Point(10, 0, 0), Point(0, -MESH_CONTROL_VAL, 10), Point(0, -10, MESH_CONTROL_VAL), Point(MESH_CONTROL_VAL, 0, 0), Point(10, -MESH_CONTROL_VAL, 0), Point(10, 0, MESH_CONTROL_VAL), Point(MESH_CONTROL_VAL, 0, 10), Point(MESH_CENTRE_VAL, -MESH_CENTRE_VAL, MESH_CENTRE_VAL));
+ mesh->SetAllVertexNormals();
+ heeksCAD->AddUndoably(mesh, NULL);
+}
+
+static void AddToolBars()
+{
+ wxFrame* frame = heeksCAD->GetMainFrame();
+ wxAuiManager* aui_manager = heeksCAD->GetAuiManager();
+ if(theApp.m_meshBar)delete theApp.m_meshBar;
+ theApp.m_meshBar = new wxToolBar(frame, -1, wxDefaultPosition, wxDefaultSize, wxTB_NODIVIDER | wxTB_FLAT);
+ theApp.m_meshBar->SetToolBitmapSize(wxSize(ToolImage::GetBitmapSize(), ToolImage::GetBitmapSize()));
+ heeksCAD->AddToolBarButton((wxToolBar*)(theApp.m_meshBar), _("Simple Mesh"), ToolImage(_T("mesh")), _T("Add a simple mesh"), OnSimpleMesh);
+ theApp.m_meshBar->Realize();
+ aui_manager->AddPane(theApp.m_meshBar, wxAuiPaneInfo().Name(_T("MeshBar")).Caption(_T("Mesh tools")).ToolbarPane().Top());
+ heeksCAD->RegisterToolBar(theApp.m_meshBar);
+}
+
+void CHeeksArtApp::OnStartUp(CHeeksCADInterface* h, const wxString& dll_path)
+{
+ m_dll_path = dll_path;
+ heeksCAD = h;
+#if !defined WXUSINGDLL
+ wxInitialize();
+#endif
+
+ ArtConfig config;
+
+ // About box, stuff
+ heeksCAD->AddToAboutBox(wxString(_T("\n\n")) + _("HeeksArt is a free random add-on to HeeksCAD")
+ + _T("\n") + _(" http://code.google.com/p/heeksart/")
+ + _T("\n") + _("Written by Dan Heeks")
+ );
+
+ // add menus and toolbars
+ wxFrame* frame = heeksCAD->GetMainFrame();
+ wxAuiManager* aui_manager = heeksCAD->GetAuiManager();
+
+ // tool bars
+ heeksCAD->RegisterAddToolBars(AddToolBars);
+ AddToolBars();
+
+ // Mesh menu
+ wxMenu *menuMesh = new wxMenu;
+ heeksCAD->AddMenuItem(menuMesh, _("Add a simple mesh"), OnSimpleMesh);
+ frame->GetMenuBar()->Append(menuMesh, _("Mesh"));
+
+ // add tick boxes for them all on the Window menu
+ wxMenu* window_menu = heeksCAD->GetWindowMenu();
+ heeksCAD->AddMenuCheckItem(window_menu, _T("Mesh"), OnMeshBar, OnUpdateMeshBar);
+ heeksCAD->RegisterHideableWindow(m_meshBar);
+
+ // add object reading functions
+ heeksCAD->RegisterReadXMLfunction("mesh", CMesh::ReadFromXMLElement);
+}
+
+void CHeeksArtApp::OnNewOrOpen(bool open)
+{
+}
+
+static void on_set_num_facets(int value, HeeksObj* object)
+{
+ theApp.m_num_facets_on_edge = value;
+}
+
+void CHeeksArtApp::GetOptions(std::list<Property *> *list){
+ PropertyList* mesh_options = new PropertyList(_("mesh options"));
+
+ mesh_options->m_list.push_back ( new PropertyInt ( _("number of splits"), m_num_facets_on_edge, NULL, on_set_num_facets ) );
+
+ list->push_back(mesh_options);
+}
+
+void CHeeksArtApp::OnFrameDelete()
+{
+}
+
+const wxString& CHeeksArtApp::GetDllFolder()
+{
+ return m_dll_path;
+}
+
+class MyApp : public wxApp
+{
+
+ public:
+
+ virtual bool OnInit(void);
+
+ };
+
+ bool MyApp::OnInit(void)
+
+ {
+
+ return true;
+
+ }
+
+ DECLARE_APP(MyApp)
+
+ IMPLEMENT_APP(MyApp)
+
@@ -0,0 +1,32 @@
+// HeeksArt.h
+// Copyright (c) 2009, Dan Heeks
+// This program is released under the BSD license. See the file COPYING for details.
+
+// defines global variables and functions
+
+#include "interface/HeeksCADInterface.h"
+
+extern CHeeksCADInterface* heeksCAD;
+
+class Property;
+
+class CHeeksArtApp{
+public:
+ wxToolBarBase* m_meshBar;
+ int m_num_facets_on_edge;
+ wxString m_dll_path;
+
+ CHeeksArtApp();
+ ~CHeeksArtApp();
+
+ void OnStartUp(CHeeksCADInterface* h, const wxString& dll_path);
+ void OnNewOrOpen(bool open);
+ void OnInitDLL();
+ void OnDestroyDLL();
+ void GetOptions(std::list<Property *> *list);
+ void OnFrameDelete();
+ const wxString& GetDllFolder();
+};
+
+extern CHeeksArtApp theApp;
+
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HeeksCNC", "HeeksArt.vcproj", "{E0CBC0FB-A641-466A-91E8-EFF5EEFB2AAE}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {E0CBC0FB-A641-466A-91E8-EFF5EEFB2AAE}.Debug|Win32.ActiveCfg = Debug|Win32
+ {E0CBC0FB-A641-466A-91E8-EFF5EEFB2AAE}.Debug|Win32.Build.0 = Debug|Win32
+ {E0CBC0FB-A641-466A-91E8-EFF5EEFB2AAE}.Release|Win32.ActiveCfg = Release|Win32
+ {E0CBC0FB-A641-466A-91E8-EFF5EEFB2AAE}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
Oops, something went wrong.

0 comments on commit 1563bf1

Please sign in to comment.