Пример #1
0
void DrawListViewItem(LPDRAWITEMSTRUCT lpDrawItem)
{
    UINT uiFlags;
	BOOL focused;

	focused=TRUE;

	if(lpDrawItem->hwndItem!=0)
	{
		if(GetFocus()!=lpDrawItem->hwndItem)
			focused=FALSE;
	}

	uiFlags=ILD_TRANSPARENT;

    // Check to see if this item is selected
    if ((lpDrawItem->itemState & ODS_SELECTED)&&(focused))
    {
        // Set the text background and foreground colors
        SetTextColor(lpDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
        SetBkColor(lpDrawItem->hDC, GetSysColor(COLOR_HIGHLIGHT));
    
        // Also add the ILD_BLEND50 so the images come out selected
        uiFlags |= ILD_BLEND50;
    }
    else
    {
        // Set the text background and foreground colors to the 
        // standard window colors
        SetTextColor(lpDrawItem->hDC, GetSysColor(COLOR_WINDOWTEXT));
        SetBkColor(lpDrawItem->hDC, GetSysColor(COLOR_WINDOW));
    }

	DrawStuff(lpDrawItem);

	lpDrawItem->rcItem.left=lpDrawItem->rcItem.left+CX_SMICON;

	if(!focused)
		return;

    // If we changed the colors for the selected item, undo it
    if (lpDrawItem->itemState & ODS_SELECTED)
    {
        // Set the text background and foreground colors
        SetTextColor(lpDrawItem->hDC, GetSysColor(COLOR_WINDOWTEXT));
        SetBkColor(lpDrawItem->hDC, GetSysColor(COLOR_WINDOW));
    }

    // If the item is focused, now draw a focus rect around the entire row
    if (lpDrawItem->itemState & ODS_FOCUS)
    {
        // Draw the focus rect
        DrawFocusRect(lpDrawItem->hDC, &(lpDrawItem->rcItem));
    }

    return;
}
Пример #2
0
void
TestWidget::Print
	(
	JEPSPrinter& p
	)
{
	const JRect bounds = GetBounds();

	if (p.WantsPreview())
		{
		JPainter& p1 = p.GetPreviewPainter(bounds);
		DrawStuff(p1);
		}

	if (p.OpenDocument(bounds))
		{
		DrawStuff(p);
		p.CloseDocument();
		}
}
Пример #3
0
void
TestWidget::Print
	(
	JPagePrinter& p
	)
{
	if (!p.OpenDocument())
		{
		return;
		}

	const JCoordinate headerHeight = p.JPainter::GetLineHeight();
	const JCoordinate footerHeight = JRound(1.5 * headerHeight);

	const JString dateStr = JGetTimeStamp();

	JBoolean cancelled = kJFalse;
	for (JIndex i=1; i<=3; i++)
		{
		if (!p.NewPage())
			{
			cancelled = kJTrue;
			break;
			}

		// draw the header

		JRect pageRect = p.GetPageRect();
		p.String(pageRect.left, pageRect.top, "testjx TestWidget");
		p.String(pageRect.left, pageRect.top, dateStr,
				 pageRect.width(), JPainter::kHAlignRight);
		p.LockHeader(headerHeight);

		// draw the footer

		pageRect = p.GetPageRect();
		const JString pageNumberStr = "Page " + JString(i);
		p.String(pageRect.left, pageRect.bottom - footerHeight, pageNumberStr,
				 pageRect.width(), JPainter::kHAlignCenter,
				 footerHeight, JPainter::kVAlignBottom);
		p.LockFooter(footerHeight);

		// draw the page

		DrawStuff(p);
		}

	if (!cancelled)
		{
		p.CloseDocument();
		}
}
void Render()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glLoadIdentity();

	DrawStuff();



	glFlush();
	glutSwapBuffers();

}
Пример #5
0
void
TestWidget::Draw
	(
	JXWindowPainter&	p,
	const JRect&		rect
	)
{
	if (itsImageBuffer != NULL)
		{
		p.JPainter::Image(*itsImageBuffer, itsImageBuffer->GetBounds(), 0,0);
		}
	else
		{
		DrawStuff(p);
		}
}
Пример #6
0
void
PictureView::AllAttached()
{	
	BeginPicture(new BPicture);
	
	DrawStuff(this);

	BPicture *picture = EndPicture();
	if (picture == NULL)
		return;

	BMessage message;
	picture->Archive(&message);
	message.PrintToStream();

	BMallocIO stream;
	
	status_t status = picture->Flatten(&stream);
	delete picture;

	if (status != B_OK)
		printf("Error flattening BPicture: %s\n", strerror(status));
	
	if (status == B_OK) {
		stream.Seek(0, SEEK_SET);
		fPicture = new BPicture();
		status = fPicture->Unflatten(&stream);
		if (status != B_OK) {
			printf("Error unflattening BPicture: %s\n", strerror(status));
			return;
		}
	}

	BMessage message2;
	fPicture->Archive(&message2);
	message2.PrintToStream();
}
void processNormalKeys(unsigned char key, int x, int y)
{
    if (key == 't') {
        key_pressed = MOVETAN;
    }
    else if (key == 'm') {
        key_pressed = MOVEPOS;
    }
    else if (key == 'r') {
        key_pressed = ROTATETAN;
    }
    else if (key == 'n') {
        next_thread();
    } else if (key == 'b') {
        prev_thread();
    } else if (key == 'v') {
        findThreadInIms();
        glutPostRedisplay();
    } else if (key == 'z') {
        /* Step */
        if (thread_vision.hasInit) {
            if (!thread_vision.isDone()) {
                thread_vision.generateNextSetOfHypoths();
                showThread(thread_vision.curr_thread());
            }
            else {
                cout << "Search already finished" << endl;
            }
        }
        else {
            // Taken from start of findThreadInIms();
            thread_vision_searched = true;
            thread_vision.set_max_length(MAX_LENGTH_VIS);
            thread_vision.clear_display();
            updateIms(_start_pt, _start_tan, _end_pt, _end_tan);
            thread_vision.clearStartData();
            thread_vision.addStartData(_start_pt, _start_tan);
            thread_vision.initThreadSearch();
            //cout << "Thread Vision not initialized. Press 'v' to init" << endl;
        }
    } else if (key == 'q') {
        cout << "Flip to prev hypoth" << endl;
        thread_vision.prev_hypoth();
        showThread(thread_vision.curr_thread());
    } else if (key == 'w') {
        cout << "Flip to next hypoth" << endl;
        thread_vision.next_hypoth();
        showThread(thread_vision.curr_thread());
    } else if (key == '1' && key <= '1' + NUM_THREADS_DISPLAY)
    {
    show_threads[((int)key-'1')] = !show_threads[((int)key-'1')];
//    } else if (key == 's') {
//        /* Save current trajectory */
//        cout << "Saving...\n";
//        cout << "Please enter destination file name (without extension): ";
//        char *dstFileName = new char[256];
//        cin >> dstFileName;
//        char *fullPath = new char[256];
//        sprintf(fullPath, "%s%s", "saved_threads/", dstFileName);
//
//        traj_recorder.setFileName(fullPath);
//
//        Thread *newThread = glThreads[currentThread]->getThread();
//        Thread copiedThread(*newThread);
//        traj_recorder.add_thread_to_list(copiedThread);
//        traj_recorder.write_threads_to_file();
    }
    /* Run through all threads, generate guess, save image in test_images */
    else if (key == 'p')
    {
        thread_ind = -1;
        while (true) {
            next_thread();
            DrawStuff();
            cout << endl << "testing thread " << thread_ind << endl << endl;
            start_timer();
            findThreadInIms();
            glutPostRedisplay();
            stop_timer();
            wait(2);
            thread_differences[thread_ind] = thread_difference(glThreads[truthThread]->getThread(), thread_vision.curr_thread());
            generation_times[thread_ind] = seconds_elapsed();
            printf("thread %2d |\t runtime (s): %05.3f | difference: %05.3f\n", thread_ind, generation_times[thread_ind], thread_differences[thread_ind]);
            DrawStuff();
            save_opengl_image();
            if (thread_ind == NUM_THREADS-1) break;
        }
        cout << endl << "-------------------" << endl;
        cout << "PERFORMANCE SUMMARY" << endl;
        cout << "-------------------" << endl;
        for (int i = 1; i < NUM_THREADS; i++)
        {
            printf("thread %2d |\t runtime (s): %05.3f | difference: %05.3f\n", i, generation_times[i], thread_differences[i]);
        }
    }
    else if (key == 27) {
        exit(0);
    }

    lastx_R = x;
    lasty_R = y;

}
Пример #8
0
int main(int argc, char* argv[]) {

    SDL_Window *window;                    // Declare a pointer
    SDL_Rect r;
    SDL_Event event;
    int endLoop = 0;
    SDL_Renderer *renderer;
    SDL_Texture *texture;
    SDL_AudioSpec audioSpec;
    audioSpec.freq = AUDIO_FREQ;
    audioSpec.format = AUDIO_S16LSB;
    audioSpec.channels = AUDIO_CHANNELS;
    audioSpec.samples = WAV_BUFFER_LEN;
    audioSpec.callback = FillAudioBufferCallback2;
    
    waveData.buffer = malloc(WAV_BUFFER_LEN*4);
    printf("waveData.buffer %x\n", waveData.buffer);
    waveData.length = WAV_BUFFER_LEN;
    waveData.curIndex = 0;
    waveData.remain = WAV_BUFFER_LEN;
    FillWaveBuffer();
    FILE* pFile = fopen("data2.csv", "w+");
    for (int i = 0; i<waveData.length; i++)
    {
        fprintf(pFile, "%f\n", waveData.buffer[i]);
    }
    fclose(pFile);
    
    if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
        return (1);
    }

    if (SDL_OpenAudio(&audioSpec, NULL) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't open audio: %s\n", SDL_GetError());
    }
    printAudioStuff(&audioSpec);
    
    SDL_PauseAudio(0);


    // Create an application window with the following settings:
    window = SDL_CreateWindow(
        "An SDL2 window",                  // window title
        SDL_WINDOWPOS_UNDEFINED,           // initial x position
        SDL_WINDOWPOS_UNDEFINED,           // initial y position
        SCREEN_WIDTH,                               // width, in pixels
        SCREEN_HEIGHT,                               // height, in pixels
        SDL_WINDOW_OPENGL                  // flags - see below
    );

    // Check that the window was successfully created
    if (window == NULL) {
        // In the case that the window could not be made...
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }
    r.w = 100;
    r.h = 50;
    renderer = SDL_CreateRenderer(window, -1, 0);
    texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, 1024, 768);
 
    while (1) {
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
            switch(event.type)
            {
                case SDL_KEYDOWN:
                  printf("Keydown\n");
                  endLoop = 1;
                break;
            }
        }

        if (endLoop > 0){
            printf("loop ended\n");
            break;
        }
        
        DrawStuff(renderer, texture);
    }
    // Close and destroy the window
    SDL_DestroyWindow(window);

    // Clean up
    SDL_Quit();
    return 0;
}
Пример #9
0
void wmsysmon_routine(int argc, char **argv)
{
    int		i;
    XEvent		Event;
    FILE		*fp;
    int		xfd;
    struct pollfd	pfd;

    createXBMfromXPM(wmsysmon_mask_bits, wmsysmon_master_xpm, wmsysmon_mask_width, wmsysmon_mask_height);

    xfd = openXwindow(argc, argv, wmsysmon_master_xpm, wmsysmon_mask_bits, wmsysmon_mask_width, wmsysmon_mask_height);
    if (xfd < 0) exit(1);

    pfd.fd = xfd;
    pfd.events = (POLLIN);

    /* init ints */
    bzero(&_last_ints, sizeof(_last_ints));
    bzero(&_ints, sizeof(_ints));
    bzero(&int_peaks, sizeof(int_peaks));


    /* init uptime */
    fp = fopen("/proc/uptime", "r");
    if (fp) {
        if (fscanf(fp, "%ld", &start_time) < 1)
            fprintf(stderr, "warning: could not read uptime\n");
        fclose(fp);
        start_uptime = time(NULL);
    }

    statfp = fopen("/proc/stat", "r");
    memfp = fopen("/proc/meminfo", "r");

    /* here we find tags in /proc/stat & /proc/meminfo and note their
     * lines, for faster lookup throughout execution.
     */
    /* /proc/meminfo */
    for (i = 0; fgets(buf, 1024, memfp); i++) {
        if(strstr(buf, "Mem:")) Mem_l = i;
        else if(strstr(buf, "Swap:")) Swap_l = i;
    }

    /* /proc/stat */
    for (i = 0; fgets(buf, 1024, statfp); i++) {
        if (strstr(buf, "disk_wio")) wio_l = i;
        else if (strstr(buf, "disk_rio")) rio_l = i;
        else if (strstr(buf, "page")) page_l = i;
        else if (strstr(buf, "swap")) swap_l = i;
        else if (strstr(buf, "intr")) intr_l = i;
    }

    while (1) {
        curtime = time(0);

        DrawUptime();
        DrawStuff();
        DrawMem();
        RedrawWindow();

        /* X Events */
        poll(&pfd, 1, update_rate);
        while (XPending(display)) {
            XNextEvent(display, &Event);
            switch (Event.type) {
            case Expose:
                DirtyWindow(Event.xexpose.x,
                            Event.xexpose.y,
                            Event.xexpose.width,
                            Event.xexpose.height);
                break;
            case DestroyNotify:
                XCloseDisplay(display);
                exit(0);
                break;

#ifdef MONDEBUG
            default:
                printf("got: %i\n", Event.type);
#endif
                break;
            }
        }
    }
}
Пример #10
0
void processNormalKeys(unsigned char key, int x, int y)
{
	if (key == 't')
	  key_pressed = MOVETAN;
  else if (key == 'm')
    key_pressed = MOVEPOS;
  else if (key == 'q')
  {
    delete thread;
    thread = new Thread(curvature, torsion, length, 2, positions, tangents);
    thread->minimize_energy_fixedPieces();
    glutPostRedisplay ();
  } else if (key == '1'){
    delete thread;
    length[0] = length[1] = 100.0;
    positions[0](0) = 50.0;
    positions[0](1) = 0.0;
    positions[0](2) = 0.0;
    positions[1](0) = -40.0;
    positions[1](1) = 80.0;
    positions[1](2) = 80.0;

    tangents[0](0) = 0.0;
    tangents[0](1) = 0.0;
    tangents[0](2) = 1.0;
    tangents[1](0) = 1.0;
    tangents[1](1) = 0.0;
    tangents[1](2) = 1.0;
    thread = new Thread(curvature, torsion, length, 2, positions, tangents);
    thread->minimize_energy_fixedPieces();
    glutPostRedisplay ();
  } else if (key == '2') {
    length[0] = length[1] = 150.0;
    positions[0](0) = -10.0;
    positions[0](1) = 140.0;
    positions[0](2) = 40.0;
    positions[1](0) = 70.0;
    positions[1](1) = 0.0;
    positions[1](2) = -20.0;

    tangents[0](0) = 0.0;
    tangents[0](1) = 0.0;
    tangents[0](2) = 1.0;
    tangents[1](0) = 1.0;
    tangents[1](1) = 0.0;
    tangents[1](2) = 0.5;
    thread = new Thread(curvature, torsion, length, 2, positions, tangents);
    thread->minimize_energy_fixedPieces();
    glutPostRedisplay ();
  } else if (key == '3') {
    length[0] = length[1] = 190.0;
    positions[0](0) = 0.0;
    positions[0](1) = 120.0;
    positions[0](2) = -40.0;
    positions[1](0) = 80.0;
    positions[1](1) = -30.0;
    positions[1](2) = 20.0;

    tangents[0](0) = 0.0;
    tangents[0](1) = 1.0;
    tangents[0](2) = 0.0;
    tangents[1](0) = 1.0;
    tangents[1](1) = 0.0;
    tangents[1](2) = -1.0;
    thread = new Thread(curvature, torsion, length, 2, positions, tangents);
    thread->minimize_energy_fixedPieces();
    glutPostRedisplay ();
  } else if (key == ' ') {
    Thread_Motion nextMotion;
    if (traj_reader.get_next_motion(nextMotion))
    {

      Thread* next = nextMotion.applyMotion(thread);
      positions[1] += nextMotion.pos_movement;
      tangents[1] = nextMotion.tan_rotation*tangents[1];
      delete thread;
      thread = next;

      traj_recorder.add_thread_to_list(new Thread(thread));
      DrawStuff();
    }
  } else if (key == 27) {
    if (traj_mode == RECORD)
      traj_recorder.write_motions_to_file();
    if (image_record_mode == SAVE_POINTS)
      traj_recorder.write_threads_to_file();
    exit(0);
  } else if (key=='p') {
    thread->initEnergyParams();
    thread->minimize_energy();
  }

  lastx_R = x;
  lasty_R = y;

}
Пример #11
0
void
OriginalView::Draw(BRect updateRect)
{
	DrawStuff(this);
}
Пример #12
0
//-----------------------------------------------------------------------------
// main application
//-----------------------------------------------------------------------------
int CAVITestApp::Main()
{
	if (!SetVideoMode())
		return 0;

	// load scheme
	if (!vgui::scheme()->LoadSchemeFromFile("resource/BoxRocket.res", "ElementViewer" ))
	{
		Assert( 0 );
	}

	// load the boxrocket localization file
	g_pVGuiLocalize->AddFile( "resource/boxrocket_%language%.txt" );

	// load the base localization file
	g_pVGuiLocalize->AddFile( "Resource/valve_%language%.txt" );
	g_pFullFileSystem->AddSearchPath("platform", "PLATFORM");
	g_pVGuiLocalize->AddFile( "Resource/vgui_%language%.txt");

	// start vgui
	g_pVGui->Start();

	// add our main window
//	vgui::Panel *mainPanel = CreateElementViewerPanel();

	CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
	AVIParams_t params;
	Q_strcpy( params.m_pFileName, "c:\\temp\\out.avi" );
	Q_strcpy( params.m_pPathID, "MOD" );
	pRenderContext->GetWindowSize( params.m_nWidth, params.m_nHeight );
	params.m_nFrameRate = 24;
	params.m_nFrameScale = 1;
	params.m_nNumChannels = 0;

	AVIHandle_t h = g_pAVI->StartAVI( params );
	AVIMaterial_t hAVIMaterial = g_pAVI->CreateAVIMaterial( "avitest", "c:\\temp\\test.avi", "MOD" );

	// run app frame loop
	vgui::VPANEL root = g_pVGuiSurface->GetEmbeddedPanel();
	g_pVGuiSurface->Invalidate( root );

	int imagesize = params.m_nWidth * params.m_nHeight;
	BGR888_t *hp = new BGR888_t[ imagesize ];

	m_flStartTime = Sys_FloatTime();
	m_pMaterial = g_pMaterialSystem->FindMaterial( "debug/debugempty", "app" );
	while ( g_pVGui->IsRunning() )
	{
		AppPumpMessages();
	
		pRenderContext->ClearColor4ub( 76, 88, 68, 255 ); 
		pRenderContext->ClearBuffers( true, true );

		DrawStuff( hAVIMaterial );

		g_pVGui->RunFrame();

		g_pVGuiSurface->PaintTraverse( root );

		// Get Bits from material system
		Rect_t rect;
		rect.x = rect.y = 0;
		rect.width = params.m_nWidth;
		rect.height = params.m_nHeight;

		pRenderContext->ReadPixelsAndStretch( &rect, &rect, (unsigned char*)hp, 
			IMAGE_FORMAT_BGR888, rect.width * sizeof( BGR888_t ) );
		g_pAVI->AppendMovieFrame( h, hp );

		g_pMaterialSystem->SwapBuffers();
	}

	delete[] hp;
	g_pAVI->FinishAVI( h );
	g_pAVI->DestroyAVIMaterial( hAVIMaterial );

//	delete mainPanel;

	return 1;
}