示例#1
0
void mainWindow :: askFileName()
{
    fileName = QFileDialog::getOpenFileName(this, "Open data file for the graf generation", "", "      *.dat (*.dat);;      * (*)");
    if (!fileName.isEmpty()) {
        drawGraphic();
    }
}
示例#2
0
文件: func.cpp 项目: tokar1/mech-math
//
// Process the Expose event: draw in the window
//
void MyWindow::onExpose(XEvent& event) {
    // Erase a window
    setForeground(getBackground());
    fillRectangle(m_RWinRect);

    // Draw the coordinate axes
    drawAxes("black", true, "gray");

    // Draw a graph of function
    setForeground("red");
    drawGraphic();

    // Draw a cross on mouse click
    if (clicked) {
        if (mouseButton == Button1)
            setForeground("blue");      // Left button
        else if (mouseButton == Button2)
            setForeground("SeaGreen");  // Middle button
        else if (mouseButton == Button3)
            setForeground("brown");     // Right mouse button
        R2Vector dx(0.2, 0.);
        R2Vector dy(0., 0.2);
        drawLine(lastClick-dx, lastClick+dx);
        drawLine(lastClick-dy, lastClick+dy);
    }
}
示例#3
0
mainWindow :: mainWindow(QApplication *_papp, QStringList *_parg, QWidget *pwg) : QWidget(pwg)
{
    papp = _papp;
    parg = _parg;

    QPushButton *btnFile = new QPushButton("Open another data file (Ctrl+o)");
    QPushButton *btnExit = new QPushButton("Exit (Ctrl+q)");
    QObject::connect(btnExit, SIGNAL(clicked()), papp, SLOT(quit()));
    QObject::connect(btnFile, SIGNAL(clicked()), this, SLOT(askFileName()));
    pscene = new QGraphicsScene(this);
    pscene->setBackgroundBrush(BgCOLOR);
    setAcceptDrops(true);
    pview = new QGraphicsView(pscene);
    QGraphicsTextItem *ptxt = pscene->addText("");
    ptxt -> setDefaultTextColor(TextCOLOR);
    QVBoxLayout *vl = new QVBoxLayout();
    QHBoxLayout *hl = new QHBoxLayout();
    hl->addWidget(btnFile);
    hl->addWidget(btnExit);
    vl->addLayout(hl);
    vl->addWidget(pview);
    setLayout(vl);
    QRect sg = QApplication::desktop()->screenGeometry(-1);
    move((sg.width()-WiWIDTH)/2, (sg.height()-WiHEIGHT)/2);
    setFixedSize(WiWIDTH, WiHEIGHT);
    show();

    TextColorPen = new QPen(QColor(TextCOLOR));
    AxisColorPen = new QPen(QColor(AxisCOLOR));
    GraphColorPen = new QPen (QColor(GraphCOLOR));
    if(!parg->isEmpty() && QFile(parg->at(0)).exists()) {
        fileName = parg->at(0);
        drawGraphic();
    }
}
示例#4
0
文件: Mask3.cpp 项目: nrj123/pvb
static int showData(PARAM *p, DATA *d)
{
char buf[80];
static int   num = 0;
static float val = 0.0f;
static long  mod = 0;
int i;

  drawGraphic    (p,ID_GRAPHIC,d);
  drawGraphic2   (p,ID_GRAPHIC2,d);
  if((mod % 8) == 0)
  {
    num++;
    if(num > 9) num = 0;
    val += 0.1f;
    if(val > 15.0f) val = 0.0f;
    sprintf(buf,"A%d",num);
    pvDisplayNum   (p,ID_LCD1,num);
    pvDisplayFloat (p,ID_LCD2,val);
    pvDisplayStr   (p,ID_LCD3,buf);

    i = num % 3;
    if     (i==0) pvSetImage(p,ID_IMAGE,"homer.bmp.orig");
    else if(i==1) pvSetImage(p,ID_IMAGE,"homer2.bmp");
    else          pvSetImage(p,ID_IMAGE,"homer.bmp.transp");
  }
  mod++;
  if(mod > 1024*1024) mod = 0;
  return 0;
}
示例#5
0
void Console::render() // Render the screen.
{
    clear();
    for (auto it : graphics) {
        drawGraphic(*it);
    }
    const COORD write_pos = { 0, 0 };
    WriteConsoleOutputA(out, buffer, dimensions, write_pos, &sr_dimensions);
    readInput();
}
void LIB_ITEM::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
                     const wxPoint& aOffset, EDA_COLOR_T aColor,
                     GR_DRAWMODE aDrawMode, void* aData,
                     const TRANSFORM& aTransform )
{
    if( InEditMode() )
    {
        // Temporarily disable filling while the item is being edited.
        FILL_T fillMode = m_Fill;
        EDA_COLOR_T color = GetDefaultColor();

        m_Fill = NO_FILL;

#ifndef USE_WX_OVERLAY
        // Erase the old items using the previous attributes.
        if( m_eraseLastDrawItem )
        {
            GRSetDrawMode( aDC, g_XorMode );
            drawEditGraphics( aPanel->GetClipBox(), aDC, color );
            drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData,
                         aTransform );
        }
#endif
        // Calculate the new attributes at the current cursor position.
        calcEdit( aOffset );

        // Draw the items using the new attributes.
        drawEditGraphics( aPanel->GetClipBox(), aDC, color );
        drawGraphic( aPanel, aDC, wxPoint( 0, 0 ), color, g_XorMode, aData,
                     aTransform );

        m_Fill = fillMode;
    }
    else
    {
        drawGraphic( aPanel, aDC, aOffset, aColor, aDrawMode, aData, aTransform );
    }
}
示例#7
0
文件: picture.cpp 项目: PNCG/neuron
void Picture::draw (Canvas* c, Graphic* gs) {
    Iterator i;
    FullGraphic gstemp;
    Transformer ttemp;

    gstemp.SetTransformer(&ttemp);

    for (First(i); !Done(i); Next(i)) {
	Graphic* gr = GetGraphic(i);
	concatGraphic(gr, gr, gs, &gstemp);
	drawGraphic(gr, c, &gstemp);
    }
    gstemp.SetTransformer(nil);	/* to avoid deleting ttemp explicitly */
}
示例#8
0
//--------------------------------------------------------------
void testApp::update(){
	grabber.update();
	pos_x = int(ofGetElapsedTimef()*32);//sin(ofGetElapsedTimef())*32+32;
	player.update();
	
	led->clear(0);
	led->clear(ofColor::black);
	led->renderBuffer.begin();
	
	//draw video as 8px width,height
	//draw line by line horizontally
	//[8 px first row ][8 px second row ]
	drawGraphic();
	led->renderBuffer.end();
	
	led->encode();
	
	serial.writeBytes((unsigned char*)led->txBuffer.data(), led->txBuffer.size());
	
}
示例#9
0
//--------------------------------------------------------------
void testApp::draw(){
	image.draw(0,0);
	ofPushMatrix();
	ofScale(10, 10);
	//draw again to preview
	drawGraphic();
	//	led->encodedBuffer.draw(0,0);
	ofPopMatrix();
	
	ofPushStyle();
	ofNoFill();
	ofSetColor(0, 255, 0);
	ofRect(0,0,numLED*10,10);
	ofPopStyle();
	
	led->draw(ptSize);
	
	//led->draw();
	
}
示例#10
0
void GuiPushButton::renderElement(IRenderer* renderer) {
    const IGraphic* graphicToUse = (pressed) ? graphicPressed : (active ? graphicPressed : graphic);
    drawGraphic(graphicToUse);
}
示例#11
0
void BSplineSelection::draw (Canvas* c, Graphic* gs) {
    drawGraphic(ifillbspline, c, gs);
    drawGraphic(bspline, c, gs);
    drawLeftA(lx0, ly0, lx1, ly1, c, gs);
    drawRightA(rx0, ry0, rx1, ry1, c, gs);
}
示例#12
0
void MyTimerProc ( EventLoopTimerRef inTimer, void *inUserData )
{
    WindowRef window = (WindowRef)inUserData;
    
    static int i = 0;
    static int j = 0;
    static int step = 5;
    GrafPtr curPort;
    CGContextRef context;
    CGrafPtr windowPort = GetWindowPort( window );
        
    GetPort(&curPort);
    SetPort(windowPort);
    
    CreateCGContextForPort( windowPort, &context );
    
    //	Do our drawing in here
    CGContextSetGrayFillColor( context, 0.0, 1.0 );
    CGContextFillRect( context, CGRectMake( 0, 0, 800, 600 ) );

    CGContextSetGrayFillColor( context, 1.0, 1.0 );
    CGContextSetRGBStrokeColor( context, 1.0, 0.0, 0.0, 1.0 );
	CGContextSetLineWidth( context, 5.0 );
    CGContextSetLineCap( context, kCGLineCapRound );
    CGContextSetLineJoin( context, kCGLineJoinRound );
    CGContextSetMiterLimit( context, 5 );

    
    //	Draw each of the 4 transform demos
    //
    //	1.  Translate - move the origin, draw the graphic
    
    //	Place the origin in the llh corner of the upper left quadrant
    CGContextSaveGState( context );
    CGContextTranslateCTM( context, i / 2, i / 2 + 300 );
    CGContextRotateCTM( context, -2.0 * 3.1416 / 8 );
    drawGraphic( context, 0, 0 );
    CGContextRestoreGState( context );


    //	2.  Rotate - move origin, do rotation, draw the graphic
    
    //	Put the origin back into the llh corner of the upper right quadrant
    CGContextSaveGState( context );
    
    if ( j < 1000/2 )
    {
        //	Rotate around left circle
        CGContextTranslateCTM( context, 500, 450 );
        CGContextRotateCTM( context, -j * 3.1416 * 2.0 / 500.0 - 3.1416 );
        CGContextTranslateCTM( context, -100, -20 );
        drawGraphic( context, 0, 0 );
    }
    if ( j >= 1000/2 )
    {
        //	Rotate under bottom half and over top right 1/4
        CGContextTranslateCTM( context, 700, 450 );
        CGContextRotateCTM( context, j * 3.1416 * 2.0 / 500.0 );
        CGContextScaleCTM( context, 1, 1 );
        CGContextTranslateCTM( context, -100, 20 );
        CGContextRotateCTM( context, 3.1416 );
        drawGraphic( context, 0, 0 );
    }

    CGContextRestoreGState( context );
    

    //  3.  Scale - move origin, set scale, draw the graphic
    CGContextSaveGState( context );
    CGContextScaleCTM( context, i * 400.0 / 500.0 / 40.0, i * 300.0 / 500.0 / 40.0 );
    CGContextRotateCTM( context, -3.1416 / 4 );
    drawGraphic( context, 0, 0 );
    CGContextRestoreGState( context );
    

    //  4.  Show the basic graphic
    CGContextTranslateCTM( context, 600, 150 );
    drawGraphic( context, 0, 0 );
    
    CGContextFlush( context );
    CGContextRelease( context );
    
    SetPort ( curPort );
    
    i += step;
    j += abs( step );
    
    if ( i >= 500 )
    {
        step = -step;
    }
    
    if ( i <= 0 )
    {
        step = -step;
        j = 0;
    }
}