예제 #1
0
파일: h.c 프로젝트: pengyuwei/hackathon2014
int init_allwin()
{
    int ret =0;
    int i = 0;
    Win win[4] = {
            // x,y,width,height,name,title,WINDOW*
            {{0, 0, 60, 60}, {0, 0, 0.8, 1}, "L1", "", NULL}, 
            {{100, 0, 20, 20}, {0.8, 0, 0.2, 0.4}, "R1", "", NULL}, 
            {{100, 10, 20, 20}, {0.8, 0.4, 0.2, 0.4}, "R2", "", NULL}, 
            {{100, 15, 20, 20}, {0.8, 0.8, 0.2, 0.2}, "RCMD", "", NULL}, 
            };


    for (i=0; i<4; i++) {
        win[i].win = newwin(win[i].locate.y, win[i].locate.x, 0, 0);
        if (NULL == win) {
            printf("Init failed.\n");
            ret = -1;
            break;
        }
        if (strcmp(win[i].name, "L1") == 0) {
            scrollok(win[i].win, TRUE);
        } else {
            clearok(win[i].win, TRUE);
        }
        windows.insert(Windows::value_type(win[i].name, win[i]));

        Win frame;
        memcpy(&frame, &win[i], sizeof(Win));
        frame.win = newwin(win[i].locate.y, win[i].locate.x, 0, 0);
        frames.insert(Windows::value_type(win[i].name, frame));
    }
 
    return ret;
}
예제 #2
0
파일: Viewer.cpp 프로젝트: tachen/osg
bool Viewer::checkEvents()
{
    // check events from any attached sources
    for(Devices::iterator eitr = _eventSources.begin();
        eitr != _eventSources.end();
        ++eitr)
    {
        osgGA::Device* es = eitr->get();
        if (es->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
        {
            if (es->checkEvents()) return true;
        }

    }

    // get events from all windows attached to Viewer.
    Windows windows;
    getWindows(windows);
    for(Windows::iterator witr = windows.begin();
        witr != windows.end();
        ++witr)
    {
        if ((*witr)->checkEvents()) return true;
    }

    return false;
}
예제 #3
0
파일: h.c 프로젝트: pengyuwei/hackathon2014
Win *get_win(const char *name)
{
    Win *win = NULL;
    Windows::iterator iter;

    iter = windows.find(name);
    if (iter == windows.end()) {
        return NULL;
    }
    win = &iter->second;
   
    return win;
}
예제 #4
0
파일: ViewerBase.cpp 프로젝트: 3dcl/osg
void ViewerBase::getWindows(Windows& windows, bool onlyValid)
{
    windows.clear();

    Contexts contexts;
    getContexts(contexts, onlyValid);

    for(Contexts::iterator itr = contexts.begin();
        itr != contexts.end();
        ++itr)
    {
        osgViewer::GraphicsWindow* gw = dynamic_cast<osgViewer::GraphicsWindow*>(*itr);
        if (gw) windows.push_back(gw);
    }
}
ProduitListe::ProduitListe(QWidget *parent, int iC, int iP) :
    QWidget(parent),
    ui(new Ui::ProduitListe),
    PageInterface(parent, iC,iP)
{
    ui->setupUi(this);

    Windows *w = (Windows*)parent;//récupérer l'objet windows pour avoir accées a la liste des produits
    ui->produitsListe->addItem("Choisissez...");
    for(int i=0; i < w->getData()->getListeProduit().size();i++){

        QString champ = w->getData()->getListeProduit().value(i).getName();
        ui->produitsListe->addItem(champ);
    }

    signalAndSlot();

}
예제 #6
0
파일: h.c 프로젝트: pengyuwei/hackathon2014
int main(int argc, char *argv[])
{
    int ret = 0;

    setlocale(LC_ALL,"");

    init_keyboard();
    initscr();

    init_allwin();
    resize_allwin();

    signal(SIGWINCH, sig_winch);

    work_thread_start();
    main_loop();

    close_keyboard();
    cleanup();

    for (int i = 30; i<129;i++) {
        printf("%d %c\t", i, i);
    }
    printf("\n");

    struct winsize size;
    Win *win = NULL;
    ioctl(STDIN_FILENO,TIOCGWINSZ,&size);
    Windows::iterator iter;
    for (iter=windows.begin(); iter!=windows.end(); iter++) {
        win = &iter->second;
        printf("%s @(%d,%d), (%dx%d) %s\n", win->name,
                win->locate.x, win->locate.y,
                win->locate.w, win->locate.h,
                win->title);
    }
    printf("SCREEN: %d x %d\n", size.ws_col, size.ws_row);

    return ret;
}
bool CompositeViewer::checkEvents()
{
    for(RefViews::iterator itr = _views.begin();
            itr != _views.end();
            ++itr)
    {
        osgViewer::View* view = itr->get();
        if (view)
        {
            // check events from any attached sources
            for(View::Devices::iterator eitr = view->getDevices().begin();
                    eitr != view->getDevices().end();
                    ++eitr)
            {
                osgGA::Device* es = eitr->get();
                if (es->getCapabilities() & osgGA::Device::RECEIVE_EVENTS)
                {
                    if (es->checkEvents()) return true;
                }

            }
        }
    }

    // get events from all windows attached to Viewer.
    Windows windows;
    getWindows(windows);
    for(Windows::iterator witr = windows.begin();
            witr != windows.end();
            ++witr)
    {
        if ((*witr)->checkEvents()) return true;
    }

    return false;
}
int main(int argc, char **argv) {
    int diff, old_score, new_score;
    struct timeval start;
    gettimeofday(&start,NULL);
    Shapes s;
    s.readFile(argc, argv);
    s.buildConflictArray();
    Graphs g;
    g.buildConflictGraph(s.getShapes());
    s.findBoundingBox();
    Windows w;
    w.createWindow();
    w.countArea(s.getShapes(), g.getGraphs());
    g.countTotalColorDiff();

    Calculate c;
    //c.printResult(s.getShapes(), g.getGraphs(), w.getWindows(), argc, argv);
    //printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));

    //std::vector<Graph> &gg = g.getGraphs();
    //c.changeGraphColor(w.getWindows(), g.getGraphs()[0]);
    //c.changeGraphColor(w.getWindows(), g.getGraphs()[0]);
    //c.changeGraphColor(w.getWindows(), g.getGraphs()[2]);
    c.initial_total_color_diff(&g, g.getGraphs(), w.getWindows());
    //c.printResult(s.getShapes(), g.getGraphs(), w.getWindows(), argc, argv);
    //printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));

    for (int group_id = 0; group_id < c.group_size; group_id++) {
        c.iterative_sol(g.getGraphs(), w.getWindows(), group_id);
    }
    //printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));
    c.simulatedAnnealing(g.getGraphs(), w.getWindows(), start, argv[1]);

    for (int group_id = 0; group_id < c.group_size; group_id++) {
        c.iterative_sol(g.getGraphs(), w.getWindows(), group_id);
    }

    c.printResult(s.getShapes(), g.getGraphs(), w.getWindows(), argc, argv);
    printf("real score : %.2f\n\n\n", c.real_score(w.getWindows()));
    return 0;
}
예제 #9
0
BOOL InsertListViewItems(HWND hwndListView)
{
	ListView_DeleteAllItems(hwndListView);
	ListView_SetItemCount(hwndListView, g_windows.size());
	return TRUE;
}
예제 #10
0
파일: h.c 프로젝트: pengyuwei/hackathon2014
void resize_allwin()
{
    Win *win = NULL;
    Win *frame = NULL;
    Windows::iterator iter;
    struct winsize size;
    // char msg[64] = {0};
    int ret = 0;

    ioctl(STDIN_FILENO,TIOCGWINSZ,&size);

    for (iter=windows.begin(); iter!=windows.end(); iter++) {
        win = &iter->second;
        frame = get_frame(win->name);
        if (NULL == frame) {
            cleanup();
            exit(0);
        }
        // set new size
        frame->locate.x = size.ws_col * frame->scale.x;
        frame->locate.y = size.ws_row * frame->scale.y;
        frame->locate.w = size.ws_col * frame->scale.w;
        frame->locate.h = size.ws_row * frame->scale.h;

        win->locate.x = frame->locate.x + 1;
        win->locate.y = frame->locate.y + 1;
        win->locate.w = frame->locate.w - 2;
        win->locate.h = frame->locate.h - 2;

        if (iter->first.compare("RCMD") == 0) {
            win->locate.h = 4;
        }

        // resize 
        ret = wresize(frame->win, frame->locate.h, frame->locate.w);
        ret = wresize(win->win, win->locate.h, win->locate.w);
        if (ERR == ret) {
            printf("wresize failed:%s %d,%d\n", win->name, win->locate.x, win->locate.y);
        }

        // move
        ret = mvwin(frame->win, frame->locate.y, frame->locate.x);
        if (ERR == ret) {
            cleanup();
            printf("mvwin frame failed:%s %d,%d\n", frame->name, frame->locate.y, frame->locate.x);
            printf("\t %d x %d\n", frame->locate.w, frame->locate.h);
            exit(0);
        }
        ret = mvwin(win->win, win->locate.y, win->locate.x);
        if (ERR == ret) {
            cleanup();
            printf("SCREEN=%d x %d\n", COLS, LINES);
            printf("mvwin failed:%s %d,%d\n", win->name, win->locate.x, win->locate.y);
            printf("\t %d x %d\n", win->locate.w, win->locate.h);
            printf("frame %d,%d %d x %d\n", frame->locate.x, frame->locate.y, frame->locate.w, frame->locate.h);
            exit(0);
        }

        //echo();
        //touchwin(win->win);
        //attron(A_REVERSE);
        box(frame->win, '|', '-');
        //mvaddstr(2, 2,win->name);
        // mvwaddstr(win->win, 1, 1, win->name);
        //sprintf(msg, "%d,%d", win->locate.y, win->locate.x);
        //mvwaddstr(win->win, 2, 1, msg);
        //attroff(A_REVERSE);
        //move(1, 1);
        //waddstr(win->win, win->name);
        wrefresh(frame->win);
        wrefresh(win->win);
  //      }
    }
}