00001 #include "autos.h"
00002 #include "bcsignals.h"
00003 #include "cplayback.h"
00004 #include "ctimebar.h"
00005 #include "ctracking.h"
00006 #include "cwindow.h"
00007 #include "cwindowgui.h"
00008 #include "cwindowtool.h"
00009 #include "bchash.h"
00010 #include "edl.h"
00011 #include "edlsession.h"
00012 #include "localsession.h"
00013 #include "mainmenu.h"
00014 #include "mainsession.h"
00015 #include "mwindowgui.h"
00016 #include "playbackengine.h"
00017 #include "playtransport.h"
00018 #include "preferences.h"
00019 #include "theme.h"
00020 #include "track.h"
00021 #include "trackcanvas.h"
00022 #include "tracks.h"
00023 #include "transportque.h"
00024 #include "mwindow.h"
00025
00026
00027
00028 #include <unistd.h>
00029
00030
00031
00032 CWindow::CWindow(MWindow *mwindow)
00033 : Thread()
00034 {
00035 this->mwindow = mwindow;
00036 }
00037
00038
00039 CWindow::~CWindow()
00040 {
00041 delete playback_engine;
00042 delete playback_cursor;
00043 }
00044
00045 int CWindow::create_objects()
00046 {
00047 destination = mwindow->defaults->get("CWINDOW_DESTINATION", 0);
00048
00049 gui = new CWindowGUI(mwindow, this);
00050 gui->create_objects();
00051
00052 playback_engine = new CPlayback(mwindow, this, gui->canvas);
00053
00054
00055 playback_engine->create_objects();
00056 gui->transport->set_engine(playback_engine);
00057 playback_cursor = new CTracking(mwindow, this);
00058 playback_cursor->create_objects();
00059 return 0;
00060 }
00061
00062
00063 void CWindow::show_window()
00064 {
00065 gui->lock_window("CWindow::show_cwindow");
00066 gui->show_window();
00067 gui->raise_window();
00068 gui->flush();
00069 gui->unlock_window();
00070
00071 gui->tool_panel->show_tool();
00072 }
00073
00074 void CWindow::hide_window()
00075 {
00076 gui->hide_window();
00077 gui->mwindow->session->show_cwindow = 0;
00078
00079 gui->unlock_window();
00080
00081 gui->tool_panel->hide_tool();
00082
00083 mwindow->gui->lock_window("CWindowGUI::close_event");
00084 mwindow->gui->mainmenu->show_cwindow->set_checked(0);
00085 mwindow->gui->unlock_window();
00086 mwindow->save_defaults();
00087
00088 gui->lock_window("CWindow::hide_window");
00089 }
00090
00091
00092 Track* CWindow::calculate_affected_track()
00093 {
00094 Track* affected_track = 0;
00095 for(Track *track = mwindow->edl->tracks->first;
00096 track;
00097 track = track->next)
00098 {
00099 if(track->data_type == TRACK_VIDEO &&
00100 track->record)
00101 {
00102 affected_track = track;
00103 break;
00104 }
00105 }
00106 return affected_track;
00107 }
00108
00109 Auto* CWindow::calculate_affected_auto(Autos *autos,
00110 int create,
00111 int *created,
00112 int redraw)
00113 {
00114 Auto* affected_auto = 0;
00115 if(created) *created = 0;
00116
00117 if(create)
00118 {
00119 int total = autos->total();
00120 affected_auto = autos->get_auto_for_editing();
00121
00122
00123 if(total != autos->total())
00124 {
00125 if(created) *created = 1;
00126 if(redraw)
00127 {
00128 mwindow->gui->lock_window("CWindow::calculate_affected_auto");
00129 mwindow->gui->canvas->draw_overlays();
00130 mwindow->gui->canvas->flash();
00131 mwindow->gui->unlock_window();
00132 }
00133 }
00134 }
00135 else
00136 {
00137 affected_auto = autos->get_prev_auto(PLAY_FORWARD, affected_auto);
00138 }
00139
00140 return affected_auto;
00141 }
00142
00143
00144
00145 void CWindow::calculate_affected_autos(FloatAuto **x_auto,
00146 FloatAuto **y_auto,
00147 FloatAuto **z_auto,
00148 Track *track,
00149 int use_camera,
00150 int create_x,
00151 int create_y,
00152 int create_z)
00153 {
00154 if(x_auto) (*x_auto) = 0;
00155 if(y_auto) (*y_auto) = 0;
00156 if(z_auto) (*z_auto) = 0;
00157
00158 if(!track) return;
00159
00160 if(use_camera)
00161 {
00162 if(x_auto) (*x_auto) = (FloatAuto*)calculate_affected_auto(
00163 track->automation->autos[AUTOMATION_CAMERA_X], create_x);
00164 if(y_auto) (*y_auto) = (FloatAuto*)calculate_affected_auto(
00165 track->automation->autos[AUTOMATION_CAMERA_Y], create_y);
00166 if(z_auto) (*z_auto) = (FloatAuto*)calculate_affected_auto(
00167 track->automation->autos[AUTOMATION_CAMERA_Z], create_z);
00168 }
00169 else
00170 {
00171 if(x_auto) (*x_auto) = (FloatAuto*)calculate_affected_auto(
00172 track->automation->autos[AUTOMATION_PROJECTOR_X], create_x);
00173 if(y_auto) (*y_auto) = (FloatAuto*)calculate_affected_auto(
00174 track->automation->autos[AUTOMATION_PROJECTOR_Y], create_y);
00175 if(z_auto) (*z_auto) = (FloatAuto*)calculate_affected_auto(
00176 track->automation->autos[AUTOMATION_PROJECTOR_Z], create_z);
00177 }
00178 }
00179
00180
00181
00182
00183
00184 void CWindow::run()
00185 {
00186 gui->run_window();
00187 }
00188
00189 void CWindow::update(int position,
00190 int overlays,
00191 int tool_window,
00192 int operation,
00193 int timebar)
00194 {
00195
00196 if(position)
00197 {
00198 gui->lock_window("CWindow::update 1");
00199 gui->slider->set_position();
00200 gui->unlock_window();
00201
00202 playback_engine->que->send_command(CURRENT_FRAME,
00203 CHANGE_NONE,
00204 mwindow->edl,
00205 1);
00206 }
00207
00208 gui->lock_window("CWindow::update 2");
00209
00210
00211
00212 if(operation)
00213 {
00214 gui->set_operation(mwindow->edl->session->cwindow_operation);
00215 }
00216
00217
00218
00219 if(overlays && !position)
00220 {
00221 gui->canvas->draw_refresh();
00222 }
00223
00224
00225
00226 if(tool_window || position)
00227 {
00228 gui->update_tool();
00229 }
00230
00231 if(timebar)
00232 {
00233 gui->timebar->update(1, 1);
00234 }
00235
00236 if(!mwindow->edl->session->cwindow_scrollbars)
00237 gui->zoom_panel->update(AUTO_ZOOM);
00238 else
00239 gui->zoom_panel->update(mwindow->edl->session->cwindow_zoom);
00240
00241 gui->canvas->update_zoom(mwindow->edl->session->cwindow_xscroll,
00242 mwindow->edl->session->cwindow_yscroll,
00243 mwindow->edl->session->cwindow_zoom);
00244 gui->canvas->reposition_window(mwindow->edl,
00245 mwindow->theme->ccanvas_x,
00246 mwindow->theme->ccanvas_y,
00247 mwindow->theme->ccanvas_w,
00248 mwindow->theme->ccanvas_h);
00249
00250
00251
00252
00253 gui->unlock_window();
00254
00255
00256
00257
00258 }
00259
00260