void DialogRepositionSurface::OnApply()
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindow()->GetActiveLayer("Surface");
  LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindow()->GetActiveLayer("MRI");
  QString msg;
  if ( !surf )
    msg = "No active surface found.";
  else if ( !mri && ui->tabWidget->currentIndex() == 0)
    msg = "No active volume found.";

  if (!msg.isEmpty())
  {
    QMessageBox::warning(this, "Error", msg);
    return;
  }

  if (ValidateAll())
  {
    ui->pushButtonApply->setDisabled(true);
    if (ui->tabWidget->currentIndex() == 0)
    {
      if (ui->comboBoxTarget->currentIndex() == 0)
      {
        surf->RepositionSurface(mri, GetVertex(),
                                GetIntensity(),
                                GetNeighborSize(),
                                GetSigma(),
                                GetFlags());
      }
      else
      {
        double pos[3];
        GetCoordinate(pos);
        surf->RepositionSurface( mri, GetVertex(),
                                       pos,
                                       GetNeighborSize(),
                                       GetSigma(),
                                       GetFlags());
      }
    }
    else if (ui->tabWidget->currentIndex() == 1)
    {
      double pos[3];
      GetCoordinate(pos);
      surf->RepositionVertex(GetVertex(), pos);
    }
    else
    {
      surf->RepositionSmoothSurface(GetVertex(), GetNeighborSize(), GetSmoothingSteps());
    }
    UpdateUI();
    ui->pushButtonApply->setDisabled(false);
    QTimer::singleShot(0, MainWindow::GetMainWindow(), SIGNAL(SlicePositionChanged()));
  }
}
Beispiel #2
0
bool COrgOp::LoadAll( CStr &roSrc )
{
	Clear();
	Load( roSrc, 0 );

	if( m_oLstOp.GetSize() < 2 )
	{
		Clear();
		ORG_OP_LOG( "Fehler: Weniger als 2 Operatoren eingelesen!\n" );
		return false;
	}

	m_poOpRootL_ = m_oLstOp[0];
	m_poOpRootR_ = m_oLstOp[1];
	if( m_poOpRootL_ == 0 || m_poOpRootR_ == 0 )
		return false;

	UpdateAll();
	ValidateAll();
	return true;
}
void DialogRepositionSurface::OnApply( wxCommandEvent& event )
{
  LayerSurface* surf = (LayerSurface*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "Surface" );
  LayerMRI* mri = (LayerMRI*)MainWindow::GetMainWindowPointer()->GetActiveLayer( "MRI" );
  wxString msg;
  if ( !surf )
    msg = _("No active surface found.");
  else if ( !mri )
    msg = _("No active volume found." );
  
  if ( !msg.IsEmpty() )
  {
    wxMessageDialog dlg( this, msg, _("Error"), wxOK );
    dlg.ShowModal();
    return;
  }
  if ( ValidateAll() )
  {
    if ( m_choiceTarget->GetCurrentSelection() == 0 )
    {
      surf->RepositionSurface( mri, GetVertex(), 
                           GetIntensity(),
                           GetNeighborSize(),
                           GetSigma() );
    }
    else
    {
      double pos[3];
      GetCoordinate( pos );
      surf->RepositionSurface( mri, GetVertex(), 
                               pos,
                               GetNeighborSize(),
                               GetSigma() );
    }
    UpdateUI();
  }
}
Beispiel #4
0
bool COrgOp::Load( CStr &roSrc, unsigned int uiIDOffset )
{
	CStr oStrLine;
	CStr oStrToken;
	CList<COp *> oLstPatch;
	unsigned int uiIDIn = 0;
	unsigned int uiIdxIn = 0;
	unsigned int uiCountIn = 0;
	unsigned int uiPortIn = 0;
	unsigned int uiIndexIn = 0;
	unsigned int uiCountOut = 0;
	unsigned int uiPortOut = 0;
	unsigned int uiInteralInt = 0;
	unsigned int uiInteralUInt = 0;
	unsigned int uiInteralFlt = 0;
	unsigned int i = 0;
	unsigned int uiMaxIPortIn = 0;
	unsigned int uiMaxIPortOut = 0;
	unsigned int uiMaxIInternalInt = 0;
	unsigned int uiMaxIInternalUInt = 0;
	unsigned int uiMaxIInternalFlt = 0;
	COp *poOp = 0;
	
	// <mod date="2010-12-07">
	CList<CArray<unsigned int> *> oLstArrID;
	CArray<unsigned int> * poArrID = 0;
	// </mod>
	
	// Alle Operatoren einlesen, erstellen und pseudo-patchen.
	while( 1 )
	{
		if( !Decode_GetNextLine( oStrLine, roSrc ) )
			break;
		i = 0;
		while( 1 )
		{
			if( !Decode_GetNextToken( oStrToken, oStrLine ) )
				break;

			if( !oStrToken.GetSize() )
			{
				if( i > 1 ) // Komprimierung :: -> :0:
					oStrToken = '0';
				else if( i == 0 )
					ORG_OP_LOG( "Fehler: Klassen-Name nicht vorhanden." );
			}

			// class
			if( i == 0 )
			{
				poOp = Create( oStrToken );
				if( poOp == 0 )
				{
					ORG_OP_LOG( "Fehler: Unbekannte Klasse: %s\n", oStrToken.GetData() );
					return false;
				}
				oLstPatch.Append( poOp );
			}
			// instance
			else if( i == 1 )
			{
#ifdef OP_USE_RUNTIME_INFO
				poOp->SetNameInstance( oStrToken );
#endif // OP_USE_RUNTIME_INFO
			}
			// id
			else if( i == 2 )
			{
				unsigned int uiID;
				ORG_OP_SSCANF( oStrToken, "%x", &uiID );
				poOp->SetID( uiID + uiIDOffset ); // Um keinen Konflikt zu erzeugen.
			}
			// flags
			else if( i == 3 )
			{
				unsigned int uiFlags;
				ORG_OP_SSCANF( oStrToken, "%x", &uiFlags );
				poOp->SetFlags( uiFlags );
			}
			// count_input
			else if ( i == 4 )
			{
				ORG_OP_SSCANF( oStrToken, "%x", &uiCountIn );
				if( poOp->GetFlags() & OP_FLAG_DYNAMIC_INPUTS )
				{
					poOp->SetCountIn( uiCountIn );
				}
				else if( poOp->GetCountIn() != uiCountIn )
				{
#ifdef OP_USE_RUNTIME_INFO
					ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Inputs unterstuetzt! "
						     "Keine dynamischen Inputs!\n", poOp->GetNameClass(), uiCountIn );
#endif // OP_USE_RUNTIME_INFO
					return false;
				}
				uiPortIn = 0;
				uiIndexIn = 0;
				uiMaxIPortIn = 3 * uiCountIn + 4 + 1;
				
				// <mod date="2010-12-07">
				poArrID = new CArray<unsigned int>( uiCountIn );
				oLstArrID.Append( poArrID );
				// </mod>
			}
			// inputs
			else if( i < uiMaxIPortIn )
			{
				unsigned int uiVal;
				ORG_OP_SSCANF( oStrToken.GetData(), "%x", &uiVal );
				switch( uiIndexIn )
				{
				case 0: // id
					uiIDIn = uiVal;
				break;
				case 1: // port
					uiIdxIn = uiVal;
				break;
				case 2: // flags
					if( uiIDIn )
						uiIDIn += uiIDOffset; // Um keinen Konflikt zu erzeugen.
					
					// <mod date="2010-12-07">
					poArrID->At( uiPortIn ) = uiIDIn;
					poOp->In( uiPortIn ) = COp::CLink( 0, uiIdxIn, uiVal );
					//poOp->In( uiPortIn ) = COp::CLink( reinterpret_cast<COp *>( uiIDIn ), uiIdxIn, uiVal );
					// </mod>
					
					++uiPortIn;
				break;
				}
				++uiIndexIn;
				if( uiIndexIn == 3 )
					uiIndexIn = 0;
			}

			// count_output
			else if( i == uiMaxIPortIn )
			{
				ORG_OP_SSCANF( oStrToken, "%x", &uiCountOut );
				if( poOp->GetFlags() & OP_FLAG_DYNAMIC_OUTPUTS )
				{
					poOp->SetCountOut( uiCountOut );
				}
				else if( poOp->GetCountOut() != uiCountOut )
				{
#ifdef OP_USE_RUNTIME_INFO
					ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Outputs unterstuetzt! "
						     "Keine dynamischen Outputs!\n", poOp->GetNameClass(), uiCountOut );
#endif // OP_USE_RUNTIME_INFO
					return false;
				}
				uiPortOut = 0;
				uiMaxIPortOut = uiCountOut + uiMaxIPortIn + 1;
			}
			// outputs
			else if( i < uiMaxIPortOut )
			{
				double dVal;
				ORG_OP_SSCANF( oStrToken.GetData(), "%lf", &dVal );
				poOp->Out( uiPortOut ) = dVal;
				++uiPortOut;
			}

			// int internal count
			else if( i == uiMaxIPortOut )
			{
				unsigned int uiCountInternalInt;
				ORG_OP_SSCANF( oStrToken, "%x", &uiCountInternalInt );
				if( poOp->GetCountInternalInt() != uiCountInternalInt )
				{
#ifdef OP_USE_RUNTIME_INFO
					ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Int-Interals unterstuetzt!\n", poOp->GetNameClass(), uiCountIn );
#endif // OP_USE_RUNTIME_INFO
					return false;
				}
				uiInteralInt = 0;
				uiMaxIInternalInt = uiMaxIPortOut + uiCountInternalInt + 1;
			}
			// int internals
			else if( i < uiMaxIInternalInt )
			{
				int iVal;
				ORG_OP_SSCANF( oStrToken.GetData(), "%d", &iVal );
				poOp->SetValueInternalInt( uiInteralInt, iVal );
				++uiInteralInt;
			}
			// uint internal count
			else if( i == uiMaxIInternalInt )
			{
				unsigned int uiCountInternalUInt;
				ORG_OP_SSCANF( oStrToken, "%x", &uiCountInternalUInt );
				if( poOp->GetCountInternalUInt() != uiCountInternalUInt )
				{
#ifdef OP_USE_RUNTIME_INFO
					ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d UInt-Interals unterstuetzt!\n", poOp->GetNameClass(), uiCountIn );
#endif // OP_USE_RUNTIME_INFO
					return false;
				}
				uiInteralUInt = 0;
				uiMaxIInternalUInt = uiMaxIInternalInt + uiCountInternalUInt + 1;
			}
			// uint internals
			else if( i < uiMaxIInternalUInt )
			{
				unsigned int uiVal;
				ORG_OP_SSCANF( oStrToken.GetData(), "%u", &uiVal );
				poOp->SetValueInternalUInt( uiInteralUInt, uiVal );
				++uiInteralUInt;
			}
			// flt internal count
			else if( i == uiMaxIInternalUInt )
			{
				unsigned int uiCountInternalFlt;
				ORG_OP_SSCANF( oStrToken, "%x", &uiCountInternalFlt );
				if( poOp->GetCountInternalFlt() != uiCountInternalFlt )
				{
#ifdef OP_USE_RUNTIME_INFO
					ORG_OP_LOG( "Fehler: Von Klasse %s werden nicht %d Float-Interals unterstuetzt!\n", poOp->GetNameClass(), uiCountIn );
#endif // OP_USE_RUNTIME_INFO
					return false;
				}
				uiInteralFlt = 0;
				uiMaxIInternalFlt = uiMaxIInternalUInt + uiCountInternalFlt + 1;
			}
			// flt internals
			else if( i < uiMaxIInternalFlt )
			{
				double dVal;
				ORG_OP_SSCANF( oStrToken.GetData(), "%lf", &dVal );
				poOp->SetValueInternalFlt( uiInteralFlt, dVal );
				++uiInteralFlt;
			}
			else
				break;
			++i;
		}
	}

	// Pseudo-Patch nun mit echten Verbindungen versehen.
	i = oLstPatch.GetSize();
	/*
	if( i < 2 )
	{
		ORG_OP_LOG( "Fehler: Weniger als 2 Operatoren eingelesen!\n" );
		return false;
	}
	*/

	// Altes Patch löschen.
	//Clear();
	//m_poOpRootL_ = 0;
	//m_poOpRootR_ = 0;
	
	
	// <mod date="2010-12-07">
	oLstArrID.MoveToBack();
	// </mod>
	
	while( i )
	{
		--i;
		poOp = oLstPatch[i];
		
		// <mod date="2010-12-07">
		oLstArrID.GetPrev( &poArrID );
		// </mod>
		
		if( poOp )
		{
			unsigned int uiIn = poOp->GetCountIn();
			while( uiIn )
			{
				--uiIn;
				
				// <mod date="2010-12-07">
				const unsigned int uiTmpIDNext = poArrID->At( uiIn );
				//unsigned int uiTmpIDNext =
				//	reinterpret_cast<unsigned int>( poOp->In( uiIn ).GetOp() );
				// </mod>
				
				if( !uiTmpIDNext ) // ID 0 ist ungültig.
					continue;

				// Ganze Liste durchiterieren, und nach der ID aus dem aktuellen
				// Input-Array Ausschau halten!
				COp *poOpNext;
				oLstPatch.MoveToFront();
				while( oLstPatch.GetNext( &poOpNext ) )
				{
					if( poOpNext->GetID() == uiTmpIDNext )
					{
						poOp->In( uiIn ).SetOp( poOpNext );
					}
				}
			}
		}

		//if( i == 0 )
		//	m_poOpRootL_ = poOp;
		//else if ( i == 1 )
		//	m_poOpRootR_ = poOp;
	}
	
	// <mod date="2010-12-07">
	LIST_DELETE( oLstArrID, CArray<unsigned int> );
	// </mod>
	
	// Alle aufglösten Operatoren in die echte Liste einfügen...
	oLstPatch.MoveToFront();
	while( oLstPatch.GetNext( &poOp ) )
	{
#ifdef OP_USE_USER_DATA
		poOp->m_pvData = 0;
#endif // OP_USE_USER_DATA
		m_oLstOp.Append( poOp );
	}

	//UpdateAll();
	ValidateAll();
	return true;
}
Beispiel #5
0
bool Validate(int alg, bool thorough, const char *seed)
{
	bool result;

	std::string timeSeed;
	if (!seed)
	{
		timeSeed = IntToString(time(NULL));
		seed = timeSeed.c_str();
	}

	cout << "Using seed: " << seed << endl << endl;
	GlobalRNG().Put((const byte *)seed, strlen(seed));

	switch (alg)
	{
	case 1: result = TestSettings(); break;
	case 2: result = TestOS_RNG(); break;
	case 3: result = ValidateMD5(); break;
	case 4: result = ValidateSHA(); break;
	case 5: result = ValidateDES(); break;
	case 6: result = ValidateIDEA(); break;
	case 7: result = ValidateARC4(); break;
	case 8: result = ValidateRC5(); break;
	case 9: result = ValidateBlowfish(); break;
	case 10: result = ValidateDiamond2(); break;
	case 11: result = ValidateThreeWay(); break;
	case 12: result = ValidateBBS(); break;
	case 13: result = ValidateDH(); break;
	case 14: result = ValidateRSA(); break;
	case 15: result = ValidateElGamal(); break;
	case 16: result = ValidateDSA(thorough); break;
	case 17: result = ValidateHAVAL(); break;
	case 18: result = ValidateSAFER(); break;
	case 19: result = ValidateLUC(); break;
	case 20: result = ValidateRabin(); break;
//	case 21: result = ValidateBlumGoldwasser(); break;
	case 22: result = ValidateECP(); break;
	case 23: result = ValidateEC2N(); break;
	case 24: result = ValidateMD5MAC(); break;
	case 25: result = ValidateGOST(); break;
	case 26: result = ValidateTiger(); break;
	case 27: result = ValidateRIPEMD(); break;
	case 28: result = ValidateHMAC(); break;
	case 29: result = ValidateXMACC(); break;
	case 30: result = ValidateSHARK(); break;
	case 32: result = ValidateLUC_DH(); break;
	case 33: result = ValidateLUC_DL(); break;
	case 34: result = ValidateSEAL(); break;
	case 35: result = ValidateCAST(); break;
	case 36: result = ValidateSquare(); break;
	case 37: result = ValidateRC2(); break;
	case 38: result = ValidateRC6(); break;
	case 39: result = ValidateMARS(); break;
	case 40: result = ValidateRW(); break;
	case 41: result = ValidateMD2(); break;
	case 42: result = ValidateNR(); break;
	case 43: result = ValidateMQV(); break;
	case 44: result = ValidateRijndael(); break;
	case 45: result = ValidateTwofish(); break;
	case 46: result = ValidateSerpent(); break;
	case 47: result = ValidateCipherModes(); break;
	case 48: result = ValidateCRC32(); break;
	case 49: result = ValidateECDSA(); break;
	case 50: result = ValidateXTR_DH(); break;
	case 51: result = ValidateSKIPJACK(); break;
	case 52: result = ValidateSHA2(); break;
	case 53: result = ValidatePanama(); break;
	case 54: result = ValidateAdler32(); break;
	case 55: result = ValidateMD4(); break;
	case 56: result = ValidatePBKDF(); break;
	case 57: result = ValidateESIGN(); break;
	case 58: result = ValidateDLIES(); break;
	case 59: result = ValidateBaseCode(); break;
	default: result = ValidateAll(thorough); break;
	}

	time_t endTime = time(NULL);
	cout << "\nTest ended at " << asctime(localtime(&endTime));
	cout << "Seed used was: " << seed << endl;

	return result;
}
Beispiel #6
0
bool Validate(int alg, bool thorough, const char *seedInput)
{
	bool result;

	std::string seed = seedInput ? std::string(seedInput) : IntToString(time(NULL));
	seed.resize(16);

	cout << "Using seed: " << seed << endl << endl;
	s_globalRNG.SetKeyWithIV((byte *)seed.data(), 16, (byte *)seed.data());

	switch (alg)
	{
	case 0: result = ValidateAll(thorough); break;
	case 1: result = TestSettings(); break;
	case 2: result = TestOS_RNG(); break;
	case 3: result = ValidateMD5(); break;
	case 4: result = ValidateSHA(); break;
	case 5: result = ValidateDES(); break;
	case 6: result = ValidateIDEA(); break;
	case 7: result = ValidateARC4(); break;
	case 8: result = ValidateRC5(); break;
	case 9: result = ValidateBlowfish(); break;
//	case 10: result = ValidateDiamond2(); break;
	case 11: result = ValidateThreeWay(); break;
	case 12: result = ValidateBBS(); break;
	case 13: result = ValidateDH(); break;
	case 14: result = ValidateRSA(); break;
	case 15: result = ValidateElGamal(); break;
	case 16: result = ValidateDSA(thorough); break;
//	case 17: result = ValidateHAVAL(); break;
	case 18: result = ValidateSAFER(); break;
	case 19: result = ValidateLUC(); break;
	case 20: result = ValidateRabin(); break;
//	case 21: result = ValidateBlumGoldwasser(); break;
	case 22: result = ValidateECP(); break;
	case 23: result = ValidateEC2N(); break;
//	case 24: result = ValidateMD5MAC(); break;
	case 25: result = ValidateGOST(); break;
	case 26: result = ValidateTiger(); break;
	case 27: result = ValidateRIPEMD(); break;
	case 28: result = ValidateHMAC(); break;
//	case 29: result = ValidateXMACC(); break;
	case 30: result = ValidateSHARK(); break;
	case 32: result = ValidateLUC_DH(); break;
	case 33: result = ValidateLUC_DL(); break;
	case 34: result = ValidateSEAL(); break;
	case 35: result = ValidateCAST(); break;
	case 36: result = ValidateSquare(); break;
	case 37: result = ValidateRC2(); break;
	case 38: result = ValidateRC6(); break;
	case 39: result = ValidateMARS(); break;
	case 40: result = ValidateRW(); break;
	case 41: result = ValidateMD2(); break;
	case 42: result = ValidateNR(); break;
	case 43: result = ValidateMQV(); break;
	case 44: result = ValidateRijndael(); break;
	case 45: result = ValidateTwofish(); break;
	case 46: result = ValidateSerpent(); break;
	case 47: result = ValidateCipherModes(); break;
	case 48: result = ValidateCRC32(); break;
	case 49: result = ValidateECDSA(); break;
	case 50: result = ValidateXTR_DH(); break;
	case 51: result = ValidateSKIPJACK(); break;
	case 52: result = ValidateSHA2(); break;
	case 53: result = ValidatePanama(); break;
	case 54: result = ValidateAdler32(); break;
	case 55: result = ValidateMD4(); break;
	case 56: result = ValidatePBKDF(); break;
	case 57: result = ValidateESIGN(); break;
	case 58: result = ValidateDLIES(); break;
	case 59: result = ValidateBaseCode(); break;
	case 60: result = ValidateSHACAL2(); break;
	case 61: result = ValidateCamellia(); break;
	case 62: result = ValidateWhirlpool(); break;
	case 63: result = ValidateTTMAC(); break;
	case 64: result = ValidateSalsa(); break;
	case 65: result = ValidateSosemanuk(); break;
	case 66: result = ValidateVMAC(); break;
	case 67: result = ValidateCCM(); break;
	case 68: result = ValidateGCM(); break;
	case 69: result = ValidateCMAC(); break;
	default: return false;
	}

	time_t endTime = time(NULL);
	cout << "\nTest ended at " << asctime(localtime(&endTime));
	cout << "Seed used was: " << seed << endl;

	return result;
}