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