PathDisplay::PathDisplay()
{
  style_property_ = new EnumProperty( "Line Style", "Lines",
                                      "The rendering operation to use to draw the grid lines.",
                                      this, SLOT( updateStyle() ));

  style_property_->addOption( "Lines", LINES );
  style_property_->addOption( "Billboards", BILLBOARDS );

  line_width_property_ = new FloatProperty( "Line Width", 0.03,
                                            "The width, in meters, of each path line."
                                            "Only works with the 'Billboards' style.",
                                            this, SLOT( updateLineWidth() ), this );
  line_width_property_->setMin( 0.001 );
  line_width_property_->hide();

  color_property_ = new ColorProperty( "Color", QColor( 25, 255, 0 ),
                                       "Color to draw the path.", this );

  alpha_property_ = new FloatProperty( "Alpha", 1.0,
                                       "Amount of transparency to apply to the path.", this );

  buffer_length_property_ = new IntProperty( "Buffer Length", 1,
                                             "Number of paths to display.",
                                             this, SLOT( updateBufferLength() ));
  buffer_length_property_->setMin( 1 );

  offset_property_ = new VectorProperty( "Offset", Ogre::Vector3::ZERO,
                                         "Allows you to offset the path from the origin of the reference frame.  In meters.",
                                         this, SLOT( updateOffset() ));
}
Beispiel #2
0
void wyScrollableLayer::updateFling(wyTargetSelector* ts) {
	if(m_scroller->computeScrollOffset()) {
		m_container->setPosition(m_horizontal ? m_scroller->getCurrX() : 0,
				m_vertical ? m_scroller->getCurrY() : (m_height - m_topBorder));
		updateOffset();
	} else {
		if(m_flinging) {
			m_flinging = false;
			invokeOnEndFling();
		}
	}

	if(!m_fadeingOut && !m_flinging && !m_scrolling && m_fadeOutTime > 0) {
		// increase no scroll time
		m_noScrollTime += ts->getDelta();

		// > fade out time
		if(m_noScrollTime >= m_fadeOutTime) {
			if(m_horizontalThumb || m_verticalThumb) {
				if(m_horizontalThumb) {
					m_horizontalThumb->stopAllActions();
					m_horizontalThumb->runAction(wyFadeOut::make(0.6f));
				}
				if(m_verticalThumb) {
					m_verticalThumb->stopAllActions();
					m_verticalThumb->runAction(wyFadeOut::make(0.6f));
				}
			}

			m_fadeingOut = true;
		}
	}
}
Beispiel #3
0
//Update loop called from the Main App class
//Checks for incoming messages from OSC
//Updates entities (environment and NPCs)
//and activates PCG
void EntityManager :: update( ){
    
    oscManager->recieveMessage();

    updatePlankton();
    updateUrchins();
    updateSparks();
    updateSpores();
    updateEggs();
    updateStarfish();
    updateJellies();
    updateFriendlies();

    
    updateOffset( );
    environment->update( hero->global, hero->local );

    if( getElapsedFrames() < 400 ) return;
    
    entityGenerator->generatePlankton( &plankton, &eggs );
    entityGenerator->generateSpores( &spores );
    entityGenerator->generateUrchin( &urchins );
    entityGenerator->generateStarfish( &starfish );
    entityGenerator->generateJellyfish( &jellies );
    if( entityGenerator->generateEgg( &eggs, &friendlies, &plankton ) )
    {
        oscManager->newFriendly();
    }
}
Beispiel #4
0
MemoryEditor::MemoryEditor() {
  setObjectName("memory-editor");
  setWindowTitle("Memory Editor");
  setGeometryString(&config().geometry.memoryEditor);
  application.windowList.append(this);

  layout = new QHBoxLayout;
  layout->setMargin(Style::WindowMargin);
  layout->setSpacing(Style::WidgetSpacing);
  setLayout(layout);

  editor = new HexEditor;
  editor->reader = { &MemoryEditor::reader, this };
  editor->writer = { &MemoryEditor::writer, this };
  editor->setFont(QFont(Style::Monospace));
  editor->setMinimumWidth((editor->lineWidth() + 3) * editor->fontMetrics().width(' '));
  editor->setMinimumHeight((16 + 1) * editor->fontMetrics().height());
  editor->setSize(16 * 1024 * 1024);
  memorySource = SNES::Debugger::MemorySource::CPUBus;
  layout->addWidget(editor);

  controlLayout = new QVBoxLayout;
  controlLayout->setSpacing(0);
  layout->addLayout(controlLayout);

  source = new QComboBox;
  source->addItem("S-CPU bus");
  source->addItem("S-APU bus");
  source->addItem("S-PPU VRAM");
  source->addItem("S-PPU OAM");
  source->addItem("S-PPU CGRAM");
  controlLayout->addWidget(source);
  controlLayout->addSpacing(2);

  addr = new QLineEdit;
  controlLayout->addWidget(addr);

  autoUpdateBox = new QCheckBox("Auto update");
  controlLayout->addWidget(autoUpdateBox);

  refreshButton = new QPushButton("Refresh");
  controlLayout->addWidget(refreshButton);

  spacer = new QWidget;
  spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
  controlLayout->addWidget(spacer);

  exportButton = new QPushButton("Export");
  controlLayout->addWidget(exportButton);

  importButton = new QPushButton("Import");
  controlLayout->addWidget(importButton);

  connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(sourceChanged(int)));
  connect(addr, SIGNAL(textEdited(const QString&)), this, SLOT(updateOffset()));
  connect(addr, SIGNAL(returnPressed()), this, SLOT(updateOffset()));
  connect(refreshButton, SIGNAL(released()), this, SLOT(refresh()));
  connect(exportButton, SIGNAL(released()), this, SLOT(exportMemory()));
  connect(importButton, SIGNAL(released()), this, SLOT(importMemory()));
}
Beispiel #5
0
void wyScrollableLayer::setContentSize(float w, float h) {
	wyColorLayer::setContentSize(w, h);
	setClipRect(wyr(0, 0, w, h), true);
	updateExtent();
	updateThumbSize();
	updateOffset();
}
Beispiel #6
0
void handleFollowUp(MsgHeader *header, Octet *msgIbuf, ssize_t length, Boolean isFromSelf, PtpClock *ptpClock)
{
  MsgFollowUp *follow;
  TimeInternal preciseOriginTimestamp;
  
  if(length < FOLLOW_UP_PACKET_LENGTH)
  {
    ERROR("short folow up message\n");
    toState(PTP_FAULTY, ptpClock);
    return;
  }
  
  switch(ptpClock->port_state)
  {
  case PTP_SLAVE:
    if(isFromSelf)
    {
      DBG("handleFollowUp: ignore from self\n");
      return;
    }
    
    if(getFlag(header->flags, PTP_SYNC_BURST) && !ptpClock->burst_enabled)
      return;
    
    DBGV("handleFollowUp: looking for uuid %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      ptpClock->parent_uuid[0], ptpClock->parent_uuid[1], ptpClock->parent_uuid[2],
      ptpClock->parent_uuid[3], ptpClock->parent_uuid[4], ptpClock->parent_uuid[5]);
    
    follow = &ptpClock->msgTmp.follow;
    msgUnpackFollowUp(ptpClock->msgIbuf, follow);
    
    if( ptpClock->waitingForFollow
      && follow->associatedSequenceId == ptpClock->parent_last_sync_sequence_number
      && header->sourceCommunicationTechnology == ptpClock->parent_communication_technology
      && header->sourcePortId == ptpClock->parent_port_id
      && !memcmp(header->sourceUuid, ptpClock->parent_uuid, PTP_UUID_LENGTH) )
    {
      ptpClock->waitingForFollow = FALSE;
      
      toInternalTime(&preciseOriginTimestamp, &follow->preciseOriginTimestamp, &ptpClock->halfEpoch);
      updateOffset(&preciseOriginTimestamp, &ptpClock->sync_receive_time,
        &ptpClock->ofm_filt, ptpClock);
      updateClock(ptpClock);
    }
    else
    {
      DBGV("handleFollowUp: unwanted\n");
    }
    break;
    
  default:
    DBGV("handleFollowUp: disreguard\n");
    return;
  }
}
Beispiel #7
0
GridDisplay::GridDisplay()
: Display()
{
  frame_property_ = new TfFrameProperty( "Reference Frame", TfFrameProperty::FIXED_FRAME_STRING,
                                         "The TF frame this grid will use for its origin.",
                                         this, 0, true );

  cell_count_property_ = new IntProperty( "Plane Cell Count", 10,
                                          "The number of cells to draw in the plane of the grid.",
                                          this, SLOT( updateCellCount() ));
  cell_count_property_->setMin( 1 );

  height_property_ = new IntProperty( "Normal Cell Count", 0,
                                      "The number of cells to draw along the normal vector of the grid. "
                                      " Setting to anything but 0 makes the grid 3D.",
                                      this, SLOT( updateHeight() ));
  height_property_->setMin( 0 );

  cell_size_property_ = new FloatProperty( "Cell Size", 1.0f,
                                           "The length, in meters, of the side of each cell.",
                                           this, SLOT( updateCellSize() ));
  cell_size_property_->setMin( 0.0001 );

  style_property_ = new EnumProperty( "Line Style", "Lines",
                                      "The rendering operation to use to draw the grid lines.",
                                      this, SLOT( updateStyle() ));
  style_property_->addOption( "Lines", Grid::Lines );
  style_property_->addOption( "Billboards", Grid::Billboards );

  line_width_property_ = new FloatProperty( "Line Width", 0.03,
                                            "The width, in meters, of each grid line.",
                                            style_property_, SLOT( updateLineWidth() ), this );
  line_width_property_->setMin( 0.001 );
  line_width_property_->hide();

  color_property_ = new ColorProperty( "Color", Qt::gray,
                                       "The color of the grid lines.",
                                       this, SLOT( updateColor() ));
  alpha_property_ = new FloatProperty( "Alpha", 0.5f,
                                       "The amount of transparency to apply to the grid lines.",
                                       this, SLOT( updateColor() ));
  alpha_property_->setMin( 0.0f );
  alpha_property_->setMax( 1.0f );

  plane_property_ = new EnumProperty( "Plane", "XY",
                                      "The plane to draw the grid along.",
                                      this, SLOT( updatePlane() ));
  plane_property_->addOption( "XY", XY );
  plane_property_->addOption( "XZ", XZ );
  plane_property_->addOption( "YZ", YZ );

  offset_property_ = new VectorProperty( "Offset", Ogre::Vector3::ZERO,
                                         "Allows you to offset the grid from the origin of the reference frame.  In meters.",
                                         this, SLOT( updateOffset() ));
}
void LocalFileOffsetStore::load() {
  std::ifstream ifs(m_storeFile.c_str(), std::ios::in);
  if (ifs.good()) {
    if (ifs.is_open()) {
      if (ifs.peek() != std::ifstream::traits_type::eof()) {
        map<string, int64> m_offsetTable_tmp;
        boost::system::error_code e;
        try {
          boost::archive::text_iarchive ia(ifs);
          ia >> m_offsetTable_tmp;
        } catch (...) {
          LOG_ERROR(
              "load offset store file failed, please check whether file: %s is "
              "cleared by operator, if so, delete this offsets.Json file and "
              "then restart consumer",
              m_storeFile.c_str());
          ifs.close();
          string errorMsg("load offset store file: ");
          errorMsg.append(m_storeFile)
              .append(
                  " failed, please check whether offsets.Json is cleared by "
                  "operator, if so, delete this offsets.Json file and then "
                  "restart consumer");
          THROW_MQEXCEPTION(MQClientException, errorMsg, -1);
        }
        ifs.close();

        for (map<string, int64>::iterator it = m_offsetTable_tmp.begin();
             it != m_offsetTable_tmp.end(); ++it) {
          // LOG_INFO("it->first:%s, it->second:%lld", it->first.c_str(),
          // it->second);
          Json::Reader reader;
          Json::Value object;
          reader.parse(it->first.c_str(), object);
          MQMessageQueue mq(object["topic"].asString(),
                            object["brokerName"].asString(),
                            object["queueId"].asInt());
          updateOffset(mq, it->second);
        }
        m_offsetTable_tmp.clear();
      } else {
        LOG_ERROR(
            "open offset store file failed, please check whether file: %s is "
            "cleared by operator, if so, delete this offsets.Json file and "
            "then restart consumer",
            m_storeFile.c_str());
        THROW_MQEXCEPTION(MQClientException,
                          "open offset store file failed, please check whether "
                          "offsets.Json is cleared by operator, if so, delete "
                          "this offsets.Json file and then restart consumer",
                          -1);
      }
    } else {
Beispiel #9
0
bool IOKitDiagnostics::serialize(OSSerialize *s) const
{
    OSDictionary * 	dict;
    bool		ok;

    dict = OSDictionary::withCapacity( 5 );
    if( !dict)
	return( false );

    updateOffset( dict, debug_ivars_size, "Instance allocation" );
    updateOffset( dict, debug_container_malloc_size, "Container allocation" );
    updateOffset( dict, debug_iomalloc_size, "IOMalloc allocation" );
    updateOffset( dict, debug_iomallocpageable_size, "Pageable allocation" );

    OSMetaClass::serializeClassDictionary(dict);

    ok = dict->serialize( s );

    dict->release();

    return( ok );
}
Beispiel #10
0
void Tiled2DGraphics::updateVisibility()
{
    _dirty = false;
    updateOffset(_clampingPolicy);
    
    if (_debug) {
        static int cnt=0;
        cnt++;
        std::ostringstream ss;
        ss << "enabled: " << _enabled << std::endl;
        ss << "scroll-delta: " << _scrollDelta << std::endl;
        ss << "zoom-level: " << _currentZoomLevel << std::endl;
        ss << "counter: " << cnt << std::endl;
        cefix::DebugGeometryFactory::get("tiles_2d_overlay")->addText(osg::Vec3(10,40,10), ss.str(), osg::Vec4(0.3,0.3,0.3,1));
    }
    
    if (!_currentVisibleLevel || !_enabled)
		return;
    
    
    // erstmal alle möglichen Tiles durchgehen und wenn sie noch nicht visible sind, zu den visible hinzufügen
    _currentVisibleLevel->getTilesInRect(_viewportRect, _visibleTiles);
    
    for(Level::TilesList::iterator i = _visibleTiles.begin(); i != _visibleTiles.end(); ) 
    {
        if(cefix::Rect::isIntersecting((*i)->getRect(), _viewportRect)) 
        {
            _tilesToHideCache->remove(*i); 
            
            (*i)->setIsInConstrainingRect(true);
            (*i)->setIsInVisibleList(true);
            (*i)->startAnyPreloadingAction();
            
            ++i;
        }
        else {
            if ((*i)->isInConstrainingRect())
                _tilesToHide.push_back(*i);
            i = _visibleTiles.erase(i);
        }
    }
    
    // std::cout << "visible tiles: "<< _visibleTiles.size() << " tiles to hide: " << _tilesToHide.size() << std::endl;
    
    hideOrphanedTiles();
    
    _mergeController->merge();
    
}
Beispiel #11
0
void MemoryEditor::sourceChanged(int index) {
  switch(index) { default:
    case 0: memorySource = SNES::Debugger::MemorySource::CPUBus; editor->setEditorSize(16 * 1024 * 1024); break;
    case 1: memorySource = SNES::Debugger::MemorySource::APUBus; editor->setEditorSize(64 * 1024);        break;
    case 2: memorySource = SNES::Debugger::MemorySource::VRAM;   editor->setEditorSize(64 * 1024);        break;
    case 3: memorySource = SNES::Debugger::MemorySource::OAM;    editor->setEditorSize(544);              break;
    case 4: memorySource = SNES::Debugger::MemorySource::CGRAM;  editor->setEditorSize(512);              break;
    case 5: memorySource = SNES::Debugger::MemorySource::CartROM; editor->setEditorSize(SNES::memory::cartrom.size()); break;
    case 6: memorySource = SNES::Debugger::MemorySource::CartRAM; editor->setEditorSize(SNES::memory::cartram.size()); break;
    case 7: memorySource = SNES::Debugger::MemorySource::SA1Bus; editor->setEditorSize(16 * 1024 * 1024); break;
    case 8: memorySource = SNES::Debugger::MemorySource::SFXBus; editor->setEditorSize(8 * 1024 * 1024); break;
  }

  updateOffset();
}
Beispiel #12
0
void MemoryEditor::searchPrev() {
  if (searchStr.size() == 0) return;

  if (searchPos < 0)
    searchPos = (int)editor->cursorPosition() / 2;
  searchPos = editor->lastIndexOf(searchStr, searchPos - 1);

  if (searchPos >= 0) {
    addr->setText(QString::number(searchPos, 16));
    updateOffset();
  } else {
    QMessageBox::information(this, "Memory Editor", "Reached beginning of memory.", QMessageBox::Ok);
    searchPos = editor->editorSize();
  }
}
Beispiel #13
0
void wyScrollableLayer::setVerticalThumb(wyNode* thumb) {
	// remove old thumb
	if(m_verticalThumb) {
		removeChildLocked(m_verticalThumb, true);
		m_verticalThumb = NULL;
	}

	// set new thumb
	if(thumb) {
		m_verticalThumb = thumb;
		thumb->setAnchor(1, 1);
		addChildLocked(thumb);
		updateThumbSize();
		updateOffset();
	}
}
Beispiel #14
0
void wyScrollableLayer::addScrollableChildLocked(wyNode* child, int z, int tag) {
	// don't intercept touch because scrollable layer need it
	child->setInterceptTouch(false);

	// add child
	m_container->addChildLocked(child, z, tag);

	// confine the touch event
	child->setTouchCoffin(this);

	// update
	updateExtent();
	if(!m_running)
		m_container->setPosition(-m_leftBorder, m_height - m_topBorder);
	updateThumbSize();
	updateOffset();
}
Beispiel #15
0
bool CCCameraBase::setLookAt(const CCVector3 &lookAtTarget, const CCVector3 &offsetTarget)
{
    if( updating )
    {
        updating = false;
        
        if( CCVector3Equals( lookAt, lookAtTarget ) == false || CCVector3Equals( offset, offsetTarget ) == false )
        {
            updatedPosition = true;
            lookAt = lookAtTarget;
            
            updateOffset( offsetTarget );
            return true;
        }
    }
    
    return false;
}
void MapShowScene::update()
{
	string temp;
	switch (mapShowState)
	{
	case MapShowState::GAME_RUNNING:
		bomberman.update();
		enemies.update();
		checkEnemies_Bomberman();
		updateOffset();
		if (bomb != nullptr)
		{
			bomb->update();
			if (bomb->bombState == BombState::DESTROYED)
			{
				delete bomb;
				bomb = nullptr;
			}
			checkBomb_Char();
		}
		else
		{
			const Uint8* currentKeyStates = SDL_GetKeyboardState(NULL);
			if (currentKeyStates[SDL_SCANCODE_SPACE])
			{
				putBomb();
			}
		}
		if ( SDL_GetTicks() - s_timeLeft > timeLeft )
		{
			mapShowState = MapShowState::GAME_OVER;
		}
		
		temp = "Time Remaning : " + getString( ( timeLeft - SDL_GetTicks() + s_timeLeft ) / 1000 );
		statusString.setText(temp.c_str());
		break;
	case MapShowState::GAME_SUCCESS:
		break;
	case MapShowState::GAME_OVER:
		break;
	}
	
}
Beispiel #17
0
Tiled2DGraphics::Tiled2DGraphics(const osg::Vec2& size, const osg::Vec4& constraining_rect, double tile_width, double tile_height, const Options& options)
:	osg::MatrixTransform(),
	_size(size),
	_constrainingRect(constraining_rect),
	_minZoomLevel(computeMinZoomLevel()),
	_maxZoomLevel(_minZoomLevel),
	_currentZoomLevel(0.0f),
    _currentVisibleLevel(NULL),
    _scrollDelta(0,0),
    _visibleTiles(),
    _tilesToHide(),
	_tileWidth(tile_width),
	_tileHeight(tile_height),
	_origin(osg::Image::BOTTOM_LEFT),
    _zoomRegistrationPoint(),
    _clampingPolicy(ClampSoft),
    _useCache(true),
    _debug(options.debug),
    _debugTiles(options.debugTiles),
    _tilesComputed(false),
    _lastLevelId(0),
    _enabled(true)
{
	_tilesToHideCache = new TilesToHideCache(options.tilesCacheLifeTime);
    _mergeController = new MergeController(this, options.numTilesToMergePerFrame);
    
    setUpdateCallback(new Tiled2DGraphicsUpdateCallback(this));
	setZoomLevel(_minZoomLevel);
	updateOffset(ClampHard);
    
	setZoomRegistrationPoint(cefix::Rect::getCenter(constraining_rect));
    
    
    
    if (_debug) {
        cefix::DebugGeometryFactory::enable("tiles_2d");
        cefix::DebugGeometryFactory::enable("tiles_2d_overlay");
        cefix::DebugGeometryFactory::get("tiles_2d")->setLocZ(1);
        addChild(cefix::DebugGeometryFactory::get("tiles_2d")->getOrCreateNode());
    }
}
Beispiel #18
0
const bool CCCameraAppUI::interpolateCamera(const float delta, const float speed)
{
	if( updating )
	{   
        updating = false;
        
        if( currentOffsetTarget.target != targetOffset )
        {
            currentOffsetTarget.target = targetOffset;
            offsetInterpolator.setup( &currentOffsetTarget.current, currentOffsetTarget.target );
        }
        
        if( currentLookAtTarget.target != targetLookAt )
        {
            currentLookAtTarget.target = targetLookAt;
            lookAtInterpolator.setup( &currentLookAtTarget.current, currentLookAtTarget.target );
        }
        
        if( offsetInterpolator.update( delta * speed ) )
        {
            refreshCameraSize();
            updating = true;
        }
        
        if( lookAtInterpolator.update( delta * speed ) )
        {
            updating = true;
            updatedPosition = true;
        }
        
        // Now update our camera
        {
            lookAt = currentLookAtTarget.current;
            updateOffset( currentOffsetTarget.current );
        }
        return true;
	}

	return false;
}
Beispiel #19
0
void MemoryEditor::gotoPrevious(int type) {
  int offset = (int)editor->cursorPosition() / 2;
  bool found = false;
  SNES::uint8 *usage;

  if (memorySource == SNES::Debugger::MemorySource::CPUBus) {
    usage = SNES::cpu.usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::APUBus) {
    usage = SNES::smp.usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::CartROM) {
    usage = SNES::cpu.cart_usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::SA1Bus) {
    usage = SNES::sa1.usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::SFXBus) {
    usage = SNES::superfx.usage;
  } else return;

  while (--offset >= 0) {
    bool foundHere = ((type && usage[offset] & type) || (!type && (usage[offset] & 0xf0) == 0));

    if (found && !foundHere) {
      offset++; break;
    } else if (!found && foundHere) {
      found = foundHere;
    }
  }

  if (offset < 0 && found) offset = 0;

  if (offset >= 0) {
    addr->setText(QString::number(offset, 16));
    updateOffset();
  } else {
    QMessageBox::information(this, "Memory Editor", "Reached beginning of memory.", QMessageBox::Ok);
  }
}
Beispiel #20
0
void MemoryEditor::gotoNext(int type) {
  int offset = (int)editor->cursorPosition() / 2;
  unsigned size = editor->editorSize();
  bool found = true;
  SNES::uint8 *usage;

  if (memorySource == SNES::Debugger::MemorySource::CPUBus) {
    usage = SNES::cpu.usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::APUBus) {
    usage = SNES::smp.usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::CartROM) {
    usage = SNES::cpu.cart_usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::SA1Bus) {
    usage = SNES::sa1.usage;
  }
  else if (memorySource == SNES::Debugger::MemorySource::SFXBus) {
    usage = SNES::superfx.usage;
  } else return;

  while (++offset < size) {
    bool foundHere = ((type && usage[offset] & type) || (!type && (usage[offset] & 0xf0) == 0));

    if (!found && foundHere) {
      found = true; break;
    } else if (found && !foundHere) {
      found = foundHere;
    }
  }

  if (offset < size) {
    addr->setText(QString::number(offset, 16));
    updateOffset();
  } else {
    QMessageBox::information(this, "Memory Editor", "Reached end of memory.", QMessageBox::Ok);
  }
}
Beispiel #21
0
bool wyScrollableLayer::touchesMoved(wyMotionEvent& e) {
	if(m_scrolling) {
		// calculate new offset
		float dx = e.x[0] - m_lastX;
		float dy = e.y[0] - m_lastY;
		float posX = m_container->getPositionX();
		float posY = m_container->getPositionY();
		if(m_vertical)
			posY += dy;
		if(m_horizontal)
			posX += dx;
		m_container->setPosition(posX, posY);

		// save last x/y
		m_lastX = e.x[0];
		m_lastY = e.y[0];

		// update
		updateOffset();

		// if exceeds thresholder, cancel child touch
		if(!m_childTouchCancelled) {
			dx = fabs(e.x[0] - m_firstX);
			dy = fabs(e.y[0] - m_firstY);

			if(dx >= DP(10) || dy >= DP(10)) {
				wyEventDispatcher::getInstance()->cancelTouch(e, m_container);
				m_childTouchCancelled = true;
			}
		}

		return true;
	}

	return false;
}
Beispiel #22
0
void CCCameraBase::setOffset(const CCVector3 &offsetTarget)
{
    updateOffset( offsetTarget );
}
Beispiel #23
0
QVariant Pin::itemChange(GraphicsItemChange change, const QVariant &value)
{
	// Note that pins are only movable within the symbol editor.

	PageScene *pageScene = dynamic_cast<PageScene *>(scene());
	if (ItemPositionChange == change && pageScene) {
		QPointF p = value.toPointF() + pageScene->reparentOffset(this);	// p is now the position relative to the current parent.
		SymbolEditor *se = dynamic_cast<SymbolEditor *>(pageScene->parent());
		if (se) {
			QGraphicsItem *anchor = se->closestPinAnchor(parentItem()->mapToScene(p), this);
			if (parentItem() != anchor) {
				pageScene->reparentWhileDragging(this, anchor);
				p = value.toPointF() + pageScene->reparentOffset(this);
				setData(FreeSCH::SectionChanged, true);
			}
			if (QGraphicsLineItem::Type == anchor->type()) {
				p.setX(anchor->pos().x());
				if (position.side() != PinPosition::Right) {
					position.setSide(PinPosition::Right);
					attributes.setValue("side", PinPosition::sideNames.at(PinPosition::Right));
					reorient();
				}
			} else if (Section::Type == anchor->type()) {
				Section *section = qgraphicsitem_cast<Section *>(anchor);
				if (section) {
					QRectF r = QRectF(QPointF(0,0), section->rect().size());
					PinPosition::PinSide newside = PinPosition::sideIndex(r, p);
					switch (newside) {
					case PinPosition::Right:
						p.setX(r.right());
						break;
					case PinPosition::Bottom:
						p.setY(r.bottom());
						break;
					case PinPosition::Left:
						p.setX(r.left());
						break;
					default: // top
						p.setY(r.top());
						break;
					}
					if (p.x() < 0)
						p.setX(0);
					if (p.x() > r.width())
						p.setX(r.width());
					if (p.y() < 0)
						p.setY(0);
					if (p.y() > r.height())
						p.setY(r.height());

					if (position.side() != newside) {
						position.setSide(newside);
						attributes.setValue("side", PinPosition::sideNames.at(newside));
						updateOffset(snap(p).toPoint());
						reorient();
						// As the pin moves around a corner of a section, it can switch sides without its pos() changing.
						// In that case the ItemPositionHasChanged event doesn't occur. So we need to emit the moved signal here.

						emit moved();
					}
				}
			}
		}
		return snap(p);
	}
	if (ItemPositionHasChanged == change && pageScene) {
		updateOffset(pos().toPoint());

		if (data(FreeSCH::SectionChanged).toBool()) {
			setData(FreeSCH::SectionChanged, false);
			emit sectionChanged(this, parentItem());
		}
		emit moved();
	}
	return QGraphicsItem::itemChange(change, value);
}
Beispiel #24
0
static void handleSync(PtpClock *ptpClock, TimeInternal *time, Boolean isFromSelf)
{
    TimeInternal originTimestamp;
    TimeInternal correctionField;

    Boolean isFromCurrentParent = FALSE;
    DBGV("handleSync: received\n");

    if (ptpClock->msgIbufLength < SYNC_LENGTH)
    {
        ERROR("handleSync: short message\n");
        toState(ptpClock, PTP_FAULTY);
        return;
    }

    switch (ptpClock->portDS.portState)
    {
    case PTP_INITIALIZING:
    case PTP_FAULTY:
    case PTP_DISABLED:

        DBGV("handleSync: disreguard\n");
        break;

    case PTP_UNCALIBRATED:
    case PTP_SLAVE:

        if (isFromSelf)
        {
            DBGV("handleSync: ignore from self\n");
            break;
        }

        isFromCurrentParent = isSamePortIdentity(
			&ptpClock->parentDS.parentPortIdentity,
			&ptpClock->msgTmpHeader.sourcePortIdentity);

        if (!isFromCurrentParent)
        {
            DBGV("handleSync: ignore from another master\n");
            break;
        }

        ptpClock->timestamp_syncRecieve = *time;

        scaledNanosecondsToInternalTime(&ptpClock->msgTmpHeader.correctionfield, &correctionField);

        if (getFlag(ptpClock->msgTmpHeader.flagField[0], FLAG0_TWO_STEP))
        {
            ptpClock->waitingForFollowUp = TRUE;
            ptpClock->recvSyncSequenceId = ptpClock->msgTmpHeader.sequenceId;
            /* Save correctionField of Sync message for future use */
            ptpClock->correctionField_sync = correctionField;
        }
        else
        {
            msgUnpackSync(ptpClock->msgIbuf, &ptpClock->msgTmp.sync);
            ptpClock->waitingForFollowUp = FALSE;
            /* Synchronize  local clock */
            toInternalTime(&originTimestamp, &ptpClock->msgTmp.sync.originTimestamp);
            /* use correctionField of Sync message for future use */
            updateOffset(ptpClock, &ptpClock->timestamp_syncRecieve, &originTimestamp, &correctionField);
            updateClock(ptpClock);
        
            issueDelayReqTimerExpired(ptpClock);
        }

        break;


    case PTP_MASTER:

        if (!isFromSelf)
        {
            DBGV("handleSync: from another master\n");
            break;
        }
        else
        {
            DBGV("handleSync: ignore from self\n");
            break;
        }

//      if waitingForLoopback && TWO_STEP_FLAG
//        {
//            /*Add latency*/
//            addTime(time, time, &rtOpts->outboundLatency);
//
//            issueFollowup(ptpClock, time);
//            break;
//        }
    case PTP_PASSIVE:
        issueDelayReqTimerExpired(ptpClock);
        DBGV("handleSync: disreguard\n");
        break;

    default:
        DBGV("handleSync: disreguard\n");

        break;
    }
}
Beispiel #25
0
void Tiled2DGraphics::updateTransform() 
{
	updateOffset(_clampingPolicy);
    	//setMatrix(osg::Matrix::translate(dx, dy, 0) * osg::Matrix::scale(_currentZoomLevel, _currentZoomLevel, 1) * osg::Matrix::translate(scroll_delta_x, scroll_delta_y, 0));

}
Beispiel #26
0
static void handleFollowUp(PtpClock *ptpClock, Boolean isFromSelf)
{
    TimeInternal preciseOriginTimestamp;
    TimeInternal correctionField;
    Boolean isFromCurrentParent = FALSE;

    DBGV("handleFollowup: received\n");


    if (ptpClock->msgIbufLength < FOLLOW_UP_LENGTH)
    {
        ERROR("handleFollowup: short message\n");
        toState(ptpClock, PTP_FAULTY);
        return;
    }

    if (isFromSelf)
    {
        DBGV("handleFollowup: ignore from self\n");
        return;
    }

    switch (ptpClock->portDS.portState)
    {
    case PTP_INITIALIZING:
    case PTP_FAULTY:
    case PTP_DISABLED:
    case PTP_LISTENING:

        DBGV("handleFollowup: disreguard\n");
        break;

    case PTP_UNCALIBRATED:
    case PTP_SLAVE:

        isFromCurrentParent = isSamePortIdentity(
			&ptpClock->parentDS.parentPortIdentity,
			&ptpClock->msgTmpHeader.sourcePortIdentity);

        if (!ptpClock->waitingForFollowUp)
        {
            DBGV("handleFollowup: not waiting a message\n");
            break;
        }

        if (!isFromCurrentParent)
        {
            DBGV("handleFollowup: not from current parent\n");
            break;
        }


        if (ptpClock->recvSyncSequenceId !=  ptpClock->msgTmpHeader.sequenceId)
        {
            DBGV("handleFollowup: SequenceID doesn't match with last Sync message\n");
            break;
        }

        msgUnpackFollowUp(ptpClock->msgIbuf, &ptpClock->msgTmp.follow);

        ptpClock->waitingForFollowUp = FALSE;
        /* synchronize local clock */
        toInternalTime(&preciseOriginTimestamp, &ptpClock->msgTmp.follow.preciseOriginTimestamp);
        scaledNanosecondsToInternalTime(&ptpClock->msgTmpHeader.correctionfield, &correctionField);
        addTime(&correctionField, &correctionField, &ptpClock->correctionField_sync);
        updateOffset(ptpClock, &ptpClock->timestamp_syncRecieve, &preciseOriginTimestamp, &correctionField);
        updateClock(ptpClock);
        
        issueDelayReqTimerExpired(ptpClock);
        break;

    case PTP_MASTER:
        DBGV("handleFollowup: from another master\n");

        break;

    case PTP_PASSIVE:
        issueDelayReqTimerExpired(ptpClock);
        DBGV("handleFollowup: disreguard\n");
        break;
    
    default:
        DBG("handleFollowup: unrecognized state\n");

        break;
    }//Switch on (port_state)

}
Beispiel #27
0
void handleSync(MsgHeader *header, Octet *msgIbuf, ssize_t length, TimeInternal *time, Boolean badTime, Boolean isFromSelf, PtpClock *ptpClock)
{
  MsgSync *sync;
  TimeInternal originTimestamp;
  
  if(length < SYNC_PACKET_LENGTH)
  {
    ERROR("short sync message\n");
    toState(PTP_FAULTY, ptpClock);
    return;
  }
  
  switch(ptpClock->port_state)
  {
  case PTP_FAULTY:
  case PTP_INITIALIZING:
  case PTP_DISABLED:
    DBGV("handleSync: disreguard\n");
    return;
    
  case PTP_UNCALIBRATED:
  case PTP_SLAVE:
    if(isFromSelf)
    {
      DBG("handleSync: ignore from self\n");
      return;
    }
    
    if(getFlag(header->flags, PTP_SYNC_BURST) && !ptpClock->burst_enabled)
      return;
    
    DBGV("handleSync: looking for uuid %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx\n",
      ptpClock->parent_uuid[0], ptpClock->parent_uuid[1], ptpClock->parent_uuid[2],
      ptpClock->parent_uuid[3], ptpClock->parent_uuid[4], ptpClock->parent_uuid[5]);
    
    if( header->sequenceId > ptpClock->parent_last_sync_sequence_number
      && header->sourceCommunicationTechnology == ptpClock->parent_communication_technology
      && header->sourcePortId == ptpClock->parent_port_id
      && !memcmp(header->sourceUuid, ptpClock->parent_uuid, PTP_UUID_LENGTH) )
    {
      /* addForeign() takes care of msgUnpackSync() */
      ptpClock->record_update = TRUE;
      sync = addForeign(ptpClock->msgIbuf, &ptpClock->msgTmpHeader, ptpClock);
      
      if(sync->syncInterval != ptpClock->sync_interval)
      {
        DBGV("message's sync interval is %d, but clock's is %d\n", sync->syncInterval, ptpClock->sync_interval);
        /* spec recommends handling a sync interval discrepancy as a fault */
      }
      
      /*
       * TODO: Sync packets without hardware time stamp are rare, but might happen.
       * Need to decide what to do with the bad default time stamp, similar to handleDelayReq().
       */

      ptpClock->sync_receive_time.seconds = time->seconds;
      ptpClock->sync_receive_time.nanoseconds = time->nanoseconds;
      
      if(!getFlag(header->flags, PTP_ASSIST))
      {
        ptpClock->waitingForFollow = FALSE;
        
        toInternalTime(&originTimestamp, &sync->originTimestamp, &ptpClock->halfEpoch);
        updateOffset(&originTimestamp, &ptpClock->sync_receive_time,
          &ptpClock->ofm_filt, ptpClock);
        updateClock(ptpClock);
      }
      else
      {
        ptpClock->waitingForFollow = TRUE;
      }
      
      s1(header, sync, ptpClock);
      
      if(!(--ptpClock->R))
      {
        issueDelayReq(ptpClock);
        
        ptpClock->Q = 0;
        ptpClock->R = getRand(&ptpClock->random_seed)%(PTP_DELAY_REQ_INTERVAL - 2) + 2;
        DBG("Q = %d, R = %d\n", ptpClock->Q, ptpClock->R);
      }
      
      DBGV("SYNC_RECEIPT_TIMER reset\n");
      timerStart(SYNC_RECEIPT_TIMER, PTP_SYNC_RECEIPT_TIMEOUT(ptpClock->sync_interval), ptpClock->itimer);
    }
    else
    {
      DBGV("handleSync: unwanted\n");
    }
    
  case PTP_MASTER:
  default:
    if( header->sourceCommunicationTechnology == ptpClock->clock_communication_technology
      || header->sourceCommunicationTechnology == PTP_DEFAULT
      || ptpClock->clock_communication_technology == PTP_DEFAULT )
    {
      if(!isFromSelf)
      {
        ptpClock->record_update = TRUE;
        addForeign(ptpClock->msgIbuf, &ptpClock->msgTmpHeader, ptpClock);
      }
      else if(ptpClock->port_state == PTP_MASTER && ptpClock->clock_followup_capable)
      {
        addTime(time, time, &ptpClock->runTimeOpts.outboundLatency);
        issueFollowup(time, ptpClock);
      }
    }
    break;
  }
}
Beispiel #28
0
MemoryEditor::MemoryEditor() {
  setObjectName("memory-editor");
  setWindowTitle("Memory Editor");
  setGeometryString(&config().geometry.memoryEditor);
  application.windowList.append(this);

  layout = new QGridLayout;
  layout->setMargin(Style::WindowMargin);
  layout->setSpacing(Style::WidgetSpacing);
  setLayout(layout);

  editor = new QHexEdit;
  editor->reader = { &MemoryEditor::reader, this };
  editor->writer = { &MemoryEditor::writer, this };
  editor->usage  = { &MemoryEditor::usage, this };
  memorySource = SNES::Debugger::MemorySource::CPUBus;
  layout->addWidget(editor, 0, 0);

  controlLayout = new QVBoxLayout;
  controlLayout->setSpacing(0);
  layout->addLayout(controlLayout, 0, 1);
  layout->setColumnStretch(0, 1);

  source = new QComboBox;
  source->addItem("S-CPU bus");
  source->addItem("S-APU bus");
  source->addItem("S-PPU VRAM");
  source->addItem("S-PPU OAM");
  source->addItem("S-PPU CGRAM");
  source->addItem("Cartridge ROM");
  source->addItem("Cartridge RAM");
  source->addItem("SA-1 bus");
  source->addItem("GSU bus");
  controlLayout->addWidget(source);
  controlLayout->addSpacing(2);

  addr = new QLineEdit;
  controlLayout->addWidget(addr);

  autoUpdateBox = new QCheckBox("Auto update");
  controlLayout->addWidget(autoUpdateBox);

  refreshButton = new QPushButton("Refresh");
  controlLayout->addWidget(refreshButton);

  toolLayout = new QHBoxLayout;
  controlLayout->addLayout(toolLayout);
  #define tool(widget, icon, text, slot, accel) \
    widget = new QToolButton; \
    toolLayout->addWidget(widget); \
    widget->setAutoRaise(true); \
    widget->setDefaultAction(new QAction(this)); \
    widget->defaultAction()->setIcon(QIcon(":16x16/mem-" icon ".png")); \
    widget->defaultAction()->setToolTip(text); \
    widget->defaultAction()->setShortcut(accel); \
    connect(widget->defaultAction(), SIGNAL(triggered()), this, SLOT(slot()))
  tool(prevCodeButton, "prev-code",    "Previous Code",    prevCode, 0);
  tool(nextCodeButton, "next-code",    "Next Code",        nextCode, 0);
  tool(prevDataButton, "prev-data",    "Previous Data",    prevData, 0);
  tool(nextDataButton, "next-data",    "Next Data",        nextData, 0);
  tool(prevUnkButton,  "prev-unknown", "Previous Unknown", prevUnknown, 0);
  tool(nextUnkButton,  "next-unknown", "Next Unknown",     nextUnknown, 0);
  toolLayout->addStretch();

  toolLayout = new QHBoxLayout;
  controlLayout->addLayout(toolLayout);
  tool(findButton,     "find",         "Find in Memory (Ctrl+F)",  search, Qt::Key_F | Qt::CTRL);
  // TODO: other icons for these maybe
  tool(findPrevButton, "prev-unknown", "Find again up (Shift+F3)", searchPrev, Qt::Key_F3 | Qt::SHIFT);
  tool(findNextButton, "next-unknown", "Find again down (F3)",     searchNext, Qt::Key_F3);
  toolLayout->addStretch();
  #undef tool

  spacer = new QWidget;
  spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
  controlLayout->addWidget(spacer);

  exportButton = new QPushButton("Export");
  controlLayout->addWidget(exportButton);

  importButton = new QPushButton("Import");
  controlLayout->addWidget(importButton);

  statusBar = new QLabel;
  layout->addWidget(statusBar, 1, 0, 1, 2);

  connect(editor, SIGNAL(currentAddressChanged(qint64)), this, SLOT(showAddress(qint64)));
  connect(source, SIGNAL(currentIndexChanged(int)), this, SLOT(sourceChanged(int)));
  connect(addr, SIGNAL(textEdited(const QString&)), this, SLOT(updateOffset()));
  connect(addr, SIGNAL(returnPressed()), this, SLOT(updateOffset()));
  connect(refreshButton, SIGNAL(released()), this, SLOT(refresh()));
  connect(exportButton, SIGNAL(released()), this, SLOT(exportMemory()));
  connect(importButton, SIGNAL(released()), this, SLOT(importMemory()));

  sourceChanged(0);
}
Beispiel #29
0
bool Reference::updateOffset(FILE* file)
{
	long newOffset = _ref->fPosition;
	return updateOffset(file,newOffset);
}
Beispiel #30
0
void CCCameraAppUI::setOffset(const CCVector3 &offsetTarget)
{
    targetOffset = currentOffsetTarget.current = currentOffsetTarget.target = offsetTarget;
    updateOffset( offsetTarget );
}