graphview.cc
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
源码类别:

通讯编程

开发平台:

Visual C++

  1. /*
  2.  * Copyright (c) 1997 University of Southern California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *      This product includes software developed by the Information Sciences
  16.  *      Institute of the University of Southern California.
  17.  * 4. Neither the name of the University nor of the Institute may be used
  18.  *    to endorse or promote products derived from this software without
  19.  *    specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  * @(#) $Header: /cvsroot/nsnam/nam-1/graphview.cc,v 1.10 2003/10/11 22:56:50 xuanc Exp $ (LBL)
  34.  */
  35. #include <stdlib.h>
  36. #ifdef WIN32
  37. #include <windows.h>
  38. #endif
  39. #include <ctype.h>
  40. #include <math.h>
  41. #include "bbox.h"
  42. #include "graphview.h"
  43. #include "netgraph.h"
  44. #include "tclcl.h"
  45. #include "paint.h"
  46. #include "packet.h"
  47. GraphView::GraphView(const char* name, NetGraph* g) 
  48.         : View(name, NONSQUARE, 30, 30), next_(NULL), graph_(g)
  49. {
  50.   Tcl& tcl = Tcl::instance();
  51.   tcl.CreateCommand(Tk_PathName(View::tk()), command, (ClientData)this, 0);
  52. }
  53. // void GraphView::draw()
  54. // {
  55. //  if (offscreen_ == 0)
  56. //  return;
  57. //  XFillRectangle(Tk_Display(tk_), offscreen_, background_,
  58. //         0, 0, width_, height_);
  59. //  graph_->render(this);
  60. //  XCopyArea(Tk_Display(tk_), offscreen_, Tk_WindowId(tk_), background_,
  61. //    0, 0, width_, height_, 0, 0);
  62. // }
  63. int GraphView::command(ClientData cd, Tcl_Interp* tcl, int argc, CONST84 char **argv)
  64. {
  65. //GraphView *gv = (GraphView *)cd;
  66.   if (argc < 2) {
  67.     Tcl_AppendResult(tcl, """, argv[0], "": arg mismatch", 0);
  68.     return (TCL_ERROR);
  69.   }
  70. //    printf("GraphView::command: %sn", argv[1]);
  71.   return (View::command(cd, tcl, argc, argv));
  72. }
  73. void 
  74. GraphView::getWorldBox(BBox & world_boundary) {
  75.   graph_->BoundingBox(world_boundary);
  76. }