Esempio n. 1
0
void
plot_renz_matches(Tcl_Interp *interp,
		  char *re_win,
		  char *names_win,
		  int text_offset,
		  char *t_colour,
		  int yoffset,
		  int num_enzymes,
		  R_Enz *r_enzyme,
		  ruler_s *ruler,
		  int sequence_len,
		  int num_matches,
		  R_Match *match,
		  tick_s *tick,
		  char *frame,
		  WorldPtr *world,
		  CanvasPtr *canvas,
		  win **win_list,
		  int num_wins,
		  StackPtr **zoom)
{
    char cmd[1024];
    int item;
    int seq_len;
    int offset;
    int y_offset;
    int t_offset;
    int i;
    int cut_site;

    sprintf(cmd, "%s delete all", re_win);
    Tcl_Eval(interp, cmd);

    sprintf(cmd, "%s delete all", names_win);
    Tcl_Eval(interp, cmd);

    t_offset = text_offset;
    y_offset = yoffset;

    seq_len = ruler->end - ruler->start + 1;

    /* for each selected enzyme, display its name and cut sites */
    for (item = 0; item < num_enzymes; item++) {

        offset = yoffset;
	sprintf(cmd,"%s create text 10 %d -text %s -anchor w -fill %s "
		"-font enzyme_font -tag {S re_%d}",
		names_win, t_offset, r_enzyme[item].name, t_colour, 
		item);
	Tcl_Eval(interp, cmd);
	sprintf(cmd, "%s create line %d %d %d %d -tag contig -fill %s",
		re_win, ruler->start, y_offset, ruler->end, y_offset, ruler->colour);
	Tcl_Eval(interp, cmd);

	for (i = 0; i < num_matches; i++) {
	    if (item == match[i].enz_name) {
	
		offset = (item * tick->ht) + yoffset;
		/* cut_site = match[i].cut_pos; */
		cut_site = ruler->start - 1 + match[i].padded_cut_pos;

		PlotStickMap(interp, re_win,
			     ruler->start - 1 + match[i].cut_pos, cut_site,
			     0, offset, 
			     tick->ht, tick->line_width, tick->colour, item,
			     ruler->start, ruler->end);
	    }
	}
	y_offset += tick->ht;
	t_offset += tick->ht;
    }
    /* draw final line */
    sprintf(cmd, "%s create line %d %d %d %d -tag contig -fill %s",
	    re_win, ruler->start, y_offset, ruler->end, y_offset, ruler->colour);
    Tcl_Eval(interp, cmd);

    /* add back selection rectangles */
    if (TCL_ERROR == Tcl_VarEval(interp, "ReSelectRect ", frame, " ",
				 names_win, NULL))
	verror(ERR_WARN, "plot_renz_matches", "%s\n", interp->result);

    world->total->x1 = ruler->start;
    world->total->x2 = ruler->end;
    world->total->y1 = 1;
    world->total->y2 = y_offset;

    memcpy(world->visible, world->total, sizeof(d_box));
    world->visible->y2 = canvas->height;

    SetCanvasCoords(interp, world->visible->x1, world->visible->y1, 
		    world->visible->x2, world->visible->y2, canvas);

    draw_single_ruler(interp, ruler, canvas, ruler->start, ruler->end, 1);
    scaleCanvas(interp, win_list, num_wins, "all", world->visible, 
		canvas);
    scrollRegion(interp, win_list, num_wins, world->total, canvas);

    /* remove all current zooming info */
    freeZoom(zoom);

    /* add first zoom */
    pushZoom(zoom, world->visible);
}
Esempio n. 2
0
void QWidget::internalSetGeometry( int x, int y, int w, int h, bool isMove )
{
    if ( extra ) {				// any size restrictions?
	w = QMIN(w,extra->maxw);
	h = QMIN(h,extra->maxh);
	w = QMAX(w,extra->minw);
	h = QMAX(h,extra->minh);
    }
    if ( w < 1 )				// invalid size
	w = 1;
    if ( h < 1 )
	h = 1;

    QPoint oldp = geometry().topLeft();
    QSize olds = size();
    QRect r( x, y, w, h );

    bool isResize = olds != r.size();

    // We only care about stuff that changes the geometry, or may
    // cause the window manager to change its state
    if ( r.size() == olds && oldp == r.topLeft() )
	return;

    QRegion oldAlloc;
    if ( !isTopLevel() && isMove && ( w==olds.width() && h==olds.height() ) ) {
	oldAlloc = allocatedRegion();
    }

    if (!in_show_maximized) {
        clearWState(WState_Maximized);
        clearWState(WState_FullScreen);
        if (isTopLevel())
            topData()->normalGeometry = QRect(0, 0, -1, -1);
    }
    QPoint oldPos = pos();
    crect = r;

    if ( testWFlags(WType_Desktop) )
	return;

    if ( isTopLevel() ) {
	//### ConfigPending not implemented, do we need it?
	//setWState( WState_ConfigPending );
	if ( isMove && ( w==olds.width() && h==olds.height() ) ) {
	    // just need to translate current region
	    QSize s( qt_screen->width(), qt_screen->height() );
	    QPoint td1 = qt_screen->mapToDevice( QPoint(0,0), s );
	    QPoint td2 = qt_screen->mapToDevice( QPoint(x - oldp.x(),y - oldp.y()), s );
	    QPoint dd = QPoint( td2.x()-td1.x(), td2.y()-td1.y() );
	    req_region.translate( dd.x(), dd.y() );
	} else {
	    if ( extra && !extra->mask.isNull() ) {
		req_region = extra->mask;
		req_region.translate(crect.x(),crect.y());
		req_region &= crect; //??? this is optional
	    } else {
		req_region = crect;
	    }
	    req_region = qt_screen->mapToDevice( req_region, QSize(qt_screen->width(), qt_screen->height()) );
	}
	if ( isVisible() ) {
	    if ( isMove && !isResize && alloc_region_index >= 0 ) {
		qwsDisplay()->moveRegion(winId(), x - oldp.x(), y - oldp.y());
		setChildrenAllocatedDirty();
	    } else {
		QRegion rgn( req_region );
#ifndef QT_NO_QWS_MANAGER
		if ( extra && extra->topextra && extra->topextra->qwsManager ) {
		    QRegion wmr = extra->topextra->qwsManager->region();
		    wmr = qt_screen->mapToDevice( wmr, QSize(qt_screen->width(), qt_screen->height()) );
		    rgn += wmr;
		}
#endif
		qwsDisplay()->requestRegion(winId(), rgn);
		if ( extra && extra->topextra ) {
		    QRect br( rgn.boundingRect() );
		    br = qt_screen->mapFromDevice( br, QSize(qt_screen->deviceWidth(), qt_screen->deviceHeight()) );
		    extra->topextra->fleft = crect.x()-br.x();
		    extra->topextra->ftop = crect.y()-br.y();
		    extra->topextra->fright = br.right()-crect.right();
		    extra->topextra->fbottom = br.bottom()-crect.bottom();
		}
	    }
	}
    }

    if ( isVisible() ) {
	isSettingGeometry = TRUE;
	if ( isMove ) {
	    QMoveEvent e( pos(), oldPos );
	    QApplication::sendEvent( this, &e );
#ifndef QT_NO_QWS_MANAGER
	    if (extra && extra->topextra && extra->topextra->qwsManager)
		QApplication::sendEvent( extra->topextra->qwsManager, &e );
#endif
	}
	if ( isResize ) {
	    QResizeEvent e( r.size(), olds );
	    QApplication::sendEvent( this, &e );
#ifndef QT_NO_QWS_MANAGER
	    if (extra && extra->topextra && extra->topextra->qwsManager) {
		QResizeEvent e( r.size(), olds );
		QApplication::sendEvent(topData()->qwsManager, &e);
	    }
#endif
/*
	    if ( !testWFlags( WStaticContents ) ) {
		QApplication::postEvent(this,new QPaintEvent(clipRegion(),
					!testWFlags(WResizeNoErase) ) );
	    }
*/
	}

	updateRequestedRegion( mapToGlobal(QPoint(0,0)) );

	QWidget *p = parentWidget();
	if ( !isTopLevel() || isResize ) {
	    if ( p && !isTopLevel() ) {
		p->paintable_region_dirty = TRUE;
		QRegion oldr( QRect(oldp, olds) );
		dirtyChildren.translate( x, y );
		if ( p->isSettingGeometry ) {
		    if ( oldp != r.topLeft() ) {
			QRegion upd( (QRegion(r) | oldr) & p->rect() );
			dirtyChildren |= upd;
		    } else {
			dirtyChildren |= QRegion(r) - oldr;
			QApplication::postEvent( this, new QPaintEvent(rect(),
			    !testWFlags(QWidget::WResizeNoErase)) );
		    }
		    p->dirtyChildren |= dirtyChildren;
		} else {
		    QRegion upd( (QRegion(r) | oldr) & p->rect() );
		    dirtyChildren |= upd;
		    QRegion paintRegion = dirtyChildren;
#define FAST_WIDGET_MOVE
#ifdef FAST_WIDGET_MOVE
		    if ( isMove && ( w==olds.width() && h==olds.height() ) ) {
			QSize s( qt_screen->width(), qt_screen->height() );

			QPoint td1 = qt_screen->mapToDevice( QPoint(0,0), s );
			QPoint td2 = qt_screen->mapToDevice( QPoint(x - oldp.x(),y - oldp.y()), s );
			QPoint dd = QPoint( td2.x()-td1.x(), td2.y()-td1.y() );
			oldAlloc.translate( dd.x(), dd.y() );

			QRegion alloc( allocatedRegion() );

			QRegion scrollRegion( alloc & oldAlloc );
			if ( !scrollRegion.isEmpty() ) {
			    QGfx * gfx = p->graphicsContext(FALSE);
			    gfx->setClipDeviceRegion( scrollRegion );
			    gfx->scroll(x,y,w,h,oldp.x(),oldp.y());
			    delete gfx;

			    QSize ds( qt_screen->deviceWidth(), qt_screen->deviceHeight() );
			    scrollRegion = qt_screen->mapFromDevice( scrollRegion, ds );
			    QPoint gp = p->mapToGlobal( QPoint(0,0) );
			    scrollRegion.translate( -gp.x(), -gp.y() );
			    paintRegion -= scrollRegion;
			}
		    }
#endif
		    if ( !oldr.isEmpty() )
			QApplication::postEvent( p, new QPaintEvent(oldr, TRUE) );
		    p->setChildrenAllocatedDirty( dirtyChildren, this );
		    qwsUpdateActivePainters();
		    paint_children( p, paintRegion, isResize );
		}
		p->overlapping_children = -1;
	    } else {
		if ( oldp != r.topLeft() ) {
		    qwsUpdateActivePainters();
		    paint_heirarchy( this, TRUE );
		} else {
		    setChildrenAllocatedDirty( dirtyChildren );
		    qwsUpdateActivePainters();
		    QApplication::postEvent( this, new QPaintEvent(rect(),
			!testWFlags(QWidget::WResizeNoErase)) );
		    paint_children( this, dirtyChildren, TRUE );
		}
	    }
	} else {
	    qwsUpdateActivePainters();
	}
#ifndef QT_NO_QWS_MANAGER
	if (isResize && extra && extra->topextra && extra->topextra->qwsManager) {
	    QApplication::postEvent(topData()->qwsManager,
				    new QPaintEvent( clipRegion(), TRUE ) );
	}
#endif
	isSettingGeometry = FALSE;
	dirtyChildren = QRegion();
    } else {
	if ( isMove )
	    QApplication::postEvent( this,
				     new QMoveEvent( pos(), oldPos ) );
	if ( isResize )
	    QApplication::postEvent( this,
				     new QResizeEvent(crect.size(), olds) );
    }
}
Esempio n. 3
0
void ed_plot_renz_matches(Tcl_Interp *interp,
			  char *re_win,
			  char *names_win,
			  int text_offset,
			  char *t_colour,
			  int yoffset,
			  int num_enzymes,
			  RENZYMES *r_enzyme,
			  ruler_s *ruler,
			  int sequence_len,
			  int num_matches,
			  R_MATCH *match,
			  tick_s *tick,
			  char *frame,
			  WorldPtr *world,
			  CanvasPtr *canvas,
			  win **win_list,
			  int num_wins,
			  StackPtr **zoom,
			  int seq_id,
			  SELECTION *sel)
{
    char cmd[1024];
    int item;
    int seq_len;
    int offset;
    int y_offset;
    int t_offset;
    int i;
    int cut_site;
    int *done;

    if (NULL == (done = (int *)xcalloc(num_enzymes, sizeof(int)))) {
	return;
    }

    sprintf(cmd, "%s delete all", re_win);
    Tcl_Eval(interp, cmd);

    sprintf(cmd, "%s delete all", names_win);
    Tcl_Eval(interp, cmd);

    t_offset = text_offset;
    y_offset = yoffset;

    seq_len = ruler->end - ruler->start + 1;

    /*printf ("seq_len=%d\n", seq_len);*/
   
    /* for each selected enzyme, display its name and cut sites */
    for (item = 0; item < num_enzymes; item++) {
        offset = yoffset;
	sprintf(cmd,"%s create text 10 %d -text %s -anchor w -fill %s "
		"-font enzyme_font -tag {S re_%d seqid_%d}",
		names_win, t_offset, r_enzyme->renzyme[item]->name, t_colour, 
		item, seq_id);
	Tcl_Eval(interp, cmd);
	sprintf(cmd, "%s create line %d %d %d %d -tag contig -fill %s",
		re_win, ruler->start, y_offset, ruler->end, y_offset, ruler->colour);
	Tcl_Eval(interp, cmd);
	 
	for (i = 0; i < num_matches; i++) {
	    if (item == match[i].enz_name) {	    
		offset = (item * tick->ht) + yoffset;
                cut_site = ruler->start - 1 + match[i].cut_pos1 - 1;
		EdPlotStickMap(interp, re_win, cut_site, 0, offset, 
			       tick->ht, tick->line_width, tick->colour, item,
			       ruler->end - ruler->start + 1, seq_id);
	    }
	}
	/* draw a selection on the re_win, if it needed */
	if (sel != NULL) {
	if (sel->sel_first != 0 && sel->sel_last != 0) {
	    if (sel->name_first != NULL && sel->name_last != NULL) {
		if (!strcmp (sel->name_first, r_enzyme->renzyme[item]->name)) {
		    sprintf (cmd, "%s create rectangle %d %d %d %d -fill green -outline green -tags \"fragment dummy seqid_%d xL_%d xR_%d name1_%s name2_%s\"", 
			     re_win, sel->sel_first+2, offset+2, sel->sel_last-2, offset+tick->ht-2, 
			     seq_id, sel->sel_first,sel->sel_last,sel->name_first, sel->name_last);
		}
	    } else {
		sprintf (cmd, "%s create rectangle %d %d %d %d -fill green -outline green -tags \"dummy\"", 
			 re_win, sel->sel_first, offset, sel->sel_last, offset+tick->ht); 
	    }
	    Tcl_Eval(interp, cmd);
	}
	}
	y_offset += tick->ht;
	t_offset += tick->ht;
    }
    /* draw final line */
    sprintf(cmd, "%s create line %d %d %d %d -tag contig -fill %s",
	    re_win, ruler->start, y_offset, ruler->end, y_offset, ruler->colour);
    Tcl_Eval(interp, cmd);
    
    /* add back selection rectangles */
    if (TCL_ERROR == Tcl_VarEval(interp, "ReSelectRect ", frame, " ",
				 names_win, NULL))
	verror(ERR_WARN, "plot_renz_matches", "%s\n", interp->result);

    world->total->x1 = ruler->start;
    world->total->x2 = ruler->end;
    world->total->y1 = 1;
    world->total->y2 = y_offset;

    memcpy(world->visible, world->total, sizeof(d_box));
    world->visible->y2 = canvas->height;
   
    /* defined in tk_utils/canvas_box.c */
    SetCanvasCoords(interp, world->visible->x1, world->visible->y1, 
		    world->visible->x2, world->visible->y2, canvas);

    draw_single_ruler(interp, ruler, canvas, ruler->start, ruler->end, 1);

    scaleCanvas(interp, win_list, num_wins, "all", world->visible, canvas);
    scrollRegion(interp, win_list, num_wins, world->total, canvas);
   
    /* remove all current zooming info */
	freeZoom(zoom);
    /* add first zoom */
	pushZoom(zoom, world->visible);
    /* defined in tk_utils/canvas_box.c */   
}
Esempio n. 4
0
void QWidget::scroll( int dx, int dy, const QRect& r )
{
    if ( testWState( WState_BlockUpdates ) && !children() )
	return;
    bool valid_rect = r.isValid();
    QRect sr = valid_rect?r:rect();
    int x1, y1, x2, y2, w=sr.width(), h=sr.height();
    if ( dx > 0 ) {
	x1 = sr.x();
	x2 = x1+dx;
	w -= dx;
    } else {
	x2 = sr.x();
	x1 = x2-dx;
	w += dx;
    }
    if ( dy > 0 ) {
	y1 = sr.y();
	y2 = y1+dy;
	h -= dy;
    } else {
	y2 = sr.y();
	y1 = y2-dy;
	h += dy;
    }

    if ( dx == 0 && dy == 0 )
	return;

    QSize s( qt_screen->width(), qt_screen->height() );
    QRegion alloc = valid_rect ? paintableRegion() : allocatedRegion();

    QRegion dAlloc = alloc;
    QPoint td1 = qt_screen->mapToDevice( QPoint(0,0), s );
    QPoint td2 = qt_screen->mapToDevice( QPoint(dx,dy), s );
    dAlloc.translate( td2.x()-td1.x(), td2.y()-td1.y() );

    QRegion scrollRegion( alloc & dAlloc );

    if ( w > 0 && h > 0 ) {
	QGfx * mygfx=graphicsContext( FALSE );
	mygfx->setClipDeviceRegion( scrollRegion );
	mygfx->scroll(x2,y2,w,h,x1,y1);
	delete mygfx;
    }

    paintable_region_dirty = TRUE;

    QPoint gpos = mapToGlobal( QPoint() );

    if ( !valid_rect && children() ) {	// scroll children
	setChildrenAllocatedDirty();
	QPoint pd( dx, dy );
	QObjectListIt it(*children());
	register QObject *object;
	while ( it ) {				// move all children
	    object = it.current();
	    if ( object->isWidgetType() ) {
		QWidget *w = (QWidget *)object;
		QPoint oldp = w->pos();
		QRect  r( w->pos() + pd, w->size() );
		w->crect = r;
		w->updateRequestedRegion( gpos + w->pos() );
		QMoveEvent e( r.topLeft(), oldp );
		QApplication::sendEvent( w, &e );
	    }
	    ++it;
	}
    }

    QSize ds( qt_screen->deviceWidth(), qt_screen->deviceHeight() );
    scrollRegion = qt_screen->mapFromDevice( scrollRegion, ds );
    scrollRegion.translate( -gpos.x(), -gpos.y() );

    QRegion update( sr );
    update -= scrollRegion;
    if ( dx ) {
	int x = x2 == sr.x() ? sr.x()+w : sr.x();
	update |= QRect( x, sr.y(), QABS(dx), sr.height() );
    }
    if ( dy ) {
	int y = y2 == sr.y() ? sr.y()+h : sr.y();
	update |= QRect( sr.x(), y, sr.width(), QABS(dy) );
    }
    repaint( update, !testWFlags(WRepaintNoErase) );
    if ( !valid_rect && children() )
	paint_children( this, update, FALSE );
}