Exemple #1
0
bool TfrmMove::init( const LCDbCryoJob *p_job )
{
	createNewJob = false;
	job = *p_job;
	initDisplay( "Move job " + job.getName() );

	PartFactory rhs( false, false );
	rhs.loadBoxes( job );
	root = rhs.createSiteList();
	if( root == NULL )
	{
		String error = "Cannot create RHS for ";
		error += job.getName().c_str();
		Application -> MessageBox( error.c_str(), NULL, MB_OK );
		return false;
	}

	PartFactory lhs( true, false );
	lhs.loadBoxes( job );
	part = lhs.createSiteList();
	if( part == NULL )
	{
		String error = "Cannot create LHS for ";
		error += job.getName().c_str();
		Application -> MessageBox( error.c_str(), NULL, MB_OK );
		return false;
	}

	int pid = LCDbAuditTrail::getCurrent().getProcessID();
	bool ownJob = (job.getProcessCID() == pid);
	if( !job.claim( jobQuery, ownJob ) )
	{
		String error = "Cannot claim job ";
		error += job.getName().c_str();
		Application -> MessageBox( error.c_str(), NULL, MB_OK );
		return false;
	}

	rightKids.clear();
	makeBoxList( root, rightKids, isUnmappedBox );
	leftKids.clear();
	makeBoxList( part, leftKids, isUnmappedBox );
	mapChildrenByJob();

	TTreeNode* parent = AvlTree->Items->Add( NULL, "Allocated-Storage" );
	parent->Data = (void*)root;
	LoadTree( AvlTree, parent, root );

	parent = SampleTree->Items->Add( NULL, "Items-to-Move" );
	parent->Data = (void*)part;
	LoadTree( SampleTree, parent, part );
	return true;
}
Exemple #2
0
void __fastcall TfrmMove::SignOffClick(TObject *Sender)
{
	if( !allBoxes( part, Util::AVAILABLE ) ) {
		Application->MessageBox( L"Some boxes are not set to \'Done\'", NULL, MB_OK );
		return;
	}

	leftKids.clear();
	makeBoxList( part, leftKids, isDoneBox );
	std::set<int> projects;
	for( Box* bi : leftKids ) {
		projects.insert( bi->getProjectCID() );
	}

	char summary[ 70 ];
	std::sprintf( summary, "%d boxes have been marked \'Done\'", (int) leftKids.size() );
	frmConfirm -> initialise( TfrmSMLogin::MOVE, summary, projects );
	if( frmConfirm->ShowModal() == mrOk ) {
		if( SignOff() ) {
			ModalResult = mrOk;
		} else {
			Application->MessageBox( L"Error updating box location", NULL, MB_OK );
			updateDisplay();
		}
	}
}
Exemple #3
0
void TfrmMove::listCurrentBoxes( bool (*boxfn)(Box* b) )
{
	leftKids.clear();
	rightKids.clear();
	if( current -> TreeView == SampleTree ) {
		makeBoxList( (IPart *) current -> Data, leftKids, boxfn );
		for( std::vector<Box*>::const_iterator bi = leftKids.begin(); bi != leftKids.end(); ++ bi )
			if( boxfn( *bi ) )
				rightKids.push_back( (Box*)((*bi) -> getMapped()) );
	} else {
		makeBoxList( (IPart *) current -> Data, rightKids, boxfn );
		for( std::vector<Box*>::const_iterator bi = rightKids.begin(); bi != rightKids.end(); ++ bi )
			if( boxfn( *bi ) )
				leftKids.push_back( (Box*)((*bi) -> getMapped()) );
	}
}
Exemple #4
0
void TfrmMove::makeBoxList( IPart* item, std::vector<Box*>& boxes, bool (*boxfn)(Box* b) )
{
	Box * b = dynamic_cast<Box*>( item );
	if( b )	{
		if( boxfn( b ) ) {
			boxes.push_back( b );
		}
	} else if( item != NULL ) {
		for( IPart* li : item->getList() ) {
			makeBoxList( li, boxes, boxfn );
		}
	}
}
Exemple #5
0
void __fastcall TfrmMove::AssignClicked(TObject *Sender)
{
	BtnAssign -> Visible = false;
	if( canAssign() ) {
		IPart* leftData = (IPart *)(SampleTree -> Selected -> Data);
		Box* oldBox = dynamic_cast< Box* >( leftData );
		IPart* rightData = (IPart *)(AvlTree -> Selected -> Data);
		Box* newSlot = dynamic_cast< Box* >( rightData );
		if( oldBox && newSlot ) {
			mapBox( oldBox, newSlot );
		} else {
			leftKids.clear();
			Util::ShowSelectedSubTree( SampleTree, 0 );
			makeBoxList( leftData, leftKids, isUnmappedBox );
			rightKids.clear();
			Util::ShowSelectedSubTree( AvlTree, leftKids.size() );
			makeBoxList( rightData, rightKids, isUnmappedBox );
			mapChildren();
		}
	}
	updateDisplay();
}
Exemple #6
0
bool TfrmMove::SignOff()
{
	rightKids.clear();
	makeBoxList( root, rightKids, isDoneBox );
	progress -> Position = 0;
	progress -> Max = rightKids.size();
	for( Box* bi : rightKids ) {
		bi->setStatus( LCDbBoxStore::SLOT_CONFIRMED );
		if( bi->save() ) {
			progress -> StepIt();
		} else {
			return false;
		}
	}
	return true;
}
Exemple #7
0
// FUNCTION ======	setup
void setup(){
	//---- SDL initialization
	if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) {        printf("Unable to initialize SDL: %s\n", SDL_GetError()); getchar() ;    }
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); 
	//screen = SDL_SetVideoMode( WIDTH, HEIGHT, COLDEPTH, SDL_OPENGL |  SDL_SWSURFACE  ); 
	screen = SDL_SetVideoMode( WIDTH, HEIGHT, COLDEPTH, SDL_OPENGL ); 
    if(!screen)  { printf("Couldn't set %dx%d GL video mode: %s\n", WIDTH,HEIGHT, SDL_GetError()); SDL_Quit();  exit(2); }
	SDL_WM_SetCaption(" Prokop's test SDL+ OpenGL", "SDL+ OpenGL");

	//materialy
	float ambient  [] = { 0.10f, 0.15f, 0.25f, 1.0f}; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT,   ambient);
	float diffuse  [] = { 0.50f, 0.50f, 0.50f, 1.0f}; glMaterialfv (GL_FRONT_AND_BACK, GL_DIFFUSE,   diffuse);
	float specular [] = { 0.00f, 0.00f, 0.00f, 1.0f}; glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR,  specular);
	float shininess[] = { 0.0f                     }; glMaterialfv (GL_FRONT_AND_BACK, GL_SHININESS, shininess);
	glEnable  (GL_LIGHT0);
	float light0_pos  [] = { 1000.0f, 0.0f, 0.0f, 1.00f}; glLightfv (GL_LIGHT0, GL_POSITION, light0_pos  );
	float light0_color[] = { 0.8f, 0.5f, 0.5f, 1.00f}; glLightfv (GL_LIGHT0, GL_DIFFUSE,  light0_color);
	glEnable  (GL_LIGHT1);
	float light1_pos  [] = { 0.0f, 1000.0f, 0.0f, 1.00f}; glLightfv (GL_LIGHT1, GL_POSITION, light1_pos  );
	float light1_color[] = { 0.5f, 0.8f, 0.5f, 1.00f}; glLightfv (GL_LIGHT1, GL_DIFFUSE,  light1_color);
	glEnable  (GL_LIGHT2);
	float light2_pos  [] = { 0.0f, 0.0f, 1000.0f, 1.00f}; glLightfv (GL_LIGHT2, GL_POSITION, light2_pos  );
	float light2_color[] = { 0.5f, 0.5f, 0.8f, 1.00f}; glLightfv (GL_LIGHT2, GL_DIFFUSE,  light2_color);
	glEnable  (GL_LIGHTING);
	glEnable (GL_COLOR_MATERIAL);
	glEnable  (GL_NORMALIZE);
	glEnable  (GL_DEPTH_TEST);
	//glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	//glEnable(GL_BLEND) ;
	//glBlendFunc (GL_SRC_ALPHA, GL_SRC_ALPHA);
	glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);	
	glShadeModel(GL_SMOOTH);
	glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);

	glClearColor( 0.9, 0.9, 0.9, 0.0);                      
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );   

	srand(1234);

	trackball (qCamera, 0, 0, 0, 0); // qCameraOld[3] = 1.0;


	printf( "1\n" );

	body.pos.set( 1,1,1 ); 
	body.vel.set( 1,-1,1 );

	//const int len = 6; 
	//double masses[len]  = { 1,1, 1,1, 1,1 };
	//Vec3d  poss[len]    = { {-1,0,0}, {+1,0,0}, {0,-2,0}, {0,+2,0}, {0,0,-3}, {0,0,+3} }
	//printf( " %f %f \n", poss[0].x, poss_[0]  );

	printf( "2\n" );

	int boxList = makeBoxList( -1,1, -2,2, -3, 3,    0.9, 0.9, 0.9  );
	//rbody.shape = boxList;
	rbody.from_mass_points( len, masses, poss );
	//rbody.qrot.setOne();

	printf( "3\n" );

	rbody.qrot.set(4,-3,2,-1);	rbody.qrot.normalize();
	//rbody.pos.add( 5.0d,5.0d,5.0d );

	printf( "4\n" );

	rbody.vel.set(0.0);
	//rbody.L  .set(10,10,10);
	rbody.init( );
	rbody.shape = shapePointsCenter( len, poss, rbody.pos, 0.5 );

	printf( "5\n" );


	rbody2.shape = boxList;
	rbody2.from_mass_points( len, masses, poss );
	rbody2.qrot.setOne();
	rbody2.vel.set(0.0);
	//rbody2.L  .set(10,10,10);
	rbody2.init( );
	constrain1 = new SpringConstrain( 20, &rbody, &rbody2, {-1,-2,-3}, {1,2,3} );
	//Vec3d p1,p2; p1.set(-1,-2,-3); p2.set(1,2,3);
	//constrain1 = new SpringConstrain( 20, &rbody, &rbody2, p1, p2 );


	printf("mass: %f invMass %f \n", rbody.mass, rbody.invMass  );
	printf("Ibody\n");
	printMat(rbody.Ibody);
	printf("invIbody\n");
	printMat(rbody.invIbody);
}