|
From: <ob...@us...> - 2007-10-07 13:46:01
|
Revision: 340
http://iaeditor.svn.sourceforge.net/iaeditor/?rev=340&view=rev
Author: obi666
Date: 2007-10-07 06:46:03 -0700 (Sun, 07 Oct 2007)
Log Message:
-----------
Applied r335-339 from trunk.
Modified Paths:
--------------
branches/release/V0.2/src/apps/editor/gui/gui_common.h
branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.cpp
branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.h
branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.cpp
branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.h
branches/release/V0.2/src/apps/editor/gui/widgets/iaTrackCtrl.cpp
branches/release/V0.2/src/apps/editor/iaCSApplication.cpp
branches/release/V0.2/src/plugins/dynamics/ode_dynamics/body.cpp
Modified: branches/release/V0.2/src/apps/editor/gui/gui_common.h
===================================================================
--- branches/release/V0.2/src/apps/editor/gui/gui_common.h 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/apps/editor/gui/gui_common.h 2007-10-07 13:46:03 UTC (rev 340)
@@ -22,10 +22,6 @@
#include <wx/dnd.h>
#include "editor.h"
-#define TIMELINE_UNIT_POS 8 //position of first unit on timeline
-#define TIMELINE_UNIT_SCALE 100.0
-#define PROGRESS_2_UNITS(progress) (progress / TIMELINE_UNIT_SCALE) * TIMELINE_UNIT_POS
-#define UNITS_2_PROGRESS(units) units * TIMELINE_UNIT_SCALE / TIMELINE_UNIT_POS
#define BUTTON_SIZE 32
#define TIMELINE_OFFSET 7*BUTTON_SIZE
Modified: branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.cpp
===================================================================
--- branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.cpp 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.cpp 2007-10-07 13:46:03 UTC (rev 340)
@@ -38,6 +38,8 @@
IMPLEMENT_DYNAMIC_CLASS(iaSimulationPanel, wxPanel)
+iaSimulationPanel *iaSimulationPanel::m_pInstance = 0;
+
iaSimulationPanel::iaSimulationPanel (iEditorCentralInfo *central_info, iaMainFrame* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style)
: wxPanel (parent, id, pos, size, style)
@@ -47,6 +49,7 @@
play_forward_pressed = false;
play_backward_pressed = false;
simulate_pressed = false;
+ m_pInstance = this;
SetMinSize (wxSize (BUTTON_SIZE, BUTTON_SIZE));
}
void iaSimulationPanel::OnSize (wxSizeEvent& event)
Modified: branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.h
===================================================================
--- branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.h 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/apps/editor/gui/widgets/iaSimulationPanel.h 2007-10-07 13:46:03 UTC (rev 340)
@@ -52,6 +52,7 @@
};
void CreateControls ();
+ iaTimeLineCtrl *GetTimeLineCtrl () {return time_line_ctrl;}
//events
void OnLastFrameClick (wxCommandEvent& event);
@@ -63,6 +64,9 @@
void OnStepBackwardClick (wxCommandEvent& event);
void OnSize (wxSizeEvent& event);
+ /// singleton instance access
+ static iaSimulationPanel* instance () {return m_pInstance;}
+
DECLARE_DYNAMIC_CLASS(iaSimulationPanel)
private:
@@ -71,6 +75,7 @@
iaSimulationTracksCtrl *tracks_ctrl;
iEditorCentralInfo *central_info;
iaMainFrame *parent;
+ static iaSimulationPanel *m_pInstance;
//Buttons
wxBitmapButton *item_bitmap_button_step_forward;
Modified: branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.cpp
===================================================================
--- branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.cpp 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.cpp 2007-10-07 13:46:03 UTC (rev 340)
@@ -65,22 +65,23 @@
wxWindow(parent, id, pos, size, style, name)
{
iaTimeLineCtrl::central_info = central_info;
- scale = 10;
+ timeline_font = new wxFont (10, wxMODERN, wxNORMAL, wxBOLD);
central_info->Get3dView ()->AddProgressListener (this);
central_info->GetObjectsInfo ()->AddListener (this);
wxString icons_path = wxString (central_info->GetIconsPath ().c_str (), wxConvUTF8);
- timeline_bitmap = wxBitmap (icons_path + _T("Icon_timeline.png"),
- wxBITMAP_TYPE_PNG);
timeline_ptr_bitmap = wxBitmap (icons_path + _T("Icon_timeline_pointer.png"), wxBITMAP_TYPE_PNG);
timeline_anim_ptr_pos = 0;
timeline_sim_ptr_pos = 0;
+ unit_size = 8;
+ unit_value = 100;
}
iaTimeLineCtrl::~iaTimeLineCtrl()
{
+ delete timeline_font;
}
void iaTimeLineCtrl::ObjectAdded (iEditorObject *obj)
{
@@ -96,19 +97,32 @@
PrepareDC (pdc);
DrawToDC (&pdc);
}
-int iaTimeLineCtrl::ScaleProgress (csTicks progress)
-{
- return (progress / TIMELINE_UNIT_SCALE) * TIMELINE_UNIT_POS;
-}
void iaTimeLineCtrl::SimulationStarted ()
{
timeline_sim_ptr_pos = 0;
Refresh ();
}
+void iaTimeLineCtrl::Rescale ()
+{
+ //first try to shrink space between units
+ unit_size -= 1;
+
+ //if we can't shrink the space more, we will rescale labels itself
+ if (unit_size < 5)
+ {
+ unit_size = 8;
+ unit_value *= 2;
+ }
+}
void iaTimeLineCtrl::SimulatorProgressChanged (csTicks progress)
{
int prev_pos = timeline_sim_ptr_pos;
- timeline_sim_ptr_pos = ScaleProgress (progress);
+ timeline_sim_ptr_pos = GetUnitPos (GetUnit (progress));
+ if (timeline_sim_ptr_pos > GetSize ().x - 20)
+ {
+ Rescale ();
+ timeline_sim_ptr_pos = GetUnitPos (GetUnit (progress));
+ }
if (prev_pos == timeline_sim_ptr_pos)
return;
@@ -124,11 +138,18 @@
memdc.SetBackground (wxBrush(GetBackgroundColour(), wxSOLID));
memdc.Clear();
- size_t b_cnt = GetSize ().x / timeline_bitmap.GetWidth () + 1;
- for (size_t i = 0; i < b_cnt; i++)
+ memdc.SetPen (*wxBLACK_PEN);
+ memdc.SetBrush (*wxBLACK_BRUSH);
+ int b_cnt = GetSize ().x / unit_size / 10 + 1;
+ for (int i = 0; i < b_cnt; i++)
{
- memdc.DrawBitmap (timeline_bitmap, TIMELINE_START + i * timeline_bitmap.GetWidth (),
- TIMELINE_YPOS, false);
+ int curr_scale = i * 10;
+ int curr_scale_pos = GetUnitPos (curr_scale);
+ memdc.DrawRectangle (curr_scale_pos, GetSize ().y - 18, 2, 18);
+ for (size_t i = 0; i < 10; i++)
+ {
+ memdc.DrawRectangle (GetUnitPos (curr_scale++), GetSize ().y - 5, 2, 5);
+ }
}
memdc.DrawBitmap (timeline_ptr_bitmap, timeline_anim_ptr_pos,
GetSize ().y - timeline_ptr_bitmap.GetHeight (), true);
@@ -136,9 +157,27 @@
memdc.SetBrush (wxBrush(wxColor (223, 211, 195, 125), wxCROSSDIAG_HATCH));
memdc.DrawRectangle (0,0, timeline_sim_ptr_pos, GetSize ().y);
+ memdc.SetFont(*timeline_font);
+ memdc.SetTextForeground (wxColor (122, 110, 90));
+ for (int i = 0; i < b_cnt; i++)
+ {
+ wxString label;
+ label.sprintf ("%d", GetUnitValue (i * 10));
+ memdc.DrawText (label, GetUnitPos (i * 10) - timeline_font->GetPointSize () * label.Length () / 2 -
+ timeline_font->GetPointSize () / 4, 0);
+ }
+
memdc.SelectObject (wxNullBitmap);
dc->DrawBitmap (dummy_bitmap, 0, 0);
}
+int iaTimeLineCtrl::GetPosValue (int pos)
+{
+ return (pos - TIMELINE_START) / unit_size * unit_value;
+}
+int iaTimeLineCtrl::GetUnitPos (int i)
+{
+ return TIMELINE_START + i * unit_size;
+}
void iaTimeLineCtrl::AnimationLockChanged (bool lock)
{
if (lock)
@@ -151,7 +190,7 @@
void iaTimeLineCtrl::AnimationProgressChanged (csTicks progress)
{
int prev_pos = timeline_anim_ptr_pos;
- timeline_anim_ptr_pos = ScaleProgress (progress);
+ timeline_anim_ptr_pos = GetUnitPos (GetUnit (progress));
if (prev_pos == timeline_anim_ptr_pos)
return;
wxClientDC cdc (this);
Modified: branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.h
===================================================================
--- branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.h 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/apps/editor/gui/widgets/iaTimeLineCtrl.h 2007-10-07 13:46:03 UTC (rev 340)
@@ -22,6 +22,7 @@
struct iEditorCentralInfo;
#include "ia-tool/iaBaseObjectListener.h"
+#include "iPcDynamicsSystem.h"
// When drag_count reaches 0, process drag message
@@ -60,17 +61,25 @@
// Events
void OnPaint (wxPaintEvent& event);
+ int GetProgressSize (int progress) {return GetUnit (progress) * unit_size;}
+ int GetPosValue (int pos);
+
protected:
- int ScaleProgress (csTicks progress);
+ int GetUnitPos (int i);
+ float GetUnit (int value) {return value / (float)unit_value;}
+ int GetUnitValue (int i) {return i * unit_value;}
+
+ /// Rescale timeline
+ void Rescale ();
iEditorCentralInfo *central_info;
- wxBitmap timeline_bitmap;
+ wxFont *timeline_font;
wxBitmap timeline_ptr_bitmap;
int timeline_anim_ptr_pos;
int timeline_sim_ptr_pos;
- //value of first 10 units on timeline
- int scale;
+ int unit_value; //value of one unit on timeline
+ int unit_size; //size of one unit on timeline
DECLARE_EVENT_TABLE()
};
Modified: branches/release/V0.2/src/apps/editor/gui/widgets/iaTrackCtrl.cpp
===================================================================
--- branches/release/V0.2/src/apps/editor/gui/widgets/iaTrackCtrl.cpp 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/apps/editor/gui/widgets/iaTrackCtrl.cpp 2007-10-07 13:46:03 UTC (rev 340)
@@ -43,6 +43,8 @@
#include <wx/dcgraph.h>
#include "../gui_common.h"
#include "iaTrackCtrl.h"
+#include "iaTimeLineCtrl.h"
+#include "iaSimulationPanel.h"
#include "iPcCharacter.h"
#include "iPcAnimation.h"
@@ -74,7 +76,6 @@
{
iaEventCtrl::central_info = central_info;
iaEventCtrl::track_event = track_event;
- SetSize(PROGRESS_2_UNITS(track_event->GetDuration ()), size.y);
}
iaEventCtrl::~iaEventCtrl()
@@ -83,8 +84,9 @@
void iaEventCtrl::OnSize (wxSizeEvent& event)
{
central_info->Get3dView ()->Lock (true);
- csTicks duration = UNITS_2_PROGRESS (event.GetSize ().x);
- csTicks start = UNITS_2_PROGRESS (GetPosition ().x);
+ iaTimeLineCtrl *timelineCtrl = iaSimulationPanel::instance ()->GetTimeLineCtrl ();
+ csTicks duration = timelineCtrl->GetPosValue (event.GetSize ().x);
+ csTicks start = timelineCtrl->GetPosValue (GetPosition ().x);
track_event->SetDuration (duration);
track_event->SetStart (start);
@@ -196,12 +198,14 @@
void iaTrackCtrl::PutObject (iEditorObject *obj, wxCoord x, wxCoord y)
{
central_info->Get3dView ()->Lock (true);
+ iaTimeLineCtrl *timeLineCtrl = iaSimulationPanel::instance ()->GetTimeLineCtrl ();
- csTicks start = UNITS_2_PROGRESS (x);
+ csTicks start = timeLineCtrl->GetPosValue (x);
iTrackEvent *event = track->PutOnTrack (obj);
event->SetStart (start);
iaEventCtrl *event_ctrl = new iaEventCtrl (central_info, event, this, -1,
- wxPoint (x, 0), wxSize (0, GetSize ().y));
+ wxPoint (x, 0), wxSize (timeLineCtrl->GetProgressSize (event->GetDuration ()), GetSize ().y));
+
switch (obj->GetObjectType ())
{
case IA_OBJECT_TYPE_ANIMATION:
@@ -274,7 +278,7 @@
void iaCharacterTracksCtrl::Expand ()
{
collapsed = false;
- SetSize (GetSize ().x, (1 + tracks.GetSize ()) * (size_t)track_size);
+ SetSize (GetSize ().x, (int) ((1 + tracks.GetSize ()) * track_size));
for (size_t i = 0; i < tracks.GetSize (); i++)
{
tracks[i]->Show (true);
@@ -283,10 +287,10 @@
void iaCharacterTracksCtrl::AddTrack (const wxColor& color, iTrack *track)
{
iaTrackCtrl *track_ctrl = new iaTrackCtrl (central_info, track,
- this, -1, wxPoint (0, (tracks.GetSize () + 1) * track_size), wxSize (GetSize ().x, track_size));
+ this, -1, wxPoint (0, (int) ((tracks.GetSize () + 1) * track_size)), wxSize (GetSize ().x, track_size));
track_ctrl->SetBackgroundColour (color);
tracks.Push (track_ctrl);
- SetSize (GetSize ().x, (tracks.GetSize () + 1) * track_size);
+ SetSize (GetSize ().x, (int) ((tracks.GetSize () + 1) * track_size));
}
bool iaCharacterTracksCtrl::CreateControls (int track_size)
{
Modified: branches/release/V0.2/src/apps/editor/iaCSApplication.cpp
===================================================================
--- branches/release/V0.2/src/apps/editor/iaCSApplication.cpp 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/apps/editor/iaCSApplication.cpp 2007-10-07 13:46:03 UTC (rev 340)
@@ -669,7 +669,6 @@
}
bool iaCSApplication::Open ()
{
- printf ("iaCSApplication::Open ()\n");
//Setup the wx windows 3d View
wxwin = scfQueryInterface<iWxWindow>(g2d);
if (!wxwin)
Modified: branches/release/V0.2/src/plugins/dynamics/ode_dynamics/body.cpp
===================================================================
--- branches/release/V0.2/src/plugins/dynamics/ode_dynamics/body.cpp 2007-10-07 13:28:09 UTC (rev 339)
+++ branches/release/V0.2/src/plugins/dynamics/ode_dynamics/body.cpp 2007-10-07 13:46:03 UTC (rev 340)
@@ -288,5 +288,5 @@
bool celPc_iaRigidBody::PerformAction(csStringID actionId, iCelParameterBlock* params)
{
return false;
-}
-
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|