NucleotideDisplay::NucleotideDisplay(UiVariables* gui, GLWidget* gl)
{	
	glWidget = gl;
	ui = gui;
	string* seq = new string("AATCGATCGTACGCTACGATCGCTACGCAGCTAGGACGGATTAATCGATCGTACGCTACGATCGCTACGCAGCTAGGACGGATTAATCGATCGTACGCTACGATCGCTACGCAGCTAGGACGGATTAATCGATCGTACGCTACGATCGCTACGCAGCTAGGACGGATT");	
	sequence = seq;
	
	textureBuffer = NULL;
	settingsTab = NULL;
	toggleButton = NULL;	
	hidden = false;
	
	nucleotide_start = 1;
	scale = 1;
	changeWidth(ui->getWidth());
	changeSize(ui->getSize());
	upToDate = false;
	
	invert = false;
	C = true;
	G = true;
	A = true;
	T = true;
	
	actionLabel = string("Nucleotide Display");
	actionTooltip = string("Nucleotides as Colors");
	actionData = actionLabel; 
	display_object = 0;
}
Beispiel #2
0
Color2DBox::Color2DBox(float x, float y, float width, float height):
	MirrorContainer(),
	quadVBO(ZERO_GL),
	quadIBO(ZERO_GL)
{
	changeSize(x, y, width, height);
};
Beispiel #3
0
void MainWindow::displayStudentTable(QSqlRelationalTableModel *model)
{
    fillFaculties();
    ui->useFilterButton->setFocus();
    changeSize(true);
    if(model->isDirty())
    {
        model->submitAll();
    }
    model->setTable("student");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);

    model->setRelation(2, QSqlRelation("faculty", "id", "name"));
    model->setRelation(3, QSqlRelation("groups", "id", "name"));

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Ім'я"));
    model->setHeaderData(2, Qt::Horizontal, QObject::tr("Факультет"));
    model->setHeaderData(3, Qt::Horizontal, QObject::tr("Група"));
    model->setHeaderData(4, Qt::Horizontal, QObject::tr("Адреса"));
    model->select();
    for(int i=0; i< model->columnCount(); i++)
    {
        ui->tableView->resizeColumnsToContents();
    }
}
Beispiel #4
0
///Set the current tip, hide the previous one, if any
void TipManager::setCurrentTip(Tip* tip)
{
   m_pCurrentTip = tip;
   m_pAnim.setTip(m_pCurrentTip);
   emit currentTipChanged(tip);
   m_pAnim.start(true);
   changeSize(true);
}
Beispiel #5
0
bool TipManager::eventFilter(QObject *obj, QEvent *event)
{
   Q_UNUSED(obj);
   if (event->type() == QEvent::Resize) {
      changeSize();
   }
   return false;
}
Beispiel #6
0
///Set the top margin
void TipManager::setTopMargin(int margin)
{
   const bool changed = !(m_TopMargin == margin);
   m_TopMargin = margin;
   if (changed) {
      changeSize(true);
      reload();
   }
}
Beispiel #7
0
///Set the bottom margin
void TipManager::setBottomMargin(int margin)
{
   bool changed = !(m_BottomMargin == margin);
   m_BottomMargin = margin;
   if (changed) {
      changeSize(false);
   }
   reload();
}
void
AnimatedSplitter::onSizeChanged( const QSize& size )
{
    AnimatedWidget* w = (AnimatedWidget*)(sender());
    if ( indexOf( w ) > 0 )
        changeSize( w, size );
    else
        Q_ASSERT( false );
}
Beispiel #9
0
CardsListView::CardsListView(QWidget *parent)
    : QWidget(parent)
{
    auto hbox = new QHBoxLayout;
    auto vbox = new QVBoxLayout;

    cl = new CardsList(nullptr);
    auto sb = new QScrollBar;

    auto toolbar = new QToolBar;
    undoAction = new QAction(this);
    undoAction->setToolTip(config->getStr("action", "undo", ""));
    undoAction->setIcon(QIcon(":/icons/left.png"));
    redoAction = new QAction(this);
    redoAction->setToolTip(config->getStr("action", "redo", ""));
    redoAction->setIcon(QIcon(":/icons/right.png"));

    toolbar->addAction(undoAction);
    toolbar->addAction(redoAction);

    auto label = new DeckSizeLabel(config->getStr("label", "number", "数目"));
    label->setAlignment(Qt::AlignVCenter |  Qt::AlignRight);

    toolbar->addSeparator();
    auto spacer = new QWidget;
    spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    toolbar->addWidget(spacer);
    toolbar->addWidget(label);

    cl->setScrollBar(sb);

    connect(cl, &CardsList::sizeChanged, label, &DeckSizeLabel::changeSize);
    connect(undoAction, &QAction::triggered, this, &CardsListView::undo);
    connect(redoAction, &QAction::triggered, this, &CardsListView::redo);

    toolbar->setStyleSheet("QToolTip{color: black; font-size: 12px}");
    if(config->bg)
    {
        cl->setStyleSheet("QWidget{color: white; font-size: 15px}");
        label->setStyleSheet("QLabel{color: white; font-size: 15px}");
    }
    else
    {
        cl->setStyleSheet("QWidget{font-size: 15px}");
        label->setStyleSheet("QLabel{color: black; font-size: 15px}");
    }

    hbox->addWidget(cl);
    hbox->addWidget(sb);
    vbox->addWidget(toolbar);
    vbox->addLayout(hbox, 1);
    setLayout(vbox);
    label->changeSize(0);
    updateButtons();
}
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: about(); break;
        case 1: changeStyle((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 2: changeSize((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 3: changeSize(); break;
        case 4: changeIcon(); break;
        case 5: addImages(); break;
        case 6: removeAllImages(); break;
        default: ;
        }
        _id -= 7;
    }
    return _id;
}
vector<Coord> Figure::updLength(Figure *a, bool update)
{
    vector <Coord> vect;

    if(update)
        vect=changeSize(a);
    else
        vect=buildVectors(a);

    return vect;

}
Beispiel #12
0
///Constructor
TipManager::TipManager(QAbstractItemView* parent):QObject(parent),m_pParent(parent),
   m_BottomMargin(0),m_TopMargin(0),m_pAnim(this),m_pCurrentTip(nullptr)
{
   m_CurrentFrame = {QPoint(0,0),QRect(),0};
   parent->installEventFilter(this);
   parent->setProperty("tipManager",QVariant::fromValue(qobject_cast<TipManager*>(this)));
   changeSize();
   reload();

   connect(&m_pAnim,SIGNAL(animationStep(FrameDescription)),this,SLOT(animationStep(FrameDescription)));
   connect(&m_pAnim,SIGNAL(transitionStarted(QAbstractAnimation::Direction,QAbstractAnimation::State)),this,
         SLOT(slotTransitionStarted(QAbstractAnimation::Direction,QAbstractAnimation::State)));
}
Beispiel #13
0
///Constructor
TipManager::TipManager(QAbstractItemView* parent):QObject(parent),m_pParent(parent),
   m_pAnim(this)
{
   m_CurrentFrame = {QPoint(0,0),QRect(),0};
   parent->installEventFilter(this);
   parent->setProperty("tipManager",QVariant::fromValue(qobject_cast<TipManager*>(this)));
   changeSize();
   reload();

   connect(&m_pAnim,&TipAnimationWrapper::animationStep,this,&TipManager::animationStep);
   connect(&m_pAnim,&TipAnimationWrapper::transitionStarted,this,
         &TipManager::slotTransitionStarted);
}
Beispiel #14
0
void MainWindow::displayDoctorsTable(QSqlRelationalTableModel *model)
{
    changeSize(false);
    if(model->isDirty())
    {
        model->submitAll();
    }
    model->setTable("doctor");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);
    model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Ім'я"));
    model->select();
}
Beispiel #15
0
bool TipManager::hideCurrentTip(bool skipAnimation)
{
   if (skipAnimation) {
      m_pCurrentTip = nullptr;
      m_pAnim.setTip(nullptr);
      emit currentTipChanged(nullptr);
      emit transitionStarted(QAbstractAnimation::Backward,QAbstractAnimation::Stopped);
   }
   else if (m_pCurrentTip) {
      m_pAnim.setTip(m_pCurrentTip);
      changeSize(false);
      m_pAnim.start(false);
      return false;
   }
   return true;
}
Beispiel #16
0
void
AnimatedSplitter::onResizeRequest( const QPoint& delta )
{
    AnimatedWidget* w = (AnimatedWidget*)(sender());
    if ( indexOf( w ) > 0 )
    {
        int newheight = w->height() + delta.y();
        if ( newheight <= w->hiddenSize().height() )
        {
            w->hide();
        }
        else
            changeSize( w, QSize( w->width(), newheight ) );
    }
    else
        Q_ASSERT( false );
}
Beispiel #17
0
int main(void){
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	static char string[1000] = "";	
	char cmd[1000] = "";
	int exitCheck = 0;
	changeSize();
	printIntro(string);
	SetConsoleTextAttribute(hConsole, 0);
	system("cls");
	printMainString(string, 1);
	printInputField(string);
	while (!exitCheck){
		SetConsoleTextAttribute(hConsole, 14);
		fgets(cmd, 999, stdin);
		if ((strcmp(cmd, "") != 0)) exitCheck = executeCmd(cmd, string, 7 + strlen(string) / 74);
		cleanStr(cmd);
	}
	return 0;
}
Beispiel #18
0
void MainWindow::displayGroupsTable(QSqlRelationalTableModel *model)
{
    changeSize(false);
    if(model->isDirty())
    {
        model->submitAll();
    }
    model->setTable("groups");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);

    //TODO HERE YOU HAVE TO SET ALL EDIT TRIGGERS DEPENDING ON TABLE SELECTED BUT NO HERE IN YOR PROGRAM
    //ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);


    model->setRelation(2, QSqlRelation("faculty", "id", "name"));

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Шифр"));
    model->setHeaderData(2, Qt::Horizontal, QObject::tr("Факультет"));
    model->select();
}
Beispiel #19
0
void MainWindow::displayVisitTable(QSqlRelationalTableModel *model)
{
    changeSize(false);
    if(model->isDirty())
    {
       model->submitAll();
    }
    model->setTable("visit");
    model->setEditStrategy(QSqlTableModel::OnManualSubmit);

    model->setRelation(1, QSqlRelation("student", "id", "name"));
    model->setRelation(3, QSqlRelation("diagnosis", "id", "name"));
    model->setRelation(4, QSqlRelation("doctor", "id", "name"));

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("Студент"));
    model->setHeaderData(2, Qt::Horizontal, QObject::tr("Дата"));
    model->setHeaderData(3, Qt::Horizontal, QObject::tr("Діагноз"));
    model->setHeaderData(4, Qt::Horizontal, QObject::tr("Лікар"));
    model->select();
}
Beispiel #20
0
bool cWindow::Create(
     HWND parent,				
     LPCWSTR text,				
     DWORD exstyle,DWORD style,	
     int x,int y,int w,int h,	
     UINT id
     )
   {
	 _hInstance=GetModuleHandle(0);
     
     WNDCLASSEX wndc;
     wndc.lpszClassName=L"MyWnd";
     wndc.cbSize=sizeof(WNDCLASSEX);
     wndc.lpfnWndProc=WNDPROC(_WndProc);
     wndc.cbClsExtra=0;
     wndc.cbWndExtra=0;
	 wndc.hbrBackground=HBRUSH(BLACK_PEN);
     wndc.hInstance=_hInstance;
     wndc.hCursor=LoadCursor(0,IDC_CROSS);
     wndc.style=CS_HREDRAW|CS_VREDRAW;
     wndc.hIcon=0;
     wndc.hIconSm=0;
     wndc.lpszMenuName=0;
     RegisterClassEx(&wndc);


	 //CreateWindow
     _hwnd=CreateWindowEx(exstyle,wndc.lpszClassName,text,
       style|WS_CLIPCHILDREN,
       x,y,w,h,parent,HMENU(id),
       _hInstance,
       this
       );

	changeSize();
    if(!_hwnd) return false;
    return true;
   }
Beispiel #21
0
/**
 * Loads and processes a specified true type font buffer to a specific point size.
 *
 * This routine takes a precompiled true type font buffer and loads the necessary processed data into memory. This routine should be called before drawText will succeed.
 *
 * @param fontPath		filename with path to load font from file in memory.
 * @param fontBuffer	A pointer in memory to a precompiled true type font buffer.
 * @param bufferSize	Size of the true type font buffer in bytes.
 * @param pointSize	The desired point size this wrapper's configured font face.
 * @param cacheAll	Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false.
 */
uint16_t FreeTypeGX::loadFont(const char* fontPath, const uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) {
    this->unloadFont();
    this->ftPointSize_v = this->ftPointSize_h = 0;
    struct stat st;

    if (fontPath && (stat(fontPath, &st)==0)) {
        FILE *fontfile = fopen(fontPath, "rb");
        if (fontfile) {
            FT_Long ftFace_fromFile_Size;

            fseek(fontfile, 0, SEEK_END);
            ftFace_fromFile_Size = ftell(fontfile);
            fseek(fontfile, 0, SEEK_SET);
            ftFace_fromFile = (uint8_t*)malloc(ftFace_fromFile_Size);
            if (ftFace_fromFile != NULL) {
                fread(ftFace_fromFile, 1, ftFace_fromFile_Size, fontfile);
                FT_New_Memory_Face(this->ftLibrary, ftFace_fromFile, ftFace_fromFile_Size, 0, &this->ftFace);
            }
            fclose(fontfile);
        }
    }
    if (ftFace_fromFile == NULL)
        FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace);

    if (pointSize > 0)
        changeSize(pointSize);

    this->ftSlot = this->ftFace->glyph;
    this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace);

    if (cacheAll) {
        return this->cacheGlyphDataComplete();
    }

    return 0;
}
Beispiel #22
0
void FramelessWin2::mouseMoveEvent(QMouseEvent *evt)
{
    QPoint globalPos = evt->globalPos();
    QRect rect = this->rect();
    QPoint tl = mapToGlobal(rect.topLeft());
    QPoint tb  = mapToGlobal(rect.bottomRight());
    QRect rmove(tl,tb);
    if ( m_pressed )
    {
        if (m_direct == UNKOWN )
        {
            move(evt->globalPos()-m_movePoint);
        }
        else
        {
            changeSize(rmove,globalPos);
            setGeometry(rmove);
        }
    }
    else
    {
        GetMoveDirect(globalPos);
    }
}
Beispiel #23
0
  const SUCCESS Events::handleEvent(const SDL_Event * const Event)
  {
    switch(Event->type)
    {  //newline brackets implemented since this is a lot of nesting
    case SDL_WINDOWEVENT: ///Some sort of input or output gained or lost
      {
        const Uint8 &winID = Event->window.windowID;
        switch(Event->window.event) 
        {
        case SDL_WINDOWEVENT_ENTER:   ///Mouse message handling gained or lost
          return mouseEnter(winID);
          
        case SDL_WINDOWEVENT_LEAVE:   ///General input message handling gained or lost
          return mouseLeave(winID);

        case SDL_WINDOWEVENT_MINIMIZED:   ///Output to the screen at all gained or lost
          return minimized(winID);
          
        case SDL_WINDOWEVENT_RESTORED:
          return restored(winID);
          
        case SDL_WINDOWEVENT_MAXIMIZED:
          return maximized(winID);
          
        case SDL_WINDOWEVENT_SHOWN:
          return shown(winID);
          
        case SDL_WINDOWEVENT_HIDDEN:
          return hidden(winID);
          
        case SDL_WINDOWEVENT_EXPOSED:
          return exposed(winID);
          
        case SDL_WINDOWEVENT_FOCUS_GAINED:
          return keyboardFocusGain(winID);
          
        case SDL_WINDOWEVENT_FOCUS_LOST:
          return keyboardFocusLost(winID);
          
        case SDL_WINDOWEVENT_SIZE_CHANGED:
            return changeSize(winID);
            
        case SDL_WINDOWEVENT_RESIZED:
          return resized(winID, Dimensions<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_MOVED:
          return moved(winID, Point<int>(Event->window.data1, Event->window.data2));
          
        case SDL_WINDOWEVENT_CLOSE:
          return windowExited(winID);
          
        default:   ///For some reason there is an unknown window event
          return FAILED;
        }
        break;
      }
    case SDL_KEYDOWN:
      {
        if(Event->key.repeat)
        {
          return keyHeld(Event->key.windowID, Event->key.keysym);
        }
        else
        {
          return keyPressed(Event->key.windowID, Event->key.keysym);
        }
        break;
      }
    case SDL_KEYUP:
        return keyReleased(Event->key.windowID, Event->key.keysym);
        
    case SDL_TEXTINPUT:
        return textInput(Event->text.windowID, Event->text.text);
        
    case SDL_TEXTEDITING:
        return textEdit(Event->edit.windowID, Event->edit.text, Event->edit.start, Event->edit.length);
        
    case SDL_MOUSEMOTION:
      return mouseMove(Event->motion.windowID, Event->motion.which,
                       Delta<Point<int> >(Point<int>(Event->motion.xrel, Event->motion.yrel), 
                                          Point<int>(Event->motion.x, Event->motion.y)),
                       bitset<N_MOUSE_BUTTONS>(Event->motion.state));
                       
    case SDL_MOUSEBUTTONDOWN:
      return mouseButtonPressed(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                Point<int>(Event->button.x, Event->button.y));
      
    case SDL_MOUSEBUTTONUP:
        return mouseButtonReleased(Event->button.windowID, Event->button.which, Event->button.button, Event->button.clicks,
                                  Point<int>(Event->button.x, Event->button.y));
     
    case SDL_MOUSEWHEEL:
        return mouseWheel(Event->wheel.windowID, Event->wheel.which, Point<int>(Event->wheel.x, Event->wheel.y));
        
    case SDL_JOYAXISMOTION:
      return joyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value);
    
    case SDL_JOYBUTTONDOWN:
      return joyButtonPressed(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYBUTTONUP:
      return joyButtonReleased(Event->jbutton.which, Event->jbutton.button);
      
    case SDL_JOYHATMOTION:
      return joyHatChange(Event->jhat.which, Event->jhat.hat, Event->jhat.value);
        
    case SDL_JOYBALLMOTION:
      return joyBallMove(Event->jball.which, Event->jball.ball, Point<int>(Event->jball.xrel, Event->jball.yrel));
      
    case SDL_DROPFILE:
    {
      const SUCCESS ret = droppedFile(Event->drop.file);
      SDL_free(Event->drop.file);
      return ret;
    }
      
    case SDL_SYSWMEVENT:
      return unhandledSystemEvent(Event->syswm.msg);
     
    case SDL_QUIT:
      return appExited();
        
    case SDL_USEREVENT:
    default:
      {
        return userEvent(Event->user.windowID, Event->user.code, Event->user.data1, Event->user.data2);
      }
    }

    return FAILED;
  }
Beispiel #24
0
void SDesktop::launch(){
    play = true;
    changeSize();
    XMapWindow(dpy, win);

    struct timeval tp;
    gettimeofday(&tp, NULL);
    long int last = tp.tv_sec * 1000 + tp.tv_usec / 1000;
    long int curr;

    while(play){
        if( XPending(dpy) == 0) {
            gettimeofday(&tp, NULL);
            curr = tp.tv_sec * 1000 + tp.tv_usec / 1000;
            if(curr - last >= 1000/60){
                draw();
                last = curr;
            }
            continue;
        }
        XNextEvent(dpy, &evnt);
        switch(evnt.type){
            case Expose:
                //draw();
            break;
            case MotionNotify:
                pointer->setCoor(evnt.xmotion.x-width/2.0, height/2.0-evnt.xmotion.y, pointer->getZ());
                //draw();
            break;
            case ButtonPress:
                switch(evnt.xbutton.button){
                    case 1:
                        for(int i=0; i<MAX; i++){
                            if(widgets[i]){
                                if(widgets[i]->mouseInArea(pointer)){
                                    if(strcmp(widgets[i]->type(),"Frame") == 0){
                                        Widget* focused = ((Frame*)widgets[i])->widgetFocused(pointer);
                                        if(focused){
                                            ((Button*)(focused))->setActive(true);
                                            focused->action(focused);
                                            //draw();
                                        }
                                    }
                                }
                            }
                        }
                    break;
                    case 4:
                        pointer->setCoor(pointer->getX(), pointer->getY(), pointer->getZ()+200);//100
                        //draw();
                    break;
                    case 5:
                        pointer->setCoor(pointer->getX(), pointer->getY(), pointer->getZ()-200);//100
                        //draw();
                    break;
                }
            break;
            case KeyPress:
                switch(evnt.xkey.keycode){
                    case 9:
                        XCloseDisplay(dpy);
                        play = false;
                    break;
                    case 23:
                        //draw();
                    break;
                    default:
                        std::cout << evnt.xkey.keycode << std::endl;
                    break;
                }
            break;
        }
    }
}
Beispiel #25
0
// ref effetv video.c function video_init()
int SwV4LDevice::VDopen(char * device, tBoxSize *newSize)
{
	int maxc;
	fprintf(stderr, "[V4L]::VDopen device '%s'\n", device);
	
	if(device == NULL){
    	videodevice = new char [ strlen(DEFAULT_VIDEO_DEVICE) +1];
		strcpy(videodevice, DEFAULT_VIDEO_DEVICE);
	}
	else {
		videodevice = new char [ strlen(device) +1];
		strcpy(videodevice, device);
	}

    if(v4l_open(videodevice)) {
		
		return -1;
	}
    v4l_setdefaultnorm(norm); // moved after getcapabilities to get the channel number
    v4l_getcapability();
//    v4lsetdefaultnorm(norm);
	// Read channel ...
	
	
    
    if(!(vd.capability.type & VID_TYPE_CAPTURE)) {
    	fprintf(stderr, "[V4L]::VDOpen: This device seems not to support video capturing.\n");
    	return -1;
	}
	hastuner = 0;
	if((vd.capability.type & VID_TYPE_TUNER)) {
		hastuner = 1;
		frequency_table = 0; // CSE : didn't undestand ...  = freq;
		TVchannel = 0;
	}

	// set acquisition size
	changeSize(newSize);

    getcurrentchannel();
	
	maxc = vd.capability.channels;
	if((maxc) && (channel <= maxc)) {
    	if(setchannel(channel))
			 return -1;
	}
	if(channel >= maxc) {
		channel = maxc;
		if(setchannel(channel))
			 return -1;
	}
	
    if(v4l_mmap()) {
    	fprintf(stderr, "[V4L]::VDopen: mmap interface is not supported by this driver.\n");
        return -1;
	}

 	/* quick hack for v4l driver that does not support double buffer capturing */
	if(vd.mbuf.frames < 2) {
    	fprintf(stderr, "[V4L]::VDopen: double buffer capturing with mmap is not supported.\n");
        return -1;
	}
    /* OLD COMMENT detecting a pixel format supported by the v4l driver.
     * video_set_grabformat() overwrites both 'converter' and 'converter_hflip'.
     * If 'converter' is non-NULL, palette converter must be initialized. */
	if(setGrabFormat(palette)) {
		fprintf(stderr, "[V4L]::VDopen: ERROR : Can't find a supported pixel format.\n");
        return -1;
	}

    v4l_getpicture();
    picture_brightness = vd.picture.brightness;
    picture_hue = vd.picture.hue;
	picture_colour = vd.picture.colour;

/*** END COPY ****/

	if(StartGrab()) {
		fprintf(stderr, "[V4L]::VDopen: Can't start grab.\n");
  		//normal at beginning or when capture has been stopped
	}

	initialised = true;
//    echo();

	return 0;
}
Beispiel #26
0
	void increaseTwice()
	{ changeSize(m_capacity*2); }
Beispiel #27
0
	void decreaseFourth()
	{ changeSize(m_capacity*3/4);	}
Beispiel #28
0
int main(int argc, const char * argv[]) {
    
    // Window size
    int SCREEN_WIDTH = 800;
    int SCREEN_HEIGHT = 600;
    
    SDL_Window *mainwindow; /* Our window handle */
    SDL_GLContext maincontext; /* Our opengl context handle */
    
    SDL_Init(SDL_INIT_VIDEO);
    
    mainwindow = SDL_CreateWindow(PROGRAM_NAME, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                                  SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
    
    /* Create our opengl context and attach it to our window */
    maincontext = SDL_GL_CreateContext(mainwindow);
    
    /* This makes our buffer swap syncronized with the monitor's vertical refresh */
    SDL_GL_SetSwapInterval(1);
    
    player.setColor(0, 1, 0);
    myGrid.size = 9;
    myGrid.LinesX = 10;
    myGrid.LinesY = 10;
    myGrid.placeTypes();
    myGrid.printTypes();
    
    SDL_Event event;
    bool running = true;
    // Initialize camera
    changeSize(SCREEN_WIDTH, SCREEN_HEIGHT);
    while (running) {
        Uint32 start = SDL_GetTicks();
        //std::cout << "Start: " << start << std::endl;
        while (SDL_PollEvent(&event)) {
            
            switch (event.type) {
                    
                // Capture any window event
                // https://wiki.libsdl.org/SDL_WindowEvent
                case SDL_WINDOWEVENT:
                    switch (event.window.event) {
                        case SDL_WINDOWEVENT_RESIZED:
                            int w = event.window.data1;
                            int h = event.window.data2;
                            changeSize(w, h);
                            break;
                    }
                    break;
                    
                // Handle keyboar events
                case SDL_KEYDOWN:
                    switch (event.key.keysym.sym) {
                        case SDLK_UP:
                            std::cout << "Up key pressed" << std::endl;
                            player.move(1, 0, 0);
                            std::cout << "Player pos X " << player.posX << std::endl;
                            break;
                        case SDLK_DOWN:
                            std::cout << "Down key pressed" << std::endl;
                            player.move(-1, 0, 0);
                            std::cout << "Player pos X " << player.posX << std::endl;
                            break;
                        case SDLK_LEFT:
                            std::cout << "Left key pressed" << std::endl;
                            player.move(0, 1, 0);
                            std::cout << "Player pos Y " << player.posY << std::endl;
                            break;
                        case SDLK_RIGHT:
                            std::cout << "Right key pressed" << std::endl;
                            player.move(0, -1, 0);
                            std::cout << "Player pos Y " << player.posY << std::endl;
                            break;
                    }
                    break;
                    
                case SDL_QUIT:
                    running = false;
                    break;
            }
        }
        
        renderScene(mainwindow);
        
        // Insure that screen update happen no more then 60 fps
        //std::cout << "End: " << SDL_GetTicks() << std::endl;
        if (1000/60>(SDL_GetTicks() - start)) {
            SDL_Delay(1000/60 - (SDL_GetTicks() - start));
        }
    }
    
    /* Delete our opengl context, destroy our window, and shutdown SDL */
    SDL_GL_DeleteContext(maincontext);
    SDL_DestroyWindow(mainwindow);
    SDL_Quit();
    
    return 0;
}
Beispiel #29
0
void dialogs::getSize()
{
    emit changeSize(dialogs::spbWidth->value(),dialogs::spbHeight->value());
    emit setPause(false);
    quit();
}
Beispiel #30
0
void keyPressed(unsigned char key, int xx, int yy)
{
	switch(key) {

		case 27:
			glutLeaveMainLoop();
			break;
		case '1':
			_current_camera = 0;
			changeSize(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
			break;
		case '2':
			_current_camera = 1;
			changeSize(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
			break;
		case '3':
			_current_camera = 2;
			changeSize(glutGet(GLUT_WINDOW_WIDTH), glutGet(GLUT_WINDOW_HEIGHT));
			break;

		case 'n': case 'N':
			if (_directional_light.isEnabled())
				_directional_light.setEnabled(false);
			else
				_directional_light.setEnabled(true);
			break;

		case 'c': case 'C':
			for (int i = 0; i < _lamps.size(); i++) {
				if (_lamps[i]->isEnabled())
					_lamps[i]->setEnabled(false);
				else
					_lamps[i]->setEnabled(true);
			}
			break;

		case 'h': case 'H':
			for (int i = 0; i < _spotLights.size(); i++) {
				if (_spotLights[i]->isEnabled())
					_spotLights[i]->setEnabled(false);
				else
					_spotLights[i]->setEnabled(true);
			}
			break;
		
		case 'O': case 'o':
			car.left();
			break;

		case 'P': case 'p':
			car.right();
			break;

		case 'Q': case 'q':
			if (!paused) {
				car.accelerate();
			}
			break;
	
		case 'A': case 'a':
			if (!paused) {
				car.reverse();
			}
			break;

		case 'S': case 's':
			if (remainingLives > 0) {
				pause();
			}
			break;
		case 'R': case 'r':
			if (remainingLives <= 0) {
				pause();
				remainingLives = 5;
				gameScore = 0;
			}
			break;
		default:
			break;
	}
}