Ejemplo n.º 1
0
bool CursorCtrl::handleMousePress( MouseEvent& e ) 
{ 
	if( e.isLeft() && ( e.isNoKey() || e.isAlt() ) ||
		e.isRight() && e.isShift() )
	{
		Allocation a;
		allocation( a );
		ViewAreaMdl* area = d_view->getArea();
		if( d_do[ DimX ] && d_do[ DimY ] && area->getDimCount() == 2 )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, 
				d_view->getDim( DimY ), y, d_mouseVeto );
		}else if( d_do[ DimX ] && area->inUse( DimX ) )
		{
			PPM x = area->toPpm( e.getX(), a.getLeft(), DimX );
			d_view->getModel()->setPos( d_view->getDim( DimX ), x, d_mouseVeto );
		}else if( d_do[ DimY ] && area->inUse( DimY ) )
		{
			PPM y = area->toPpm( e.getY(), a.getTop(), DimY );
			d_view->getModel()->setPos( d_view->getDim( DimY ), y, d_mouseVeto );
		}
		return d_swallow;	// Der Click soll nicht immer gefressen werden.
	}else
		return false;
}
Ejemplo n.º 2
0
	void draw(Canvas & c, const Allocation & a)
	{
		Lexi::Twips x = a.getLeft() + a.getWidth() / 10;
		c.drawLine( x, a.getTop(), x, a.getBottom(), g_color );	
		Lexi::Twips y = a.getTop() + a.getHeight() / 10;
		c.drawLine( x, y, a.getRight(), y, g_color );	
	}
Ejemplo n.º 3
0
	void execute()
	{
		Allocation rect;
		getAllocation( rect );
		try
		{
			Allocation a = d_model->getAllocation();
			Viewport* v = getHandler()->getViewport();
			assert( v );
			Viewport::pushCursor( Viewport::CurWait );
			if( rect.getWidth() != 0 && rect.getHeight() != 0 )
			{
				v->captureDamage();

				PpmRange rx, ry;
				rx.first = d_model->toPpm( rect.getLeft(), a.getLeft(), DimX );
				rx.second = d_model->toPpm( rect.getRight(), a.getLeft(), DimX );
				ry.first = d_model->toPpm( rect.getTop(), a.getTop(), DimY );
				ry.second = d_model->toPpm( rect.getBottom(), a.getTop(), DimY );
				d_target->setRange( rx, ry );
				v->commitDamage();
			}else
			{
				d_target->centerPoint( d_model->toPpm( rect.getLeft(), a.getLeft(), DimX ),
					d_model->toPpm( rect.getTop(), a.getTop(), DimY ) );
			}
			v->damageAll();
			Viewport::popCursor();
		}catch( ... )
		{
			qDebug( "Exception in _OverviewCmd" );
		}
		Command::execute();
	}
Ejemplo n.º 4
0
void SpinLineView2::draw( Canvas& v, const Allocation& a )
{
	Canvas& c = v;
	ViewAreaMdl* area = getViewArea();
	SpinSpace::Iterator pos, _end = d_model->end();
	SpinSpace::Element e;
	Twips y, x;
	char buf[ 16 ];
	for( pos = d_model->begin(); pos != _end; ++pos )
	{
		d_model->fetch( pos, e );
		if( !e.isGhost() )
		{
			y = area->toTwip( e.d_point[DimY]->getShift( d_model->getSpec() ), 
				a.getTop(), DimY );
			c.drawLine( a.getLeft(), y, a.getRight(), y, d_clr );
			e.d_point[DimY]->getLabel().format( buf, sizeof(buf) );
			QFont f;
			f.setPointSize( s_ps / TwipsPerPoint );
			c.drawText( a.getLeft(), y, buf, &f, d_clr );
			if( d_verti )
			{
				x = area->toTwip( e.d_point[DimX]->getShift( d_model->getSpec() ), 
					a.getLeft(), DimX );
				c.drawLine( x, a.getTop(), x, a.getBottom(), d_clr );
				e.d_point[DimX]->getLabel().format( buf, sizeof(buf) );
				c.drawText( x + g_w, a.getBottom() - g_w, buf, &f, d_clr );
			}
		}
	}
}
Ejemplo n.º 5
0
void ResidueParamView::draw( Canvas& v, const Allocation& a )
{
    if( !d_show )
        return;
    Canvas& c = v;
    ViewAreaMdl* area = getViewArea();
    Twips y;
    QString str;
    DisPar val;
    if( d_resi )
    {
        Root::SymbolSet ss = d_resi->getAllDisPar();
        Root::SymbolSet::const_iterator pos;
        for( pos = ss.begin(); pos != ss.end(); ++pos )
        {
            val = d_resi->getDisPar( (*pos) );
            if( val.isValid() )
            {
                y = area->toTwip( val.d_mean + val.d_dev, a.getTop(), DimY );
                c.drawLine( a.getLeft(), y, a.getRight(), y, d_clr );
                str.sprintf( "+ %s", (*pos).data() );
                QFont f;
                f.setPointSize( s_pointSize / TwipsPerPoint );
                c.drawText( a.getLeft(), y, str, &f, d_clr );

                y = area->toTwip( val.d_mean - val.d_dev, a.getTop(), DimY  );
                c.drawLine( a.getLeft(), y, a.getRight(), y, d_clr );
                str.sprintf( "- %s", (*pos).data() );
                c.drawText( a.getLeft(), y, str, &f, d_clr );
            }
        }
    } else if( d_type )
    {
        const ResidueType::AtomMap& ss = d_type->getAtoms();
        ResidueType::AtomMap::const_iterator pos;
        for( pos = ss.begin(); pos != ss.end(); ++pos )
        {
            val = (*pos).second->getDisPar();
            if( val.isValid() )
            {
                y = area->toTwip( val.d_mean + val.d_dev, a.getTop(), DimY );
                c.drawLine( a.getLeft(), y, a.getRight(), y, d_clr );
                str.sprintf( "+ %s", (*pos).first.data() );
                QFont f;
                f.setPointSize( s_pointSize / TwipsPerPoint );
                c.drawText( a.getLeft(), y, str, &f, d_clr );

                y = area->toTwip( val.d_mean - val.d_dev, a.getTop(), DimY  );
                c.drawLine( a.getLeft(), y, a.getRight(), y, d_clr );
                str.sprintf( "- %s", (*pos).first.data() );
                c.drawText( a.getLeft(), y, str, &f, d_clr );
            }
        }
    }
}
Ejemplo n.º 6
0
	void execute()
	{
		Allocation r;
		getAllocation( r );
		ViewAreaMdl* mdl = d_view->getBuf()->getViewArea();
		Allocation a = mdl->getAllocation();
		PpmCube c;
		c.assign( 2, PpmRange() );
		c[ DimX ].first = mdl->toPpm( r.getLeft(), a.getLeft(), DimX );
		c[ DimX ].second = mdl->toPpm( r.getRight(), a.getLeft(), DimX );
		c[ DimY ].first = mdl->toPpm( r.getTop(), a.getTop(), DimY );
		c[ DimY ].second = mdl->toPpm( r.getBottom(), a.getTop(), DimY );
		d_view->selectPeak( c );
		notifySelection( d_view );
		Command::execute();
	}
Ejemplo n.º 7
0
void OverviewCtrl::draw(Canvas & c, const Allocation & a)
{
	const PpmRange& rx = d_target->getRange( DimX );
	const PpmRange& ry = d_target->getRange( DimY );

	GlyphCommander::draw( c, a );

	ViewAreaMdl* area = d_mdl->getViewArea();

	Coord left = area->toTwip( rx.first, a.getLeft(), DimX );
	Coord right = area->toTwip( rx.second, a.getLeft(), DimX );
	Coord top = area->toTwip( ry.first, a.getTop(), DimY );
	Coord bottom = area->toTwip( ry.second, a.getTop(), DimY );

	c.drawLine( left, top, right, top, g_yellow );	
	c.drawLine( left, top, left, bottom, g_yellow );	
	c.drawLine( left, bottom, right, bottom, g_yellow );	
	c.drawLine( right, top, right, bottom, g_yellow );	
}
Ejemplo n.º 8
0
void Border::invalidate(Viewport & v, const Allocation & a)
{
    Twips t = a.getTop();
    Twips l = a.getLeft();
    Twips h = a.getHeight();
    Twips w = a.getWidth();
    Twips d = d_thickness;

	// Zeichne einen Rahmen um a herum nach innen ausdehnend um thickness.
    v.damage( Allocation( l, t, w, d ) ); // oben
    v.damage( Allocation( l, t, d, h ) ); // links
    v.damage( Allocation( l + w - d, t, d, h ) ); // rechts
    v.damage( Allocation( l, t + h - d, w, d ) ); // unten
}
Ejemplo n.º 9
0
void SpecViewer::draw(Canvas & c, const Allocation & a)
{
	d_area->allocate( a );
	c.clip( a );	// RISK: clip
	Layer::draw( c, a );
	c.popClip();

	// Zeichne nun bei Bedarf das Fokusrechteck
    if( d_focus ) 
	{
		// NOTE: mit dieser Variante verschwindet right/bottom meist
		//		 Irgendwer macht Rundungsfehler, ev. Tile.
		c.drawRect( a.getLeft(), a.getTop(), a.getWidth() - s_off, 
			a.getHeight() - s_off, g_color ); 
    }
}
Ejemplo n.º 10
0
	bool handleMousePress( Viewport& v, const Allocation& a, const MouseEvent& e )
	{
		if( e.isLeft() && d_agent->getCurDim() != -1 )
		{
			d_phi = d_agent->getPhi();
			d_psi = d_agent->getPsi();
			if( e.getX() < ( a.getLeft() + a.getWidth() / 10 ) )
				d_dim = DimY;
			else if( e.getY() < ( a.getTop() + a.getHeight() / 10 ) )
				d_dim = DimX;
			else
				d_dim = DimUndefined;
			v.grab( this );
			return true;
		}else
			return false;
	}
Ejemplo n.º 11
0
bool PointSelectCtrl::handleMousePress( Viewport& v, const Allocation& a, const MouseEvent& e ) 
{ 
	if( e.isLeft() && e.isShift() && !e.isAlt() && !e.isCtrl() )
	{
		return installCommand( new _SelectPointCmd( this, d_view ) ); // && d_swallow; 
	}else if( e.isLeft() && e.isNoKey() )
	{
		ViewAreaMdl* mdl = d_view->getViewArea();
		d_view->selectPeak( mdl->toPpm( e.getX(), a.getLeft(), DimX ), 
			mdl->toPpm( e.getY(), a.getTop(), DimY ) );	
		// Nicht immer true zurück, damit Cursor funktioniert.
		notifySelection( d_view, SpinPointView::PairIdLabelSysOrResi );
		return d_swallow;
	}
	// else
		return false;
}
Ejemplo n.º 12
0
	void execute()
	{
		Allocation rect;
		getAllocation( rect );
		if( rect.getWidth() != 0 && rect.getHeight() != 0 )
		{
			Allocation a = d_model->getAllocation();
			Viewport* p = getController()->getViewport();
			assert( p );
			p->pushCursor( Viewport::CurWait );
			p->captureDamage();
			if( d_do[ DimY ] && d_model->inUse( DimY ) && 
				d_do[ DimX ] && d_model->inUse( DimX )  )
			{
				PpmRange rx;
				rx.first = d_model->toPpm( rect.getLeft(), a.getLeft(), DimX );
				rx.second = d_model->toPpm( rect.getRight(), a.getLeft(), DimX );
				
				PpmRange ry;
				ry.first = d_model->toPpm( rect.getTop(), a.getTop(), DimY );
				ry.second = d_model->toPpm( rect.getBottom(), a.getTop(), DimY );

				d_model->setRange( rx, ry );

			}else if( d_do[ DimX ] && d_model->inUse( DimX ) )
			{
				PpmRange rx;
				rx.first = d_model->toPpm( rect.getLeft(), a.getLeft(), DimX );
				rx.second = d_model->toPpm( rect.getRight(), a.getLeft(), DimX );

				d_model->setRange( DimX, rx );

			}else if( d_do[ DimY ] && d_model->inUse( DimY ) )
			{
				PpmRange ry;
				ry.first = d_model->toPpm( rect.getTop(), a.getTop(), DimY );
				ry.second = d_model->toPpm( rect.getBottom(), a.getTop(), DimY );

				d_model->setRange( DimY, ry );

			}
			p->commitDamage();
			p->popCursor();
			d_model->redraw(p);
		}
		Command::execute();
	}
Ejemplo n.º 13
0
void Border::draw( Canvas& v, const Allocation& a)  
{
	Canvas& c = v;
    Twips t = a.getTop();
    Twips l = a.getLeft();
    Twips h = a.getHeight();
    Twips w = a.getWidth();
    Twips d = d_thickness;

	// Zeichne einen Rahmen um a herum nach innen ausdehnend um thickness.
    c.fillRect( l, t, w, d, d_color ); // oben
    c.fillRect( l, t, d, h, d_color ); // links
    c.fillRect( l + w - d, t, d, h, d_color ); // rechts
    c.fillRect( l, t + h - d, w, d, d_color ); // unten

    Glyph* g = getBody();
    if( g != nil ) 
	{
	    Allocation interior( a );
	    allocateBody( g, d_thickness, interior );
	    g->draw( v, interior);
    }
}
Ejemplo n.º 14
0
void SpecRuler2D::draw( Canvas& v, const Allocation& a)  
{
	if( d_model == 0 )
		return;
	assert( d_model->getDimCount() == 2 );
	Canvas& c = v;
    Twips t = a.getTop();
    Twips l = a.getLeft();
    Twips h = a.getHeight();
    Twips w = a.getWidth();

    Glyph* g = getBody();
    if( g != nil ) 
	{
	    Allocation interior( a );
	    allocateBody( g, interior );
	    g->draw( v, interior);
    }

	// Zeichne die horizontale Legende
	ViewAreaMdl* area = d_model->getViewArea();
	char buf[ 32 ];
	char format[ 8 ];
	Font::BoundingBox box;
	double delta;
	int stellen;
	double start;
	double p;
	Twips x;
	Twips y;

	// Wir zeichnen immer von links nach rechts und oben nach unten.
	if( d_show[ DimX ] )
	{
		const PpmRange& rh = d_model->getBuffer().getScale( DimX ).getRange();
        //const Allotment& ax = a.getAllotment( DimX );
		delta = ::fabs( area->toPpmDiff( 0, d_space[ DimX ], DimX ) );
		start = calc( rh, delta, stellen );

		// Zeichne die horizontale Legende
		::sprintf( format, "%%0.%df", stellen );
		y = t + h - d_height;
		p = start;
		while( rh.contains( p ) )
		{
			x = area->toTwip( p, DimX );
			c.drawLine( x, y, x, y + d_large, d_color, d_thick );
			::sprintf( buf, format, p );
			box.stringBox( d_font, buf, c.getViewport() );
			c.drawText( x - box.getWidth() / 2, y + d_large + box.getAscent(), buf, &d_font, d_color );
			if( rh.isParallel() )
				p += delta;
			else
				p -= delta;
		}
		double count = d_count[ DimX ];
		if( delta > 1.0 )
			count = delta;
		if( rh.isParallel() )
		{
			p = start - delta;
			delta = delta / count;
			while( p < rh.second )
			{
				x = area->toTwip( p, DimX );
				if( p >= rh.first )
					c.drawLine( x, y, x, y + d_small, d_color, d_thick );
				p += delta;
			}
		}else
		{
			p = start + delta;
			delta = delta / count;
			while( p > rh.second )
			{
				x = area->toTwip( p, DimX );
				if( p <= rh.first )
					c.drawLine( x, y, x, y + d_small, d_color, d_thick );
				p -= delta;
			}
		}
	}

	if( d_show[ DimY ] )
	{
		const PpmRange& rv = d_model->getBuffer().getScale( DimY ).getRange();
        //const Allotment& ay = a.getAllotment( DimY );
		delta = ::fabs( area->toPpmDiff( 0, d_space[ DimY ], DimY ) );
		start = calc( rv, delta, stellen );

		// Zeichne die vertikale Legende
		::sprintf( format, "%%0.%df", stellen );

		x = l + w - d_width;
		p = start;
		while( rv.contains( p ) )
		{
			y = area->toTwip( p, DimY );
			c.drawLine( x, y, x + d_large, y, d_color, d_thick );
			::sprintf( buf, format, p );
			box.stringBox( d_font, buf, c.getViewport() );
			c.drawText( x + d_large + 20, y + 
				( box.getAscent() - box.getDescent() ) / 2, 
				buf, &d_font, d_color );
			// c.drawText( x + d_large + 20, y + box.getAscent() / 2, buf, d_font, d_color );
			if( rv.isParallel() )
				p += delta;
			else
				p -= delta;
		}
		double count = d_count[ DimY ];
		if( delta > 1.0 )
			count = delta;
		if( rv.isParallel() )
		{
			p = start - delta;
			delta = delta / count;
			while( p < rv.second )
			{
				y = area->toTwip( p, DimY );
				if( p >= rv.first )
					c.drawLine( x, y, x + d_small, y, d_color, d_thick );
				p += delta;
			}
		}else
		{
			p = start + delta;
			delta = delta / count;
			while( p > rv.second )
			{
				y = area->toTwip( p, DimY );
				if( p <= rv.first )
					c.drawLine( x, y, x + d_small, y, d_color, d_thick );
				p -= delta;
			}
		}
	}
}