示例#1
0
void SampleTCO::setSampleFile( const QString & _sf )
{
	m_sampleBuffer->setAudioFile( _sf );
	updateLength();

	emit sampleChanged();
}
示例#2
0
void
TrackComponentSettings::updateObserver()
{

    // Get change flags //
    //
    int changes = trackComponent_->getTrackComponentChanges();

    // TrackComponent //
    //
    if ((changes & TrackComponent::CTC_ParentChanged)
        || (changes & TrackComponent::CTC_TransformChange)
        || (changes & TrackComponent::CTC_SChange)
        || (changes & TrackComponent::CTC_LengthChange)
        || (changes & TrackComponent::CTC_ShapeChange))
    {
        updateTransformation();
        updateS();
        updateLength();
        updateCurvature();
    }

    // Parent //
    //
    SettingsElement::updateObserver();
}
示例#3
0
OdometryDisplay::OdometryDisplay()
  : Display()
  , messages_received_(0)
{
  topic_property_ = new RosTopicProperty( "Topic", "",
                                          QString::fromStdString( ros::message_traits::datatype<nav_msgs::Odometry>() ),
                                          "nav_msgs::Odometry topic to subscribe to.",
                                          this, SLOT( updateTopic() ));

  color_property_ = new ColorProperty( "Color", QColor( 255, 25, 0 ),
                                       "Color of the arrows.",
                                       this, SLOT( updateColor() ));

  position_tolerance_property_ = new FloatProperty( "Position Tolerance", .1,
                                                    "Distance, in meters from the last arrow dropped, "
                                                    "that will cause a new arrow to drop.",
                                                    this );
  position_tolerance_property_->setMin( 0 );
                                                
  angle_tolerance_property_ = new FloatProperty( "Angle Tolerance", .1,
                                                 "Angular distance from the last arrow dropped, "
                                                 "that will cause a new arrow to drop.",
                                                 this );
  angle_tolerance_property_->setMin( 0 );

  keep_property_ = new IntProperty( "Keep", 100,
                                    "Number of arrows to keep before removing the oldest.  0 means keep all of them.",
                                    this );
  keep_property_->setMin( 0 );

  length_property_ = new FloatProperty( "Length", 1.0,
                                        "Length of each arrow.",
                                        this, SLOT( updateLength() ));
}
示例#4
0
void ScrollViewBar::onScrolled(const Vec2& outOfBoundary)
{
    if(_autoHideEnabled)
    {
        _autoHideRemainingTime = _autoHideTime;
        ProtectedNode::setOpacity(_opacity);
    }
    
    Layout* innerContainer = _parent->getInnerContainer();
    
    float innerContainerMeasure = 0;
    float scrollViewMeasure = 0;
    float outOfBoundaryValue = 0;
    float innerContainerPosition = 0;
    if(_direction == ScrollView::Direction::VERTICAL)
    {
        innerContainerMeasure = innerContainer->getContentSize().height;
        scrollViewMeasure = _parent->getContentSize().height;
        outOfBoundaryValue = outOfBoundary.y;
        innerContainerPosition = -innerContainer->getPositionY();
    }
    else if(_direction == ScrollView::Direction::HORIZONTAL)
    {
        innerContainerMeasure = innerContainer->getContentSize().width;
        scrollViewMeasure = _parent->getContentSize().width;
        outOfBoundaryValue = outOfBoundary.x;
        innerContainerPosition = -innerContainer->getPositionX();
    }
    
    float length = calculateLength(innerContainerMeasure, scrollViewMeasure, outOfBoundaryValue);
    Vec2 position = calculatePosition(innerContainerMeasure, scrollViewMeasure, innerContainerPosition, outOfBoundaryValue, length);
    updateLength(length);
    setPosition(position);
}
void changeLength(DoubleIntArrPointer *possible, int solution[SIZE][SIZE], int possibleLen[SIZE][SIZE], int solutionNum, int row, int col){
	int change, changeCol, changeRow;
	
	//row
	for(change = 0; change < SIZE; change++){
		if(solution[row][change] == EMPTY){
			possible[row][change][solutionNum - 1] = 0;
		}
	}
				
	//column
	for(change = 0; change < SIZE; change++){
		if(solution[change][col] == EMPTY){
			possible[change][col][solutionNum - 1] = 0;
		}
	}
				
	//box
	for(changeRow = (row/3)*3; changeRow < ((row/3)*3 + 3); changeRow++){
		for(changeCol = (col/3)*3; changeCol < ((col/3)*3 + 3); changeCol++){
			if(solution[changeRow][changeCol] == EMPTY){
				possible[changeRow][changeCol][solutionNum - 1] = 0;
			}
		}
	}
				
	updateLength(possible, possibleLen);
}
示例#6
0
SampleTCO::SampleTCO( Track * _track ) :
	TrackContentObject( _track ),
	m_sampleBuffer( new SampleBuffer )
{
	saveJournallingState( false );
	setSampleFile( "" );
	restoreJournallingState();

	// we need to receive bpm-change-events, because then we have to
	// change length of this TCO
	connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ),
					this, SLOT( updateLength( bpm_t ) ) );
	switch( getTrack()->trackContainer()->type() )
	{
		case TrackContainer::BBContainer:
			setAutoResize( true );
			break;

		case TrackContainer::SongContainer:
			// move down
		default:
			setAutoResize( false );
			break;
	}
}
示例#7
0
void SampleTCO::setSampleBuffer( SampleBuffer* sb )
{
	sharedObject::unref( m_sampleBuffer );
	m_sampleBuffer = sb;
	updateLength();

	emit sampleChanged();
}
示例#8
0
TrackComponentSettings::TrackComponentSettings(ProjectSettings *projectSettings, SettingsElement *parentSettingsElement, TrackComponent *trackComponent)
    : SettingsElement(projectSettings, parentSettingsElement, trackComponent)
    , ui(new Ui::TrackComponentSettings)
    , trackComponent_(trackComponent)
    , line_(NULL)
    , arc_(NULL)
    , spiral_(NULL)
    , poly3_(NULL)
    , sparcs_(NULL)
{
    ui->setupUi(this);

    // Casts //
    //
    TrackComponent::DTrackType type = trackComponent_->getTrackType();
    if (type == TrackComponent::DTT_LINE)
    {
        ui->groupBox->setTitle(tr("line"));
        line_ = dynamic_cast<TrackElementLine *>(trackComponent_);
    }
    else if (type == TrackComponent::DTT_ARC)
    {
        ui->groupBox->setTitle(tr("arc"));
        arc_ = dynamic_cast<TrackElementArc *>(trackComponent_);
    }
    else if (type == TrackComponent::DTT_SPIRAL)
    {
        ui->groupBox->setTitle(tr("spiral"));
        spiral_ = dynamic_cast<TrackElementSpiral *>(trackComponent_);
    }
    else if (type == TrackComponent::DTT_POLY3)
    {
        ui->groupBox->setTitle(tr("poly3"));
        poly3_ = dynamic_cast<TrackElementPoly3 *>(trackComponent_);
    }
    else if (type == TrackComponent::DTT_COMPOSITE)
    {
        ui->groupBox->setTitle(tr("composite"));
    }
    else if (type == TrackComponent::DTT_SPARCS)
    {
        ui->groupBox->setTitle(tr("spiral-arc-spiral"));
        sparcs_ = dynamic_cast<TrackSpiralArcSpiral *>(trackComponent_);
    }
    else
    {
        ui->groupBox->setTitle(tr("unknown type"));
    }

    updateTransformation();
    updateS();
    updateLength();
    updateCurvature();
}
示例#9
0
文件: timeline.cpp 项目: 4423Q/pencil
void TimeLine::forceUpdateLength(QString newLength)
{
    bool ok;
    int dec = newLength.toInt(&ok, 10);

    if ( dec > getFrameLength())
    {
        updateLength(dec);
        updateContent();
        QSettings settings("Pencil","Pencil");
        settings.setValue("length", dec);
    }
}
示例#10
0
void Dialog2::changeAtom2(int index)
{
   if((*list2)[index]!=index2){
   index2=(*list2)[index];
   currentAtom2=view->getAtom(index2);

   makeComboList(atomSelect1,1);
   index=find(*list1,index1);
   atomSelect1->setCurrentItem(index);
   updateLength();
   }
//   emit atomChanged();
}
示例#11
0
sampleTCO::sampleTCO( track * _track ) :
	trackContentObject( _track ),
	m_sampleBuffer( new sampleBuffer )
{
	saveJournallingState( false );
	setSampleFile( "" );
	restoreJournallingState();

	// we need to receive bpm-change-events, because then we have to
	// change length of this TCO
	connect( engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ),
					this, SLOT( updateLength( bpm_t ) ) );
}
示例#12
0
// Constructor for hardware SPI -- must connect to MOSI, SCK pins
Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t o) :
 numLEDs(n), dataPin(USE_HW_SPI), brightness(0), pixels(NULL),
 rOffset(o & 3), gOffset((o >> 2) & 3), bOffset((o >> 4) & 3)
{
  updateLength(n);
}

// Constructor for 'soft' (bitbang) SPI -- any two pins can be used
Adafruit_DotStar::Adafruit_DotStar(uint16_t n, uint8_t data, uint8_t clock,
  uint8_t o) :
 dataPin(data), clockPin(clock), brightness(0), pixels(NULL),
 rOffset(o & 3), gOffset((o >> 2) & 3), bOffset((o >> 4) & 3)
{
  updateLength(n);
}

Adafruit_DotStar::~Adafruit_DotStar(void) { // Destructor
  if(pixels)                free(pixels);
  if(dataPin == USE_HW_SPI) hw_spi_end();
  else                      sw_spi_end();
}

void Adafruit_DotStar::begin(void) { // Initialize SPI
  if(dataPin == USE_HW_SPI) hw_spi_init();
  else                      sw_spi_init();
}

// Pins may be reassigned post-begin(), so a sketch can store hardware
// config in flash, SD card, etc. rather than hardcoded.  Also permits
// "recycling" LED ram across multiple strips: set pins to first strip,
// render & write all data, reassign pins to next strip, render & write,
// etc.  They won't update simultaneously, but usually unnoticeable.

// Change to hardware SPI -- must connect to MOSI, SCK pins
void Adafruit_DotStar::updatePins(void) {
  sw_spi_end();
  dataPin = USE_HW_SPI;
  hw_spi_init();
}
示例#13
0
void frAnimationClip::cleanup()
{
  updateLength();

	elementListIt it = m_elements.begin();

	while (it != m_elements.end())
	{
		if (it->len==0)
			it=m_elements.erase(it);
		else
			++it;
	}
}
示例#14
0
void frAnimationClip::deleteElementsReferringClip(sU32 clipID)
{
	elementListIt it = m_elements.begin();

	while (it != m_elements.end())
  {
    if (it->type == 1 && it->id == clipID)
      it = m_elements.erase(it);
    else
      ++it;
  }

  updateLength();
}
示例#15
0
    void* MemoryMappedFile::map(const char *filenameIn, long &length, int options) {
        _filename = filenameIn;
        /* big hack here: Babble uses db names with colons.  doesn't seem to work on windows.  temporary perhaps. */
        char filename[256];
        strncpy(filename, filenameIn, 255);
        filename[255] = 0;
        { 
            size_t len = strlen( filename );
            for ( size_t i=len-1; i>=0; i-- ){
                if ( filename[i] == '/' ||
                     filename[i] == '\\' )
                    break;
                
                if ( filename[i] == ':' )
                    filename[i] = '_';
            }
        }

        updateLength( filename, length );

        DWORD createOptions = FILE_ATTRIBUTE_NORMAL;
        if ( options & SEQUENTIAL )
            createOptions |= FILE_FLAG_SEQUENTIAL_SCAN;

        fd = CreateFile(
                 toNativeString(filename).c_str(),
                 GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ,
                 NULL, OPEN_ALWAYS, createOptions , NULL);
        if ( fd == INVALID_HANDLE_VALUE ) {
            out() << "Create/OpenFile failed " << filename << ' ' << GetLastError() << endl;
            return 0;
        }

        mapped += length;

        maphandle = CreateFileMapping(fd, NULL, PAGE_READWRITE, 0, length, NULL);
        if ( maphandle == NULL ) {
            out() << "CreateFileMapping failed " << filename << ' ' << GetLastError() << endl;
            return 0;
        }

        view = MapViewOfFile(maphandle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
        if ( view == 0 ) {
            out() << "MapViewOfFile failed " << filename << " " << errnoWithDescription() << " ";
            out() << GetLastError();
            out() << endl;
        }
        len = length;
        return view;
    }
示例#16
0
/** Extends the timeline frame length if necessary
 *
 *  @param[in] frame The new animation length
 */
void TimeLine::extendLength(int frame)
{
    int currentLength = mTracks->getFrameLength();
    if(frame > (currentLength * 0.75))
    {
        int newLength = std::max(frame, currentLength) * 1.5;

        if (newLength > 9999)
            newLength = 9999;

        mTracks->setFrameLength(newLength);
        updateLength();
    }
}
示例#17
0
void Dialog2::changeAtom1(int index)
{
   if((*list1)[index]!=index1){
   index1=(*list1)[index];
   currentAtom1=view->getAtom(index1);
//   makeComboList(atomSelect1,1);
//   atomSelect1->setCurrentItem(index);
   
   makeComboList(atomSelect2,2);
   index=find(*list2,index2);
   atomSelect2->setCurrentItem(index);
   updateLength();
   }
}
示例#18
0
void Dialog2::setupComboBox(QComboBox *box,int which)
{
  makeComboList(box,which);

  switch(which){
    case 1:
      connect(box,SIGNAL(activated(int)),this,SLOT(changeAtom1(int))); 
      break;
    case 2:
      updateLength();
      connect(box,SIGNAL(activated(int)),this,SLOT(changeAtom2(int))); 
      break;
   }
}
示例#19
0
文件: SampleTrack.cpp 项目: LMMS/lmms
SampleTCO::SampleTCO( Track * _track ) :
	TrackContentObject( _track ),
	m_sampleBuffer( new SampleBuffer ),
	m_isPlaying( false )
{
	saveJournallingState( false );
	setSampleFile( "" );
	restoreJournallingState();

	// we need to receive bpm-change-events, because then we have to
	// change length of this TCO
	connect( Engine::getSong(), SIGNAL( tempoChanged( bpm_t ) ),
					this, SLOT( updateLength() ), Qt::DirectConnection );
	connect( Engine::getSong(), SIGNAL( timeSignatureChanged( int,int ) ),
					this, SLOT( updateLength() ) );

	//care about positionmarker
	TimeLineWidget * timeLine = Engine::getSong()->getPlayPos( Engine::getSong()->Mode_PlaySong ).m_timeLine;
	if( timeLine )
	{
		connect( timeLine, SIGNAL( positionMarkerMoved() ), this, SLOT( playbackPositionChanged() ) );
	}
	//playbutton clicked or space key / on Export Song set isPlaying to false
	connect( Engine::getSong(), SIGNAL( playbackStateChanged() ),
			this, SLOT( playbackPositionChanged() ), Qt::DirectConnection );
	//care about loops
	connect( Engine::getSong(), SIGNAL( updateSampleTracks() ),
			this, SLOT( playbackPositionChanged() ), Qt::DirectConnection );
	//care about mute TCOs
	connect( this, SIGNAL( dataChanged() ), this, SLOT( playbackPositionChanged() ) );
	//care about mute track
	connect( getTrack()->getMutedModel(), SIGNAL( dataChanged() ),
			this, SLOT( playbackPositionChanged() ), Qt::DirectConnection );
	//care about TCO position
	connect( this, SIGNAL( positionChanged() ), this, SLOT( updateTrackTcos() ) );

	switch( getTrack()->trackContainer()->type() )
	{
		case TrackContainer::BBContainer:
			setAutoResize( true );
			break;

		case TrackContainer::SongContainer:
			// move down
		default:
			setAutoResize( false );
			break;
	}
	updateTrackTcos();
}
示例#20
0
void TscoreTie::checkStaves() {
  if ((m_extraTieItem == nullptr) != (firstNote()->staff() == secondNote()->staff())) {
      if (m_extraTieItem) {
          delete m_extraTieItem;
          m_extraTieItem = nullptr;
      } else {
          m_extraTieItem = newTie(secondNote());
          QTransform t;
          t.scale(1.0, secondNote()->note()->rtm.stemDown() ? -1.0 : 1.0);
          m_extraTieItem->setTransform(t);
          m_extraTieItem->setPos(-m_extraTieItem->boundingRect().width(),
                                 secondNote()->notePos() + (secondNote()->note()->rtm.stemDown() ? 3.7 : - 1.8));
      }
      updateLength();
  }
}
示例#21
0
TscoreTie::TscoreTie(TscoreNote* sn1, TscoreNote* sn2) :
  m_firstNote(sn1),
  m_scondNote(sn2)
{
  if (firstNote()->note()->rtm.tie()) // continue tie if first note already belongs to someone
    firstNote()->note()->rtm.setTie(Trhythm::e_tieCont);
  else // or start a new one
    firstNote()->note()->rtm.setTie(Trhythm::e_tieStart);

  if (secondNote()->tie()) // second note has a tie so set it to continue
    secondNote()->note()->rtm.setTie(Trhythm::e_tieCont);
  else // or end the tie on second note
    secondNote()->note()->rtm.setTie(Trhythm::e_tieEnd);

  m_tieItem = newTie(firstNote());
  updateLength();
  checkStaves();
}
示例#22
0
void AutomationPattern::loadSettings( const QDomElement & _this )
{
	clear();

	movePosition( _this.attribute( "pos" ).toInt() );
	setName( _this.attribute( "name" ) );
	setProgressionType( static_cast<ProgressionTypes>( _this.attribute(
							"prog" ).toInt() ) );
	setTension( _this.attribute( "tens" ) );
	setMuted(_this.attribute( "mute", QString::number( false ) ).toInt() );

	for( QDomNode node = _this.firstChild(); !node.isNull();
						node = node.nextSibling() )
	{
		QDomElement element = node.toElement();
		if( element.isNull()  )
		{
			continue;
		}
		if( element.tagName() == "time" )
		{
			m_timeMap[element.attribute( "pos" ).toInt()]
				= element.attribute( "value" ).toFloat();
		}
		else if( element.tagName() == "object" )
		{
			m_idsToResolve << element.attribute( "id" ).toInt();
		}
	}

	int len = _this.attribute( "len" ).toInt();
	if( len <= 0 )
	{
		// TODO: Handle with an upgrade method
		updateLength();
	}
	else
	{
		changeLength( len );
	}
	generateTangents();
}
示例#23
0
void AutomationPattern::removeValue( const MidiTime & time )
{
	cleanObjects();

	m_timeMap.remove( time );
	m_tangents.remove( time );
	timeMap::const_iterator it = m_timeMap.lowerBound( time );
	if( it != m_timeMap.begin() )
	{
		--it;
	}
	generateTangents(it, 3);

	if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack )
	{
		updateLength();
	}

	emit dataChanged();
}
示例#24
0
MidiTime AutomationPattern::putValue( const MidiTime & time,
					const float value,
					const bool quantPos,
					const bool ignoreSurroundingPoints )
{
	cleanObjects();

	MidiTime newTime = quantPos ?
				Note::quantized( time, quantization() ) :
				time;

	m_timeMap[ newTime ] = value;
	timeMap::const_iterator it = m_timeMap.find( newTime );

	// Remove control points that are covered by the new points
	// quantization value. Control Key to override
	if( ! ignoreSurroundingPoints )
	{
		for( int i = newTime + 1; i < newTime + quantization(); ++i )
		{
			AutomationPattern::removeValue( i );
		}
	}
	if( it != m_timeMap.begin() )
	{
		--it;
	}
	generateTangents( it, 3 );

	// we need to maximize our length in case we're part of a hidden
	// automation track as the user can't resize this pattern
	if( getTrack() && getTrack()->type() == Track::HiddenAutomationTrack )
	{
		updateLength();
	}

	emit dataChanged();

	return newTime;
}
示例#25
0
    void* MemoryMappedFile::map(const char *filenameIn, unsigned long long &length, int options) {
        setFilename(filenameIn);
        /* big hack here: Babble uses db names with colons.  doesn't seem to work on windows.  temporary perhaps. */
        char filename[256];
        strncpy(filename, filenameIn, 255);
        filename[255] = 0;
        {
            size_t len = strlen( filename );
            for ( size_t i=len-1; i>=0; i-- ) {
                if ( filename[i] == '/' ||
                        filename[i] == '\\' )
                    break;

                if ( filename[i] == ':' )
                    filename[i] = '_';
            }
        }

        updateLength( filename, length );

        {
            DWORD createOptions = FILE_ATTRIBUTE_NORMAL;
            if ( options & SEQUENTIAL )
                createOptions |= FILE_FLAG_SEQUENTIAL_SCAN;
            DWORD rw = GENERIC_READ | GENERIC_WRITE;
            fd = CreateFile(
                     toNativeString(filename).c_str(),
                     rw, // desired access
                     FILE_SHARE_WRITE | FILE_SHARE_READ, // share mode
                     NULL, // security
                     OPEN_ALWAYS, // create disposition
                     createOptions , // flags
                     NULL); // hTempl
            if ( fd == INVALID_HANDLE_VALUE ) {
                DWORD e = GetLastError();
                log() << "Create/OpenFile failed " << filename << " errno:" << e << endl;
                return 0;
            }
        }

        mapped += length;

        {
            DWORD flProtect = PAGE_READWRITE; //(options & READONLY)?PAGE_READONLY:PAGE_READWRITE;
            maphandle = CreateFileMapping(fd, NULL, flProtect,
                                          length >> 32 /*maxsizehigh*/,
                                          (unsigned) length /*maxsizelow*/,
                                          NULL/*lpName*/);
            if ( maphandle == NULL ) {
                DWORD e = GetLastError(); // log() call was killing lasterror before we get to that point in the stream
                log() << "CreateFileMapping failed " << filename << ' ' << errnoWithDescription(e) << endl;
                return 0;
            }
        }

        void *view = 0;
        {
            scoped_lock lk(mapViewMutex);
            DWORD access = (options&READONLY)? FILE_MAP_READ : FILE_MAP_ALL_ACCESS;
            view = MapViewOfFile(maphandle, access, /*f ofs hi*/0, /*f ofs lo*/ 0, /*dwNumberOfBytesToMap 0 means to eof*/0);
        }
        if ( view == 0 ) {
            DWORD e = GetLastError();
            log() << "MapViewOfFile failed " << filename << " " << errnoWithDescription(e) << endl;
        }
        else {
            views.push_back(view);
        }
        len = length;

        return view;
    }
void updateTrickRow(DoubleIntArrPointer *possible, int solution[SIZE][SIZE], int possibleLen[SIZE][SIZE]){
	for(int colBox = 0; colBox < SQUARES; colBox++){
		for(int rowBox = 0; rowBox < SQUARES; rowBox++){
			int fullCount = 0;
			
			//Look at box
			for (int col = 0; col < SQUARES; col++){
				for(int row = 0; row < SQUARES; row++){
					if (solution[3*rowBox + row][3*colBox + col] != EMPTY){
						fullCount++;
					}
				}
			}
		
			if(fullCount >= 6){
				for(int row = 0; row < SQUARES; row++){
					int sequenceCount = 0;
					stack <int> num;		
					
					for(int col = 0; col < SQUARES; col++){
						if(solution[3*rowBox + row][3*colBox + col] == EMPTY){
							sequenceCount++;
						}
					}
		
					if(sequenceCount == 2 && fullCount == 7){
						for(int col = 0; col < SQUARES; col++){
							if(solution[3*rowBox + row][3*colBox + col] == EMPTY){
								for(int i = 0; i < SIZE; i++){
									if(possible[3*rowBox + row][3*colBox + col][i] != EMPTY){
										num.push(possible[3*rowBox + row][3*colBox + col][i]);
									}
								}
							}
						}			
						
					}else if(sequenceCount == 3 && fullCount == 6){
						for (int col = 0; col < SQUARES; col++){
							for(int i = 0; i < SIZE; i++){
								if(possible[3*rowBox + row][3*colBox + col][i] != EMPTY){
									num.push(possible[3*rowBox + row][3*colBox + col][i]);
								}
							}
						}
					}
					
					//Update the corresponding rows
					if(colBox == 0){
						while(!num.empty()){
							for(int i = 3; i < 9; i++){
								if(solution[3*rowBox + row][i] == EMPTY){
									possible[3*rowBox + row][i][num.top() - 1] = 0;
								}
							}
							num.pop();
						}
					}else if (colBox == 1){
						while(!num.empty()){
							for(int i = 0; i < 3; i++){
								possible[3*rowBox + row][i][num.top() - 1] = 0;
							}
							
							for(int i = 6; i < 9; i++){
								possible[3*rowBox + row][i][num.top() - 1] = 0;
							}
							num.pop();
						}
					}else if(colBox == 2){
						while(!num.empty()){
							for(int i = 0; i < 6; i++){
								if(solution[3*rowBox + row][i] == EMPTY){
									possible[3*rowBox + row][i][num.top() - 1] = 0;
								}
							}
							num.pop();
						}
					}
					updateLength(possible, possibleLen);
				}
			}
		}
	}
}
void updateTrickRowAdvanced(DoubleIntArrPointer *possible, int solution[SIZE][SIZE], int possibleLen[SIZE][SIZE], int testNum){
	stack <int> rowStack;
	
	for(int rowBox = 0; rowBox < SQUARES; rowBox++){
		for(int colBox = 0; colBox < SQUARES; colBox++){
			int stat = 0;
			bool isSame = true;
			
			for(int row = 0; row < SQUARES; row++){
				for(int col = 0; col < SQUARES; col++){
					if(possible[3*rowBox + row][3*colBox + col][testNum - 1] != EMPTY){
						rowStack.push(row);
					}
				}
			}
		
			if(!rowStack.empty()){
				stat = rowStack.top();
			}else{
				isSame = false;
			}
			
			//Check if that number only appears in one column
			while(!rowStack.empty() && rowStack.size() > 1){
				
				rowStack.pop();
				
				if(!rowStack.empty() && rowStack.top() != stat){
					isSame = false;
					
					while(!rowStack.empty()){
						rowStack.pop();
					}
				}
			}

			
			
			if(isSame == true){
				//Update the corresponding columns
					if(colBox == 0){
						for(int i = 3; i < 9; i++){
							if(solution[3*rowBox + stat][i] == EMPTY){
								possible[3*rowBox + stat][i][testNum - 1] = 0;
							}
						}
					}else if (colBox == 1){
						for(int i = 0; i < 3; i++){
							possible[3*rowBox + stat][i][testNum - 1] = 0;
						}
						
						for(int i = 6; i < 9; i++){
							possible[3*rowBox + stat][i][testNum - 1] = 0;
						}
					}else if(colBox == 2){
						for(int i = 0; i < 6; i++){
							if(solution[3*rowBox + stat][i] == EMPTY){
								possible[3*rowBox + stat][i][testNum - 1] = 0;
							}
						}
					}
					updateLength(possible, possibleLen);
			}
			
			while(!rowStack.empty()){
				rowStack.pop();
			}
		}
	}
}
void setUpChecks(DoubleIntArrPointer *possible, int array[SIZE][SIZE], int arrayLength[SIZE][SIZE]){
	stack <int> done;
	
	for(int rowBox = 0; rowBox < SQUARES; rowBox++){
		for (int colBox = 0; colBox < SQUARES; colBox++){
			
			for(int row = 0; row < 3; row++){
				for (int col = 0; col < 3; col++){
					if (array[rowBox*3 + row][colBox*3 + col] != EMPTY){
						done.push(array[rowBox*3 + row][colBox*3 + col]);
					}
				}
			}
			
			while(!done.empty()){		
				for (int row = 0; row < 3; row++){
					for (int col = 0; col < 3; col++){
						if (array[rowBox*3 + row][colBox*3 + col] == EMPTY){
							possible[rowBox*3 + row][colBox*3 + col][done.top() - 1] = EMPTY;
						}
					}	
				}
		
				done.pop();
			}
		}
	}
	
	for(int row = 0; row < SIZE; row++){
		for (int i = 0; i < SIZE; i++){
			if (array[row][i] != EMPTY){
				done.push(array[row][i]);
			}
		}

		while(!done.empty()){		
			for (int i = 0; i < SIZE; i++){
				if (array[row][i] == EMPTY){
					possible[row][i][done.top() - 1] = EMPTY;
				}
			}
		
			done.pop();
		}
	}
	
	for(int col = 0; col < SIZE; col++){
		for (int i = 0; i < SIZE; i++){
			if (array[i][col] != EMPTY){
				done.push(array[i][col]);
			}
		}

		while(!done.empty()){		
			for (int i = 0; i < SIZE; i++){
				if (array[i][col] == EMPTY){
					possible[i][col][done.top() - 1] = EMPTY;
				}
			}
		
			done.pop();
		}
	}
	
	updateLength(possible, arrayLength);
}
示例#29
0
// Constructor for use with arbitrary clock/data pins:
LPD8806::LPD8806(uint16_t n, uint8_t dpin, uint8_t cpin) {
  pixels = NULL;
  begun  = false;
  updateLength(n);
  updatePins(dpin, cpin);
}
示例#30
0
// Constructor for use with hardware SPI (specific clock/data pins):
LPD8806::LPD8806(uint16_t n) {
  pixels = NULL;
  begun  = false;
  updateLength(n);
  updatePins();
}