[4] | 1 | /*============================================================================= |
---|
| 2 | |
---|
| 3 | Program: JuxtaView for SAGE |
---|
| 4 | Module: JuxtaSCUI.cpp - Part of JuxtaView's UI |
---|
| 5 | Authors: Arun Rao, arao@evl.uic.edu, |
---|
| 6 | Ratko Jagodic, rjagodic@evl.uic.edu, |
---|
| 7 | Nicholas Schwarz, schwarz@evl.uic.edu, |
---|
| 8 | Luc Renambot, luc@evl.uic.edu, |
---|
| 9 | et al. |
---|
| 10 | Date: 30 September 2004 |
---|
| 11 | Modified: 15 August 2005 |
---|
| 12 | |
---|
| 13 | Copyright (c) 2005 Electronic Visualization Laboratory, |
---|
| 14 | University of Illinois at Chicago |
---|
| 15 | |
---|
| 16 | All rights reserved. |
---|
| 17 | * |
---|
| 18 | * Redistribution and use in source and binary forms, with or without |
---|
| 19 | * modification, are permitted provided that the following conditions are met: |
---|
| 20 | * |
---|
| 21 | * * Redistributions of source code must retain the above copyright |
---|
| 22 | * notice, this list of conditions and the following disclaimer. |
---|
| 23 | * * Redistributions in binary form must reproduce the above |
---|
| 24 | * copyright notice, this list of conditions and the following disclaimer |
---|
| 25 | * in the documentation and/or other materials provided with the distribution. |
---|
| 26 | * * Neither the name of the University of Illinois at Chicago nor |
---|
| 27 | * the names of its contributors may be used to endorse or promote |
---|
| 28 | * products derived from this software without specific prior written permission. |
---|
| 29 | * |
---|
| 30 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
---|
| 31 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
---|
| 32 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
---|
| 33 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
---|
| 34 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
---|
| 35 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 36 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
---|
| 37 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
---|
| 38 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
---|
| 39 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
---|
| 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 41 | * |
---|
| 42 | * Direct questions, comments etc about SAGE to http://www.evl.uic.edu/cavern/forum/ |
---|
| 43 | * |
---|
| 44 | *****************************************************************************/ |
---|
| 45 | |
---|
| 46 | |
---|
| 47 | #include "JuxtaSCUI.h" |
---|
| 48 | |
---|
| 49 | void SkipComments(FILE* fin,char commentFlag); |
---|
| 50 | #define COMMENT_FLAG '#' |
---|
| 51 | |
---|
| 52 | JuxtaSCUIFrame::JuxtaSCUIFrame(bool ov, char* skinfilename,wxWindow* parent, int id, const wxString& title, |
---|
| 53 | const wxPoint& pos, const wxSize& size, long style) |
---|
| 54 | :wxFrame(parent,id,title,pos,size,style) |
---|
| 55 | { |
---|
| 56 | QUANTAinit(); |
---|
| 57 | client = NULL; |
---|
| 58 | num_clients = 0; |
---|
| 59 | |
---|
| 60 | |
---|
| 61 | //---------setup the ui |
---|
| 62 | wxImage* img; |
---|
| 63 | wxBitmapButton* bmpbtn; |
---|
| 64 | wxBitmap* bmp; |
---|
| 65 | wxPanel* panel; |
---|
| 66 | char buffer[100]; |
---|
| 67 | char background[100]; |
---|
| 68 | char upfile[100]; |
---|
| 69 | char downfile[100]; |
---|
| 70 | int xpos,ypos; |
---|
| 71 | |
---|
| 72 | gApp->SetTopWindow(this); |
---|
| 73 | |
---|
| 74 | panel = new wxPanel(this,-1); |
---|
| 75 | |
---|
| 76 | //background |
---|
| 77 | wxInitAllImageHandlers(); |
---|
| 78 | FILE* skinfile = NULL; |
---|
| 79 | |
---|
| 80 | if(skinfilename == NULL) |
---|
| 81 | skinfile = fopen("Skins/default.jsk","r"); |
---|
| 82 | else |
---|
| 83 | skinfile = fopen(skinfilename,"r"); |
---|
| 84 | |
---|
| 85 | if(skinfile == NULL) |
---|
| 86 | return; |
---|
| 87 | |
---|
| 88 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 89 | |
---|
| 90 | //get the background filename |
---|
| 91 | fscanf(skinfile,"%s\n",background); |
---|
| 92 | img = new wxImage(background); |
---|
| 93 | bmp = new wxBitmap((*img)); |
---|
| 94 | statbmp = new wxStaticBitmap(panel,20,(*bmp),wxPoint(0,0)); |
---|
| 95 | #if defined(_WIN32) || defined(WIN32) || defined(WINDOWS) || defined(_WINDOWS_) |
---|
| 96 | statbmp->Disable(); //to make sure the button pushes go to the buttons, not the background image |
---|
| 97 | #endif |
---|
| 98 | |
---|
| 99 | //get the pan up info |
---|
| 100 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 101 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 102 | img = new wxImage(upfile); |
---|
| 103 | bmpbtn = new wxBitmapButton(panel,ID_PanUp,(*img),wxPoint(xpos,ypos), |
---|
| 104 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 105 | img = new wxImage(downfile); |
---|
| 106 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 107 | bmpbtn->SetToolTip(buffer); |
---|
| 108 | |
---|
| 109 | //get the pan down info |
---|
| 110 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 111 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 112 | img = new wxImage(upfile); |
---|
| 113 | bmpbtn = new wxBitmapButton(panel,ID_PanDown,(*img),wxPoint(xpos,ypos), |
---|
| 114 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 115 | img = new wxImage(downfile); |
---|
| 116 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 117 | bmpbtn->SetToolTip(buffer); |
---|
| 118 | |
---|
| 119 | //get the pan left info |
---|
| 120 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 121 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 122 | img = new wxImage(upfile); |
---|
| 123 | bmpbtn = new wxBitmapButton(panel,ID_PanLeft,(*img),wxPoint(xpos,ypos), |
---|
| 124 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 125 | img = new wxImage(downfile); |
---|
| 126 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 127 | bmpbtn->SetToolTip(buffer); |
---|
| 128 | |
---|
| 129 | //get the pan right info |
---|
| 130 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 131 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 132 | img = new wxImage(upfile); |
---|
| 133 | bmpbtn = new wxBitmapButton(panel,ID_PanRight,(*img),wxPoint(xpos,ypos), |
---|
| 134 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 135 | img = new wxImage(downfile); |
---|
| 136 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 137 | bmpbtn->SetToolTip(buffer); |
---|
| 138 | |
---|
| 139 | //get the fast pan up info |
---|
| 140 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 141 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 142 | img = new wxImage(upfile); |
---|
| 143 | bmpbtn = new wxBitmapButton(panel,ID_FastPanUp,(*img),wxPoint(xpos,ypos), |
---|
| 144 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 145 | img = new wxImage(downfile); |
---|
| 146 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 147 | bmpbtn->SetToolTip(buffer); |
---|
| 148 | |
---|
| 149 | //load up the fast pan down button |
---|
| 150 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 151 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 152 | img = new wxImage(upfile); |
---|
| 153 | bmpbtn = new wxBitmapButton(panel,ID_FastPanDown,(*img),wxPoint(xpos,ypos), |
---|
| 154 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 155 | img = new wxImage(downfile); |
---|
| 156 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 157 | bmpbtn->SetToolTip(buffer); |
---|
| 158 | |
---|
| 159 | //load up the fast pan left button |
---|
| 160 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 161 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 162 | img = new wxImage(upfile); |
---|
| 163 | bmpbtn = new wxBitmapButton(panel,ID_FastPanLeft,(*img),wxPoint(xpos,ypos), |
---|
| 164 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 165 | img = new wxImage(downfile); |
---|
| 166 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 167 | bmpbtn->SetToolTip(buffer); |
---|
| 168 | |
---|
| 169 | //load up the fast pan right button |
---|
| 170 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 171 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 172 | img = new wxImage(upfile); |
---|
| 173 | bmpbtn = new wxBitmapButton(panel,ID_FastPanRight,(*img),wxPoint(xpos,ypos), |
---|
| 174 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 175 | img = new wxImage(downfile); |
---|
| 176 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 177 | bmpbtn->SetToolTip(buffer); |
---|
| 178 | |
---|
| 179 | //load up the zoom in button |
---|
| 180 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 181 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 182 | img = new wxImage(upfile); |
---|
| 183 | bmpbtn = new wxBitmapButton(panel,ID_ZoomIn,(*img),wxPoint(xpos,ypos), |
---|
| 184 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 185 | img = new wxImage(downfile); |
---|
| 186 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 187 | bmpbtn->SetToolTip(buffer); |
---|
| 188 | |
---|
| 189 | //load up the zoom out button |
---|
| 190 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 191 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 192 | img = new wxImage(upfile); |
---|
| 193 | bmpbtn = new wxBitmapButton(panel,ID_ZoomOut,(*img),wxPoint(xpos,ypos), |
---|
| 194 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 195 | img = new wxImage(downfile); |
---|
| 196 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 197 | bmpbtn->SetToolTip(buffer); |
---|
| 198 | |
---|
| 199 | //load up the Quit button |
---|
| 200 | SkipComments(skinfile,COMMENT_FLAG); |
---|
| 201 | fscanf(skinfile,"%s %s %s (%d,%d)\n",buffer,upfile,downfile,&xpos,&ypos); |
---|
| 202 | img = new wxImage(upfile); |
---|
| 203 | bmpbtn = new wxBitmapButton(panel,ID_Quit,(*img),wxPoint(xpos,ypos), |
---|
| 204 | wxSize(img->GetWidth(),img->GetHeight()),wxBORDER_NONE); |
---|
| 205 | img = new wxImage(downfile); |
---|
| 206 | bmpbtn->SetBitmapSelected((*img)); |
---|
| 207 | bmpbtn->SetToolTip(buffer); |
---|
| 208 | |
---|
| 209 | fclose(skinfile); |
---|
| 210 | |
---|
| 211 | overviewframe = NULL; |
---|
| 212 | showoverview = ov; |
---|
| 213 | |
---|
| 214 | } |
---|
| 215 | |
---|
| 216 | |
---|
| 217 | void JuxtaSCUIFrame::Show() |
---|
| 218 | { |
---|
| 219 | for (int i = 0 ; i < num_clients ; i++) |
---|
| 220 | if(overviewframe[i] && showoverview) |
---|
| 221 | overviewframe[i]->Show(); |
---|
| 222 | |
---|
| 223 | wxFrame::Show(); |
---|
| 224 | } |
---|
| 225 | |
---|
| 226 | |
---|
| 227 | BEGIN_EVENT_TABLE( JuxtaSCUIFrame, wxFrame) |
---|
| 228 | EVT_BUTTON( ID_PanUp, JuxtaSCUIFrame::OnEvent) |
---|
| 229 | EVT_BUTTON( ID_PanDown, JuxtaSCUIFrame::OnEvent) |
---|
| 230 | EVT_BUTTON( ID_PanLeft, JuxtaSCUIFrame::OnEvent) |
---|
| 231 | EVT_BUTTON( ID_PanRight, JuxtaSCUIFrame::OnEvent) |
---|
| 232 | EVT_BUTTON( ID_FastPanUp, JuxtaSCUIFrame::OnEvent) |
---|
| 233 | EVT_BUTTON( ID_FastPanDown, JuxtaSCUIFrame::OnEvent) |
---|
| 234 | EVT_BUTTON( ID_FastPanLeft, JuxtaSCUIFrame::OnEvent) |
---|
| 235 | EVT_BUTTON( ID_FastPanRight, JuxtaSCUIFrame::OnEvent) |
---|
| 236 | EVT_BUTTON( ID_ZoomIn, JuxtaSCUIFrame::OnEvent) |
---|
| 237 | EVT_BUTTON( ID_ZoomOut, JuxtaSCUIFrame::OnEvent) |
---|
| 238 | EVT_BUTTON( ID_Quit, JuxtaSCUIFrame::OnEvent) |
---|
| 239 | END_EVENT_TABLE() |
---|
| 240 | |
---|
| 241 | //------------------------------------------ |
---|
| 242 | JuxtaSCUIFrame::~JuxtaSCUIFrame() |
---|
| 243 | { |
---|
| 244 | |
---|
| 245 | if(client) |
---|
| 246 | { |
---|
| 247 | PassEvent(JVQUIT); |
---|
| 248 | for (int i = 0 ; i < num_clients ; i++) { |
---|
| 249 | client[i] -> close(); |
---|
| 250 | delete client[i]; |
---|
| 251 | client[i] = NULL; |
---|
| 252 | } |
---|
| 253 | delete client; |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | |
---|
| 259 | //------------------------------------------ |
---|
| 260 | void JuxtaSCUIFrame::Init(char* configfilename) |
---|
| 261 | { |
---|
| 262 | FILE* fin = fopen(configfilename,"r"); |
---|
| 263 | if(!fin) |
---|
| 264 | return; |
---|
| 265 | |
---|
| 266 | char ip[32]; |
---|
| 267 | int port; |
---|
| 268 | memset(ip,0,32); |
---|
| 269 | |
---|
| 270 | // get number of clients to connect to |
---|
| 271 | fscanf(fin,"%d", &num_clients); |
---|
| 272 | |
---|
| 273 | // allocate array of pointers to clients |
---|
| 274 | client = new QUANTAnet_tcpClient_c *[num_clients]; |
---|
| 275 | |
---|
| 276 | // allocate array of pointers to overview frames |
---|
| 277 | overviewframe = new JuxtaOverviewFrame *[num_clients]; |
---|
| 278 | |
---|
| 279 | // allocate QUANTA objects for each client |
---|
| 280 | for (int i = 0 ; i < num_clients ; i++) { |
---|
| 281 | client[i] = new QUANTAnet_tcpClient_c(); |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | cout << "*****Number of clients: " << num_clients << endl; |
---|
| 285 | |
---|
| 286 | for (int i = 0 ; i < num_clients ; i++) { |
---|
| 287 | |
---|
| 288 | // read client info and connect |
---|
| 289 | fscanf(fin,"%s : %d\n",ip,&port); |
---|
| 290 | |
---|
| 291 | //client[i] = new QUANTAnet_tcpClient_c(); |
---|
| 292 | if(client[i] -> connectToServer(ip, port) < 0) |
---|
| 293 | { |
---|
| 294 | client[i] -> close(); |
---|
| 295 | delete client[i]; |
---|
| 296 | client[i] = NULL; |
---|
| 297 | |
---|
| 298 | #if DEBUG |
---|
| 299 | wxMessageBox("Failed To Connect To Server.\nMake sure juxtauiclient.conf file has correct server ip and port number.\nCorrect format is \"server ip\" : \"port number\""); |
---|
| 300 | #endif |
---|
| 301 | } |
---|
| 302 | |
---|
| 303 | else |
---|
| 304 | { |
---|
| 305 | //make sure the user didn't disable the overview |
---|
| 306 | if(showoverview) |
---|
| 307 | { |
---|
| 308 | fprintf(stderr,"Attempting to load overview\n"); |
---|
| 309 | //ask for the overview!!!! |
---|
| 310 | overviewframe[i] = new JuxtaOverviewFrame(gApp->GetTopWindow(), |
---|
| 311 | -1,"Overview", |
---|
| 312 | wxPoint(wxWindow::GetSize().GetWidth(),0), |
---|
| 313 | wxSize(100,200), |
---|
| 314 | wxMINIMIZE_BOX | wxFRAME_NO_TASKBAR | wxRESIZE_BORDER); |
---|
| 315 | overviewframe[i]->Layout(); |
---|
| 316 | overviewframe[i]->Show(); |
---|
| 317 | |
---|
| 318 | GetOverview(i); |
---|
| 319 | GetExtents(i); |
---|
| 320 | } |
---|
| 321 | else |
---|
| 322 | { |
---|
| 323 | fprintf(stderr,"Not attempting to make overview\n"); |
---|
| 324 | overviewframe[i] = new JuxtaOverviewFrame(0,-1,"",wxPoint(0,0),wxSize(0,0),wxSIMPLE_BORDER); |
---|
| 325 | overviewframe[i]->Layout(); |
---|
| 326 | overviewframe[i]->Show(); |
---|
| 327 | } |
---|
| 328 | |
---|
| 329 | fflush(stderr); |
---|
| 330 | |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | } |
---|
| 334 | |
---|
| 335 | /* |
---|
| 336 | |
---|
| 337 | if(client[0] == NULL) |
---|
| 338 | { |
---|
| 339 | client[0] -> close(); |
---|
| 340 | delete client[i]; |
---|
| 341 | client[0] = NULL; |
---|
| 342 | |
---|
| 343 | #if DEBUG |
---|
| 344 | wxMessageBox("Failed To Connect To Server.\nMake sure juxtauicl\ |
---|
| 345 | ient.conf file has correct server ip and port number.\nCorrect format is \"serv\ |
---|
| 346 | er ip\" : \"port number\""); |
---|
| 347 | #endif |
---|
| 348 | } |
---|
| 349 | else |
---|
| 350 | { |
---|
| 351 | //make sure the user didn't disable the overview |
---|
| 352 | if(showoverview) |
---|
| 353 | { |
---|
| 354 | fprintf(stderr,"Attempting to load overview\n"); |
---|
| 355 | //ask for the overview!!!! |
---|
| 356 | overviewframe = new JuxtaOverviewFrame(gApp->GetTopWindow()\ |
---|
| 357 | , |
---|
| 358 | -1,"Overview", |
---|
| 359 | wxPoint(wxWindow::GetSize().GetWidth(),0), |
---|
| 360 | wxSize(100,200), |
---|
| 361 | wxMINIMIZE_BOX | wxFRAME_NO_TASKBAR | wxRESIZE_BORDER); |
---|
| 362 | overviewframe->Layout(); |
---|
| 363 | overviewframe->Show(); |
---|
| 364 | |
---|
| 365 | GetOverview(i); |
---|
| 366 | GetExtents(i); |
---|
| 367 | } |
---|
| 368 | else |
---|
| 369 | { |
---|
| 370 | fprintf(stderr,"Not attempting to make overview\n"); |
---|
| 371 | overviewframe = new JuxtaOverviewFrame(0,-1,"",wxPoint(0,0)\ |
---|
| 372 | ,wxSize(0,0),wxSIMPLE_BORDER); |
---|
| 373 | overviewframe[i]->Layout(); |
---|
| 374 | overviewframe[i]->Show(); |
---|
| 375 | } |
---|
| 376 | |
---|
| 377 | fflush(stderr); |
---|
| 378 | |
---|
| 379 | } |
---|
| 380 | */ |
---|
| 381 | fclose(fin); |
---|
| 382 | } |
---|
| 383 | |
---|
| 384 | //------------------------------------------ |
---|
| 385 | void JuxtaSCUIFrame::OnEvent(wxCommandEvent& event) |
---|
| 386 | { |
---|
| 387 | |
---|
| 388 | //disable all buttons but quit |
---|
| 389 | //here's the tree |
---|
| 390 | // this |
---|
| 391 | // |_______panel |
---|
| 392 | // |________All the buttons!!!!!! |
---|
| 393 | |
---|
| 394 | // this->GetChildren().GetFirst()->GetData()->Disable(); |
---|
| 395 | |
---|
| 396 | switch(event.GetId()) |
---|
| 397 | { |
---|
| 398 | case ID_FastPanLeft: |
---|
| 399 | PassEvent(JVFAST_PAN_LEFT); |
---|
| 400 | break; |
---|
| 401 | case ID_FastPanRight: |
---|
| 402 | PassEvent(JVFAST_PAN_RIGHT); |
---|
| 403 | break; |
---|
| 404 | case ID_FastPanUp: |
---|
| 405 | PassEvent(JVFAST_PAN_UP); |
---|
| 406 | break; |
---|
| 407 | case ID_FastPanDown: |
---|
| 408 | PassEvent(JVFAST_PAN_DOWN); |
---|
| 409 | break; |
---|
| 410 | case ID_PanLeft: |
---|
| 411 | PassEvent(JVPAN_LEFT); |
---|
| 412 | break; |
---|
| 413 | case ID_PanRight: |
---|
| 414 | PassEvent(JVPAN_RIGHT); |
---|
| 415 | break; |
---|
| 416 | case ID_PanUp: |
---|
| 417 | PassEvent(JVPAN_UP); |
---|
| 418 | break; |
---|
| 419 | case ID_PanDown: |
---|
| 420 | PassEvent(JVPAN_DOWN); |
---|
| 421 | break; |
---|
| 422 | case ID_ZoomIn: |
---|
| 423 | PassEvent(JVZOOM_IN); |
---|
| 424 | break; |
---|
| 425 | case ID_ZoomOut: |
---|
| 426 | PassEvent(JVZOOM_OUT); |
---|
| 427 | break; |
---|
| 428 | case ID_Quit: |
---|
| 429 | PassEvent(JVQUIT); |
---|
| 430 | break; |
---|
| 431 | default: |
---|
| 432 | break; |
---|
| 433 | } //end switch |
---|
| 434 | |
---|
| 435 | //ask for the extent if it's not quit |
---|
| 436 | if( event.GetId() != ID_Quit) |
---|
| 437 | |
---|
| 438 | for (int i = 0 ; i < num_clients ; i++) { |
---|
| 439 | if (overviewframe[i] && showoverview ) |
---|
| 440 | { |
---|
| 441 | GetExtents(i); |
---|
| 442 | if(overviewframe[i]) |
---|
| 443 | overviewframe[i]->Refresh(); |
---|
| 444 | } |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | Refresh(); |
---|
| 448 | |
---|
| 449 | // this->GetChildren().GetFirst()->GetData()->Enable(); |
---|
| 450 | |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | //------------------------------------------ |
---|
| 454 | void JuxtaSCUIFrame::BigRefresh() |
---|
| 455 | { |
---|
| 456 | for (int i = 0 ; i < num_clients ; i++) { |
---|
| 457 | if (overviewframe[i] && showoverview ) |
---|
| 458 | { |
---|
| 459 | GetExtents(i); |
---|
| 460 | if(overviewframe[i]) |
---|
| 461 | overviewframe[i]->Refresh(); |
---|
| 462 | } |
---|
| 463 | } |
---|
| 464 | |
---|
| 465 | Refresh(); |
---|
| 466 | |
---|
| 467 | } |
---|
| 468 | |
---|
| 469 | //------------------------------------------ |
---|
| 470 | void JuxtaSCUIFrame::PassEvent(char* strEvent) |
---|
| 471 | { |
---|
| 472 | #if DEBUG |
---|
| 473 | fprintf(stderr,"passing event %s\n",strEvent); |
---|
| 474 | #endif |
---|
| 475 | //pass event to server |
---|
| 476 | static char sendBuffer[TRANSMISSION_SIZE]; |
---|
| 477 | static int size = TRANSMISSION_SIZE; |
---|
| 478 | |
---|
| 479 | clientMutex.Lock(); |
---|
| 480 | memset(sendBuffer,0,TRANSMISSION_SIZE); |
---|
| 481 | strcpy(sendBuffer,strEvent); |
---|
| 482 | for (int i = 0 ; i < num_clients ; i++) { |
---|
| 483 | if(client[i]) |
---|
| 484 | { |
---|
| 485 | client[i]->write(sendBuffer,&size, QUANTAnet_tcpClient_c::BLOCKING); |
---|
| 486 | } |
---|
| 487 | } |
---|
| 488 | clientMutex.Unlock(); |
---|
| 489 | |
---|
| 490 | } |
---|
| 491 | |
---|
| 492 | //------------------------------------------ |
---|
| 493 | void JuxtaSCUIFrame::PassBuffer(void* buffer,int size) |
---|
| 494 | { |
---|
| 495 | clientMutex.Lock(); |
---|
| 496 | for (int i = 0 ; i < num_clients ; i++) { |
---|
| 497 | if(client[i]) |
---|
| 498 | { |
---|
| 499 | client[i]->write((const char*)buffer,&size,QUANTAnet_tcpClient_c::BLOCKING); |
---|
| 500 | } |
---|
| 501 | } |
---|
| 502 | clientMutex.Unlock(); |
---|
| 503 | |
---|
| 504 | } |
---|
| 505 | |
---|
| 506 | //------------------------------------------ |
---|
| 507 | void JuxtaSCUIFrame::GetExtents(int cn) |
---|
| 508 | { |
---|
| 509 | #if DEBUG |
---|
| 510 | fprintf(stderr,"Getting extents for overview\n"); |
---|
| 511 | #endif |
---|
| 512 | //pass event to server |
---|
| 513 | static char sendBuffer[TRANSMISSION_SIZE]; |
---|
| 514 | static int sendsize = TRANSMISSION_SIZE; |
---|
| 515 | static int readsize = sizeof(float) * 4; |
---|
| 516 | |
---|
| 517 | memset(sendBuffer,0,TRANSMISSION_SIZE); |
---|
| 518 | clientMutex.Lock(); |
---|
| 519 | strcpy(sendBuffer,JVEXTENTS); |
---|
| 520 | |
---|
| 521 | float readarray[4]; |
---|
| 522 | if( client[cn] ) |
---|
| 523 | { |
---|
| 524 | client[cn]->write(sendBuffer,&sendsize,QUANTAnet_tcpClient_c::BLOCKING); |
---|
| 525 | //get four floats |
---|
| 526 | client[cn]->read((char*)readarray,&readsize,QUANTAnet_tcpClient_c::BLOCKING); |
---|
| 527 | if(overviewframe[cn]) |
---|
| 528 | overviewframe[cn]->SetExtentRectangle(readarray[0],readarray[1],readarray[2],readarray[3]); |
---|
| 529 | |
---|
| 530 | #if DEBUG |
---|
| 531 | fprintf(stderr,"floats recieved: %f, %f, %f, %f\n",readarray[0],readarray[1],readarray[2],readarray[3]); |
---|
| 532 | #endif |
---|
| 533 | } |
---|
| 534 | clientMutex.Unlock(); |
---|
| 535 | |
---|
| 536 | } |
---|
| 537 | |
---|
| 538 | void JuxtaSCUIFrame::GetOverview(int cn) |
---|
| 539 | { |
---|
| 540 | #if DEBUG |
---|
| 541 | fprintf(stderr,"Getting overview image\n"); |
---|
| 542 | #endif |
---|
| 543 | //pass event to server |
---|
| 544 | static char sendBuffer[TRANSMISSION_SIZE]; |
---|
| 545 | static int sendsize = TRANSMISSION_SIZE; |
---|
| 546 | static int readsize; |
---|
| 547 | |
---|
| 548 | memset(sendBuffer,0,TRANSMISSION_SIZE); |
---|
| 549 | |
---|
| 550 | clientMutex.Lock(); |
---|
| 551 | strcpy(sendBuffer,JVOVERVIEW); |
---|
| 552 | |
---|
| 553 | if(client[cn]) |
---|
| 554 | { |
---|
| 555 | //ask for the overview |
---|
| 556 | client[cn]->write(sendBuffer,&sendsize,QUANTAnet_tcpClient_c::BLOCKING); |
---|
| 557 | |
---|
| 558 | //get two ints |
---|
| 559 | int dimarray[2]; |
---|
| 560 | readsize = sizeof(int) * 2; |
---|
| 561 | client[cn]->read((char*)dimarray,&readsize,QUANTAnet_tcpClient_c::BLOCKING); |
---|
| 562 | |
---|
| 563 | //get pixels |
---|
| 564 | readsize = dimarray[0] * dimarray[1] * 3; |
---|
| 565 | unsigned char* img = new unsigned char[readsize]; |
---|
| 566 | client[cn]->read((char*)img,&readsize,QUANTAnet_tcpClient_c::BLOCKING); |
---|
| 567 | |
---|
| 568 | if(overviewframe[cn]) |
---|
| 569 | overviewframe[cn]->SetImage(dimarray[0],dimarray[1],img); |
---|
| 570 | |
---|
| 571 | #if DEBUG |
---|
| 572 | fprintf(stderr,"Got overview of dims %d x %d\n",dimarray[0],dimarray[1]); |
---|
| 573 | #endif |
---|
| 574 | |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | clientMutex.Unlock(); |
---|
| 578 | |
---|
| 579 | } |
---|
| 580 | |
---|
| 581 | //------------------------------------------ |
---|
| 582 | |
---|
| 583 | void SkipComments(FILE* fin,char commentFlag) |
---|
| 584 | { |
---|
| 585 | char c; |
---|
| 586 | c = fgetc(fin); |
---|
| 587 | bool skipline; |
---|
| 588 | if( c == commentFlag) |
---|
| 589 | { |
---|
| 590 | skipline = true; |
---|
| 591 | while(skipline) |
---|
| 592 | { |
---|
| 593 | while( c != '\n' && !feof(fin)) |
---|
| 594 | c = fgetc(fin); |
---|
| 595 | |
---|
| 596 | if(feof(fin)) |
---|
| 597 | return; |
---|
| 598 | |
---|
| 599 | long position = ftell(fin); |
---|
| 600 | c = fgetc(fin); |
---|
| 601 | if(c != commentFlag) |
---|
| 602 | { |
---|
| 603 | skipline = false; |
---|
| 604 | fseek(fin,position,0); |
---|
| 605 | } |
---|
| 606 | } |
---|
| 607 | } |
---|
| 608 | else |
---|
| 609 | { |
---|
| 610 | fseek(fin, ftell(fin) - 1, 0); |
---|
| 611 | } |
---|
| 612 | } |
---|