コード例 #1
0
ファイル: graphicsview.cpp プロジェクト: tohojo/xkcd-viewer
void GraphicsView::scale(qreal dx, qreal dy)
{
  QGraphicsView::scale(dx,dy);
  updateZoom();
}
コード例 #2
0
ファイル: graphicsview.cpp プロジェクト: tohojo/xkcd-viewer
void GraphicsView::setTransform(const QTransform & matrix, bool combine)
{
  QGraphicsView::setTransform(matrix, combine);
  updateZoom();
}
コード例 #3
0
void QtGradientStopsControllerPrivate::slotZoomAll()
{
    updateZoom(1);
}
コード例 #4
0
void QtGradientStopsControllerPrivate::slotZoomChanged(double zoom)
{
    updateZoom(zoom);
}
コード例 #5
0
void QtGradientStopsControllerPrivate::slotChangeZoom(int value)
{
    updateZoom(value / 100.0);
}
コード例 #6
0
bool Plot3DDialog::updatePlot() {
  int axis = -1;

  if (generalDialog->currentWidget() == (QWidget*)bars) {
    emit updateBars(boxBarsRad->text().toDouble());
  }

  if (generalDialog->currentWidget() == (QWidget*)points) {
    if (boxPointStyle->currentItem() == 0)
      emit updatePoints(boxSize->text().toDouble(), boxSmooth->isChecked());
    else if (boxPointStyle->currentItem() == 1)
      emit updateCross(boxCrossRad->text().toDouble(),
                       boxCrossLinewidth->text().toDouble(),
                       boxCrossSmooth->isChecked(), boxBoxed->isChecked());
    else if (boxPointStyle->currentItem() == 2)
      emit updateCones(boxConesRad->text().toDouble(), boxQuality->value());
  }

  if (generalDialog->currentWidget() == (QWidget*)title) {
    emit updateTitle(boxTitle->text(), titleColor, titleFont);
  }

  if (generalDialog->currentWidget() == (QWidget*)colors) {
    emit updateTransparency(boxTransparency->value() * 0.01);
    emit updateDataColors(fromColor, toColor);
    emit updateColors(meshColor, axesColor, numColor, labelColor, bgColor,
                      gridColor);
  }

  if (generalDialog->currentWidget() == (QWidget*)general) {
    emit showColorLegend(boxLegend->isChecked());
    emit updateMeshLineWidth(boxMeshLineWidth->value());
    emit adjustLabels(boxDistance->value());
    emit updateResolution(boxResolution->value());
    emit showColorLegend(boxLegend->isChecked());
    emit setNumbersFont(numbersFont);
    emit updateZoom(boxZoom->value() * 0.01);
    emit updateScaling(boxXScale->value() * 0.01, boxYScale->value() * 0.01,
                       boxZScale->value() * 0.01);
  }

  if (generalDialog->currentWidget() == (QWidget*)scale) {
    axis = axesList->currentRow();
    QString from = boxFrom->text().toLower();
    QString to = boxTo->text().toLower();
    double start, end;
    bool error = false;
    try {
      MyParser parser;
      parser.SetExpr(from.toAscii().constData());
      start = parser.Eval();
    } catch (mu::ParserError& e) {
      QMessageBox::critical(0, tr("Start limit error"),
                            QString::fromStdString(e.GetMsg()));
      boxFrom->setFocus();
      error = true;
      return false;
    }
    try {
      MyParser parser;
      parser.SetExpr(to.toAscii().constData());
      end = parser.Eval();
    } catch (mu::ParserError& e) {
      QMessageBox::critical(0, tr("End limit error"),
                            QString::fromStdString(e.GetMsg()));
      boxTo->setFocus();
      error = true;
      return false;
    }

    if (start >= end) {
      QMessageBox::critical(
          0, tr("Input error"),
          tr("Please enter scale limits that satisfy: from < to!"));
      boxTo->setFocus();
      return false;
    }

    if (!error)
      emit updateScale(axis, scaleOptions(axis, start, end, boxMajors->text(),
                                          boxMinors->text()));
  }

  if (generalDialog->currentWidget() == (QWidget*)axes) {
    axis = axesList2->currentRow();
    labels[axis] = boxLabel->text();
    emit updateLabel(axis, boxLabel->text(), axisFont(axis));
    emit updateTickLength(axis, boxMajorLength->text().toDouble(),
                          boxMinorLength->text().toDouble());
  }

  return true;
}
コード例 #7
0
void TransferFunctionEditorView::resizeEvent(QResizeEvent* event) {
    updateZoom();
    invalidatedHistogram_ = true;
    QGraphicsView::resizeEvent(event);
    this->resetCachedContent();
}
コード例 #8
0
ファイル: greatwindow.cpp プロジェクト: ricowang/Great
void GreatWindow::keyPressEvent(QKeyEvent *event)
{
    // nNpPmMoO
    int key=event->key();
    if(PressedAny("nNpPmMoO ")) {
        m_jumping = event->modifiers() & Qt::ShiftModifier;
        int offset = 1;
        bool group = false;
        if(QString("oOpP").indexOf(char(key)) != -1) {
            offset = -1;
        }

        if(QString("mMpP").indexOf(char(key)) != -1) {
            group = true;
        }

        m_mainUrl = ContentMgr.getUrl(offset, true, group);
        if(!m_jumping) {
            ViewMgr.present(m_mainUrl);
        } else {
            this->setStatus(3, m_mainUrl);
        }

        return;
    }

    if(PressedAny("Aa")) {
        bool fit = m_canvas->getFit();
        m_canvas->setFit(!fit);
        updateZoom();
    }

    if(PressedAny("Qq")) {
        on_action_Quit_triggered();
    }

#define DELTA 20
    if(PressedAny("jklhJKLH")) {
        int x = 0, y = 0;
        if(key == 'h' || key == 'H') {
            x = DELTA;
        }

        if(key == 'l' || key == 'L') {
            x = -DELTA;
        }

        if(key == 'j' || key == 'J') {
            y = -DELTA;
        }

        if(key == 'k' || key == 'K') {
            y = DELTA;
        }

        m_canvas->offset(x, y);
    }

    if(PressedAny("fF")) {
        reverFullScreen();
    }

    if(PressedAny("sS")) {
        ViewMgr.activeNext(this);
    }

    if(PressedAny("dD")) {
        ViewMgr.setDuplicate();
    }

    if(PressedAny("=+-0")) {
        if('0' == key) {
            m_canvas->setZoom(1);
        } else {
            m_canvas->zoom(key!='-'?true:false);
        }

        updateZoom();
    }
}
コード例 #9
0
ファイル: network.c プロジェクト: b00s1/NewtonWars
void stepNetwork(void)
{
   int i, k, pi, pi2, nbytes, newfd;
   char remoteIP[INET6_ADDRSTRLEN];
   struct sockaddr_storage remoteaddr;
   socklen_t addrlen;
   struct timeval tv;

   if(getDeathMessage(sendbuf))
   {
      for(k = 0; k < conf.maxPlayers; ++k)
      {
         if(connection[k].socket && !connection[k].bot)
         {
            snd(connection[k].socket, "\r\n");
            snd(connection[k].socket, sendbuf);
            snd(connection[k].socket, "\r\n> ");
         }
      }
   }
   
   tv.tv_sec = 0;
   tv.tv_usec = 1;
   readfds = master;
   if(select(fdmax + 1, &readfds, NULL, NULL, &tv) == -1)
   {
      print_error("select");
      exit(5);
   }

   for(i = 0; i <= fdmax; ++i)
   {
      if(FD_ISSET(i, &readfds))
      {
         if(i == listener)
         {
            addrlen = sizeof remoteaddr;
            newfd = accept(listener, (struct sockaddr *)&remoteaddr, &addrlen);
            if(newfd == -1)
            {
               print_error("accept");
            }
            else
            {
               getnameinfo((struct sockaddr *)&remoteaddr, addrlen, remoteIP, sizeof remoteIP, NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV);
               for(k = 0; k < conf.maxPlayers; ++k)
               {
                  if(connection[k].socket == 0)
                  {
                     connection[k].socket = newfd;
                     strncpy(connection[k].remoteIP,remoteIP,INET6_ADDRSTRLEN);
                     playerJoin(k);
                     updateName(k, "Anonymous");
                     allSendPlayerPos(k);
                     break;
                  }
               }
               if(k == conf.maxPlayers)
               {
                  close(newfd);
                  printf("new connection from %s on socket %d refused: max connections\n", remoteIP, newfd);
               }
               else
               {
                  FD_SET(newfd, &master);
                  if(newfd > fdmax)
                  {
                     fdmax = newfd;
                  }
                  printf("new connection from %s on socket %d accepted\n", remoteIP, newfd);
                  snd(newfd, WELCOME);
               }
            }
         }
         else
         {
            if((nbytes = recv(i, buf, sizeof buf, 0)) <= 0)
            {
               if(nbytes == 0)
               {
                  printf("socket %d hung up\n", i);
               }
               else
               {
                  print_error("recv");
               }
               for(k = 0; k < conf.maxPlayers; ++k)
               {
                  if(connection[k].socket == i)
                  {
                     connection[k].socket = 0;
                     connection[k].echo = 0;
                     connection[k].bot = 0;
                     playerLeave(k);
                     allSendPlayerLeave(k);
                     break;
                  }
               }   
               close(i);
               FD_CLR(i, &master);
            }
            else
            {
               pi = -1;
               for(k = 0; k < conf.maxPlayers; ++k)
               {
                  if(connection[k].socket == i)
                  {
                     pi = k;
                     break;
                  }
               }   
               for(k = 0; k < nbytes && pi >= 0; ++k)
               {
                  unsigned char c = buf[k];
                  if(c != '\r' && c != '\n')
                  {
                     if(isprint(c) && connection[pi].msgbufindex < 128 - 2)
                     {
                        connection[pi].msgbuf[connection[pi].msgbufindex++] = c;
                     }
                  }
                  else
                  {
                     if(connection[pi].msgbufindex == 0)
                     {
                        continue;
                     }
                     connection[pi].msgbuf[connection[pi].msgbufindex] = '\0';
                     connection[pi].msgbuf[connection[pi].msgbufindex + 1] = '\0';
                     connection[pi].msgbufindex = 0;
                     if(connection[pi].echo)
                     {
                        snd(i, connection[pi].msgbuf);
                        snd(i, "\r\n");
                     }
                     if(!overdrive)printf("%16s (%d): \"%s\"\n", getPlayer(pi)->name, pi, connection[pi].msgbuf);
                     switch(connection[pi].msgbuf[0])
                     {
                        case 'n':
                        {
                           updateName(pi, connection[pi].msgbuf + 2);
                           break;
                        }
                        case 't':
                        {
			  if(is_from_localhost(connection[pi])) {
                           tankEnergy(atoi(connection[pi].msgbuf + 2));
			  }
                          break;
                        }
                        case 'v':
                        {
                           updateVelocity(pi, atof(connection[pi].msgbuf + 2));
                           break;
                        }
			case 'w':
			{
			   toggleWatch(pi);
			   break;
			}
                        case 'z':
                        {
                           updateZoom(atof(connection[pi].msgbuf + 2));
                           break;
                        }
			case 'T':
			{
			  if(is_from_localhost(connection[pi])) {
		            double throttle = atof(connection[pi].msgbuf + 2);
			    conf.throttle.tv_sec= throttle;
			    conf.throttle.tv_nsec=(throttle - conf.throttle.tv_sec) * 1000000000;
			  }
			  break;
			}
			case 'D':
			{
			  if(is_from_localhost(connection[pi])) {
			    conf.debug = atoi(connection[pi].msgbuf + 2);
			  }
			  break;
			}
                        case 'c':
                        {
                           clearTraces(pi);
                           break;
                        }
                        case 'o':
                        {
			   if(is_from_localhost(connection[pi])) {
                             overdrive = !overdrive;
			   }
                           break;
                        }
                        case 'b':
                        {
                           connection[pi].bot = !connection[pi].bot;
                           if(connection[pi].bot)
                           {
                              sendOwnId(i, pi);
                              for(pi2 = 0; pi2 < conf.maxPlayers; ++pi2)
                              {
                                 if(connection[pi2].socket)
                                 {
                                    sendPlayerPos(i, pi2);
                                 }
                              }
                           }
                           break;
                        }
                        case 'f':
                        {
                           toggleFps();
                           break;
                        }
                        case 'i':
                        {
                           if(strcmp("init", connection[pi].msgbuf) == 0)
                           {
                              reinitialize();
                           }
                           break;
                        }
                        case 'x':
                        {
                           if(strcmp("xit", connection[pi].msgbuf) == 0)
                           {
                              exit(0);
                           }
                           break;
                        }
                        case 'e':
                        {
                           connection[pi].echo = !connection[pi].echo;
                           break;
                        }
                        case 'r':
                        {
                           validateOld(pi);
                           break;
                        }
                        default:
                        {
                           updateAngle(pi, atof(connection[pi].msgbuf));
                           break;
                        }
                     }

                     if(!connection[pi].bot)
                     {
                        snd(i, "> ");
                     }
                  }
               }
            }
         }
      }
   }
   for(k = 0; k < conf.maxPlayers; ++k)
   {
      if(getPlayer(k)->active && getPlayer(k)->timeoutcnt > 2)
      {
         connection[k].echo = 0;
         playerLeave(k);
         close(connection[k].socket);
         FD_CLR(connection[k].socket, &master);
         connection[k].socket = 0;
         connection[k].bot = 0;
         allSendPlayerLeave(k);
     }
   }   
}