moved the rest to trunk
git-svn-id: svn://anubis/jcad/trunk@31 c8684bfa-0c3a-0410-9efb-b8c82542f01e
This commit is contained in:
parent
583df8452a
commit
7e0ff79829
26
src/Makefile
Normal file
26
src/Makefile
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
CP := cp
|
||||
TARGET := jcad
|
||||
MODULES := main gui engine
|
||||
export GTKMM_VERSION := 2.4
|
||||
export GTKGLEXTMM_VERSION := 1.2
|
||||
CXXFLAGS := -O2
|
||||
LDFLAGS := `pkg-config --libs gtkmm-$(GTKMM_VERSION)` \
|
||||
`pkg-config --libs gtkglextmm-$(GTKGLEXTMM_VERSION)`
|
||||
ARCHIVES := $(foreach module,$(MODULES),$(module)/$(module).a)
|
||||
|
||||
all: $(MODULES) $(TARGET)
|
||||
|
||||
$(TARGET): $(ARCHIVES)
|
||||
$(CXX) -o $@ $(ARCHIVES) $(LDFLAGS)
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||
|
||||
.PHONY: $(MODULES)
|
||||
$(MODULES):
|
||||
$(MAKE) -C $@
|
||||
|
||||
clean:
|
||||
$(RM) -f *.o *.a *~ $(TARGET)
|
||||
for m in $(MODULES); do (cd $$m; $(MAKE) clean ); done
|
30
src/engine/Makefile
Normal file
30
src/engine/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
SRCS := Profile.cpp
|
||||
MODULES := Profile.o
|
||||
TARGET := engine.a
|
||||
GTKMM_VERSION := 2.4
|
||||
GTKGLEXTMM_VERSION := 1.2
|
||||
CPPFLAGS = -I..
|
||||
CXXFLAGS = -O2 $(CPPFLAGS) \
|
||||
`pkg-config --cflags gtkmm-$(GTKMM_VERSION)` \
|
||||
`pkg-config --cflags gtkglextmm-$(GTKGLEXTMM_VERSION)`
|
||||
DEPS := $(SRCS:.cpp=.d)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(MODULES)
|
||||
$(AR) rcv $@ $?
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) -f *.o *.d *~ $(TARGET)
|
||||
|
||||
%.d: %.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CXX) -MM $(CPPFLAGS) $< | \
|
||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
|
||||
|
||||
include $(DEPS)
|
0
src/engine/Profile.cpp
Normal file
0
src/engine/Profile.cpp
Normal file
12
src/engine/Profile.h
Normal file
12
src/engine/Profile.h
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
#ifndef PROFILE_H
|
||||
#define PROFILE_H
|
||||
|
||||
class Profile
|
||||
{
|
||||
public:
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
81
src/gui/Displayer.cpp
Normal file
81
src/gui/Displayer.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <gdkmm/cursor.h>
|
||||
#include "ProfileDisplayer.h"
|
||||
#include "PartDisplayer.h"
|
||||
#include "Displayer.h"
|
||||
|
||||
Displayer::Displayer(const Glib::RefPtr<const Gdk::GL::Config> & config)
|
||||
: Gtk::GL::DrawingArea(config)
|
||||
{
|
||||
set_gl_capability(config);
|
||||
set_events(Gdk::POINTER_MOTION_MASK
|
||||
| Gdk::BUTTON_PRESS_MASK
|
||||
| Gdk::BUTTON_RELEASE_MASK
|
||||
| Gdk::SCROLL_MASK);
|
||||
}
|
||||
|
||||
Displayer::~Displayer()
|
||||
{
|
||||
}
|
||||
|
||||
bool Displayer::draw()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Displayer::on_motion_notify_event(GdkEventMotion * event)
|
||||
{
|
||||
get_pointer(m_x, m_y);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Displayer::on_button_press_event(GdkEventButton * event)
|
||||
{
|
||||
}
|
||||
|
||||
bool Displayer::on_button_release_event(GdkEventButton * event)
|
||||
{
|
||||
}
|
||||
|
||||
bool Displayer::on_scroll_event(GdkEventScroll * event)
|
||||
{
|
||||
}
|
||||
|
||||
void Displayer::on_realize()
|
||||
{
|
||||
Gtk::GL::DrawingArea::on_realize();
|
||||
|
||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||
glwindow->get_window()->set_cursor(Gdk::Cursor(Gdk::CROSSHAIR));
|
||||
|
||||
if (!glwindow->gl_begin(get_gl_context()))
|
||||
return;
|
||||
|
||||
glViewport(0, 0, get_width(), get_height());
|
||||
|
||||
glwindow->gl_end();
|
||||
}
|
||||
|
||||
/*
|
||||
* called on widget resizes
|
||||
*/
|
||||
bool Displayer::on_configure_event(GdkEventConfigure * event)
|
||||
{
|
||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||
|
||||
if (!glwindow->gl_begin(get_gl_context()))
|
||||
return false;
|
||||
|
||||
glViewport(0, 0, get_width(), get_height());
|
||||
|
||||
glwindow->gl_end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Displayer::on_expose_event(GdkEventExpose * event)
|
||||
{
|
||||
return draw();
|
||||
}
|
29
src/gui/Displayer.h
Normal file
29
src/gui/Displayer.h
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
#ifndef GLWIDGET_H
|
||||
#define GLWIDGET_H
|
||||
|
||||
#include <gtkmm/gl/drawingarea.h>
|
||||
|
||||
class Displayer : public Gtk::GL::DrawingArea
|
||||
{
|
||||
public:
|
||||
Displayer(const Glib::RefPtr<const Gdk::GL::Config> & config);
|
||||
~Displayer();
|
||||
|
||||
protected:
|
||||
int m_x, m_y;
|
||||
|
||||
virtual bool draw();
|
||||
virtual void on_realize();
|
||||
virtual bool on_configure_event(GdkEventConfigure * event);
|
||||
virtual bool on_expose_event(GdkEventExpose * event);
|
||||
|
||||
/* signal handlers */
|
||||
virtual bool on_motion_notify_event(GdkEventMotion * event);
|
||||
virtual bool on_button_press_event(GdkEventButton * event);
|
||||
virtual bool on_button_release_event(GdkEventButton * event);
|
||||
virtual bool on_scroll_event(GdkEventScroll * event);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
35
src/gui/GUI.cpp
Normal file
35
src/gui/GUI.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
#include "GUI.h"
|
||||
#include "MainWindow.h"
|
||||
#include <gtkmm/main.h>
|
||||
#include <gtkglmm.h>
|
||||
#include <iostream>
|
||||
|
||||
int GUI::start(int argc, char * argv[])
|
||||
{
|
||||
Gtk::Main gtkmain(argc, argv);
|
||||
Gtk::GL::init(argc, argv);
|
||||
|
||||
Glib::RefPtr<Gdk::GL::Config> glconfig;
|
||||
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB |
|
||||
Gdk::GL::MODE_DEPTH |
|
||||
Gdk::GL::MODE_DOUBLE);
|
||||
|
||||
if (!glconfig)
|
||||
{
|
||||
std::cerr << "Could not create double-buffered GL visual"
|
||||
<< "Trying single-buffered visual." << std::endl;
|
||||
|
||||
glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB |
|
||||
Gdk::GL::MODE_DEPTH);
|
||||
|
||||
if (!glconfig)
|
||||
{
|
||||
std::cerr << "Cannot create OpenGL context!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
MainWindow mw(glconfig);
|
||||
Gtk::Main::run(mw);
|
||||
}
|
12
src/gui/GUI.h
Normal file
12
src/gui/GUI.h
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
#ifndef GUI_H
|
||||
#define GUI_H
|
||||
|
||||
class GUI
|
||||
{
|
||||
public:
|
||||
int start(int argc, char * argv[]);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
54
src/gui/MainWindow.cpp
Normal file
54
src/gui/MainWindow.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
#include "MainWindow.h"
|
||||
#include <gtkmm/action.h>
|
||||
#include <gtkmm/stock.h>
|
||||
#include <gtkmm/main.h>
|
||||
#include "PartDisplayer.h"
|
||||
|
||||
MainWindow::MainWindow(const Glib::RefPtr<Gdk::GL::Config> & config)
|
||||
: m_displayer(new PartDisplayer(config))
|
||||
{
|
||||
set_default_size(500, 500);
|
||||
|
||||
m_refActionGroup = Gtk::ActionGroup::create();
|
||||
m_refActionGroup->add(Gtk::Action::create("FileMenu", "_File"));
|
||||
m_refActionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW),
|
||||
sigc::mem_fun(*this, &MainWindow::on_action_new));
|
||||
m_refActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
|
||||
sigc::mem_fun(*this, &MainWindow::on_action_quit));
|
||||
Glib::RefPtr<Gtk::UIManager> m_refUIManager = Gtk::UIManager::create();
|
||||
m_refUIManager->insert_action_group(m_refActionGroup);
|
||||
add_accel_group(m_refUIManager->get_accel_group());
|
||||
Glib::ustring ui_info =
|
||||
"<ui>"
|
||||
" <menubar name='MenuBar'>"
|
||||
" <menu action='FileMenu'>"
|
||||
" <menuitem action='New' />"
|
||||
" <separator />"
|
||||
" <menuitem action='Quit' />"
|
||||
" </menu>"
|
||||
" </menubar>"
|
||||
" <toolbar name='ToolBar'>"
|
||||
" <toolitem action='New' />"
|
||||
" </toolbar>"
|
||||
"</ui>";
|
||||
m_refUIManager->add_ui_from_string(ui_info);
|
||||
|
||||
m_VBox.pack_start(*m_refUIManager->get_widget("/MenuBar"),
|
||||
Gtk::PACK_SHRINK);
|
||||
m_VBox.pack_start(*m_refUIManager->get_widget("/ToolBar"),
|
||||
Gtk::PACK_SHRINK);
|
||||
m_VBox.pack_start(*m_displayer);
|
||||
m_VBox.pack_start(m_statusBar, Gtk::PACK_SHRINK);
|
||||
add(m_VBox);
|
||||
show_all();
|
||||
}
|
||||
|
||||
void MainWindow::on_action_new()
|
||||
{
|
||||
}
|
||||
|
||||
void MainWindow::on_action_quit()
|
||||
{
|
||||
Gtk::Main::quit();
|
||||
}
|
29
src/gui/MainWindow.h
Normal file
29
src/gui/MainWindow.h
Normal file
@ -0,0 +1,29 @@
|
||||
|
||||
#ifndef MAINWINDOW_H
|
||||
#define MAINWINDOW_H
|
||||
|
||||
#include <gtkmm/window.h>
|
||||
#include <gtkmm/menubar.h>
|
||||
#include <gtkmm/box.h>
|
||||
#include <gtkmm/actiongroup.h>
|
||||
#include <gtkmm/uimanager.h>
|
||||
#include <gtkmm/statusbar.h>
|
||||
#include "Displayer.h"
|
||||
|
||||
class MainWindow : public Gtk::Window
|
||||
{
|
||||
public:
|
||||
MainWindow(const Glib::RefPtr<Gdk::GL::Config> & config);
|
||||
|
||||
protected:
|
||||
Glib::RefPtr<Gtk::UIManager> m_refUIManager;
|
||||
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
|
||||
Displayer * m_displayer;
|
||||
Gtk::VBox m_VBox;
|
||||
Gtk::Statusbar m_statusBar;
|
||||
|
||||
void on_action_new();
|
||||
void on_action_quit();
|
||||
};
|
||||
|
||||
#endif
|
30
src/gui/Makefile
Normal file
30
src/gui/Makefile
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
SRCS := MainWindow.cpp GUI.cpp Displayer.cpp ProfileDisplayer.cpp PartDisplayer.cpp
|
||||
MODULES := MainWindow.o GUI.o Displayer.o ProfileDisplayer.o PartDisplayer.o
|
||||
TARGET := gui.a
|
||||
GTKMM_VERSION := 2.4
|
||||
GTKGLEXTMM_VERSION := 1.2
|
||||
CPPFLAGS = -I..
|
||||
CXXFLAGS = -O2 $(CPPFLAGS) \
|
||||
`pkg-config --cflags gtkmm-$(GTKMM_VERSION)` \
|
||||
`pkg-config --cflags gtkglextmm-$(GTKGLEXTMM_VERSION)`
|
||||
DEPS := $(SRCS:.cpp=.d)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(MODULES)
|
||||
$(AR) rcv $@ $?
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) -f *.o *.d *~ $(TARGET)
|
||||
|
||||
%.d: %.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CXX) -MM $(CPPFLAGS) $< | \
|
||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
|
||||
|
||||
include $(DEPS)
|
73
src/gui/PartDisplayer.cpp
Normal file
73
src/gui/PartDisplayer.cpp
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
#include "PartDisplayer.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
PartDisplayer::PartDisplayer(const Glib::RefPtr<const Gdk::GL::Config> & config)
|
||||
: Displayer(config)
|
||||
{
|
||||
}
|
||||
|
||||
PartDisplayer::~PartDisplayer()
|
||||
{
|
||||
}
|
||||
|
||||
bool PartDisplayer::draw()
|
||||
{
|
||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||
if (!glwindow->gl_begin(get_gl_context()))
|
||||
return false;
|
||||
|
||||
glClearColor(0.1, 0.6, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-3, 3, -3, 3, 0.0001, 100000);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
gluLookAt(10, -10, 10,
|
||||
0, 0, 0,
|
||||
0, 0, 1);
|
||||
drawPlane();
|
||||
glPushMatrix();
|
||||
glRotatef(90, 1, 0, 0);
|
||||
drawPlane();
|
||||
glPopMatrix();
|
||||
glRotatef(90, 0, 0, 1);
|
||||
glRotatef(90, 1, 0, 0);
|
||||
drawPlane();
|
||||
|
||||
if (glwindow->is_double_buffered())
|
||||
glwindow->swap_buffers();
|
||||
else
|
||||
glFlush();
|
||||
return true;
|
||||
}
|
||||
|
||||
void PartDisplayer::drawPlane()
|
||||
{
|
||||
glColor4f(0.1, 0.8, 1.0, 0.3);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glEnable(GL_BLEND);
|
||||
glBegin(GL_QUADS);
|
||||
glVertex2f(1, 1);
|
||||
glVertex2f(-1, 1);
|
||||
glVertex2f(-1, -1);
|
||||
glVertex2f(1, -1);
|
||||
glEnd();
|
||||
glEnable(GL_LINE_SMOOTH);
|
||||
glColor4f(0.0, 0.15, 0.3, 1.0);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glVertex2f(1, 1);
|
||||
glVertex2f(-1, 1);
|
||||
glVertex2f(-1, -1);
|
||||
glVertex2f(1, -1);
|
||||
glEnd();
|
||||
glBegin(GL_LINE_STRIP);
|
||||
glVertex2f(0.6, -1.0);
|
||||
glVertex2f(0.6, -0.9);
|
||||
glVertex2f(1.0, -0.9);
|
||||
glEnd();
|
||||
glDisable(GL_LINE_SMOOTH);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
19
src/gui/PartDisplayer.h
Normal file
19
src/gui/PartDisplayer.h
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
#ifndef PARTDISPLAYER_H
|
||||
#define PARTDISPLAYER_H
|
||||
|
||||
#include "Displayer.h"
|
||||
|
||||
class PartDisplayer : public Displayer
|
||||
{
|
||||
public:
|
||||
PartDisplayer(const Glib::RefPtr<const Gdk::GL::Config> & config);
|
||||
~PartDisplayer();
|
||||
bool draw();
|
||||
|
||||
protected:
|
||||
void drawPlane();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
30
src/gui/ProfileDisplayer.cpp
Normal file
30
src/gui/ProfileDisplayer.cpp
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
#include "ProfileDisplayer.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
|
||||
ProfileDisplayer::ProfileDisplayer(const Glib::RefPtr<const Gdk::GL::Config> & config)
|
||||
: Displayer(config)
|
||||
{
|
||||
}
|
||||
|
||||
ProfileDisplayer::~ProfileDisplayer()
|
||||
{
|
||||
}
|
||||
|
||||
bool ProfileDisplayer::draw()
|
||||
{
|
||||
Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();
|
||||
if (!glwindow->gl_begin(get_gl_context()))
|
||||
return false;
|
||||
|
||||
glClearColor(0.1, 0.6, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (glwindow->is_double_buffered())
|
||||
glwindow->swap_buffers();
|
||||
else
|
||||
glFlush();
|
||||
return true;
|
||||
}
|
||||
|
18
src/gui/ProfileDisplayer.h
Normal file
18
src/gui/ProfileDisplayer.h
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
#ifndef PROFILEDISPLAYER_H
|
||||
#define PROFILEDISPLAYER_H
|
||||
|
||||
#include "Displayer.h"
|
||||
|
||||
class ProfileDisplayer : public Displayer
|
||||
{
|
||||
public:
|
||||
ProfileDisplayer(const Glib::RefPtr<const Gdk::GL::Config> & config);
|
||||
~ProfileDisplayer();
|
||||
bool draw();
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
#endif
|
||||
|
26
src/main/Makefile
Normal file
26
src/main/Makefile
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
SRCS := main.cpp
|
||||
MODULES := main.o
|
||||
TARGET := main.a
|
||||
DEPS := $(SRCS:.cpp=.d)
|
||||
CPPFLAGS := -I..
|
||||
CXXFLAGS := -O2 $(CPPFLAGS)
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(MODULES)
|
||||
$(AR) rcv $@ $?
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $(CXXFLAGS) $<
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) -f *.o *.d *~ $(TARGET)
|
||||
|
||||
%.d: %.cpp
|
||||
@set -e; rm -f $@; \
|
||||
$(CXX) -MM $(CPPFLAGS) $< | \
|
||||
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' > $@
|
||||
|
||||
include $(DEPS)
|
9
src/main/main.cpp
Normal file
9
src/main/main.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
#include "gui/GUI.h"
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
GUI theGUI;
|
||||
theGUI.start(argc, argv);
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user