Пример #1
0
void __fastcall TDesignFrm::btAddSubHeadClick(TObject *Sender)
{
    String  key = vleHeadDef->Keys[vleHeadDef->Row];
    if(key == "")
    {
        ShowMessage("请先选择封包头!");
        return;
    }

    String  fileName;
    if(InputQuery("输入文件名(不加后缀)", "输入文件名(不加后缀)", fileName))
    {
        if(fileName == "")
            return;

        if(fileName.Pos("."))
            fileName = LeftString(fileName, ".");
        fileName += ".eggxp";

        WorkSpace	*  selWorkSpace = m_WorkSpaceManager->CreateNewWorkSpace();
        selWorkSpace->InitWorkSpace(m_WorkSpaceManager->GetFilePath(),
                    fileName, key);
        selWorkSpace->SaveToFile();
        m_WorkSpaceManager->ReloadWorkSpacePack();
        WorkspaceToGUI();
    }
}
Пример #2
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);
	WorkSpace w;
	w.show();
	return a.exec();
}
Пример #3
0
void __fastcall TDesignFrm::btClearHeadDefClick(TObject *Sender)
{
    int result = Application->MessageBox(L"这个清空动作会清空所有文件!  是否继续?",L"删除询问",MB_OKCANCEL);
    if(result == IDCANCEL)
    {
        return;
    }

    m_WorkSpaceManager->BeginUpdate();
    for(int i=m_WorkSpaceManager->GetWorkSpaceCount()-1; i>=0; i--)
    {
        m_WorkSpaceManager->DeleteWorkSpace(i);
    }


    //添加一条新数据
    String  head = IntToHex(0, 2);
    String  subHead = IntToHex(0, 2);
    String  fileName = FormatStr("Pack_%s_%s.eggxp", head, subHead);
    WorkSpace	*  selWorkSpace = m_WorkSpaceManager->CreateNewWorkSpace();
    selWorkSpace->InitWorkSpace(m_WorkSpaceManager->GetFilePath(),
				fileName, head);

	selWorkSpace->GetFileManager()->CreateNew();
	selWorkSpace->SaveToFile();

	m_WorkSpaceManager->ReloadWorkSpacePack();

	WorkspaceToGUI();
	m_WorkSpaceManager->EndUpdate();
}
Пример #4
0
void __fastcall TDesignFrm::btStartNewClick(TObject *Sender)
{
    if(SourceGenDesignFrm->StartDesign() == false)
        return;

    String  fileName, head, subHead;
    m_WorkSpaceManager->BeginUpdate();
    for(int i=0; i<SourceGenDesignFrm->GetHeadCount(); i++)
    {
        for(int j=0; j<SourceGenDesignFrm->GetSubHeadCount(); j++)
        {
            head = IntToHex(i+1, 2);
            subHead = IntToHex(j+1, 2);
            fileName = FormatStr("Pack_%s_%s.eggxp", head, subHead);
            WorkSpace	*  selWorkSpace = m_WorkSpaceManager->CreateNewWorkSpace();
            selWorkSpace->InitWorkSpace(m_WorkSpaceManager->GetFilePath(),
						fileName, head + " " + subHead);

			selWorkSpace->GetFileManager()->CreateNew();
            selWorkSpace->SaveToFile();            
        }
    }

    m_WorkSpaceManager->ReloadWorkSpacePack();
    WorkspaceToGUI();
    m_WorkSpaceManager->EndUpdate();
}
Пример #5
0
void Test_TorsionalMinimisation()
{
	FFParamSet ffps;
	ffps.readLib("lib/amber03aa.ff");

	//System sys(ffps);
	//sys.add(NewProteinHelix(ffps,"*A-(AAAAPAAAA)-A*" ));

	PDB_In sys(ffps,"./pd_double/test.pdb");
	sys.load();

	WorkSpace wspace = WorkSpace( sys );
	RotBond replacement; // Must stay in scope for the lifetime of this wspace...
	wspace.setRotatableBondList( &replacement ); // Override the internal dummy rotbond array
	wspace.info();
	wspace.addStdTra("imported464");
	wspace.outtra.append();

	Forcefield ffs = createffts(wspace);

	SegmentDefBase sd(wspace,37,44,SegBreakCentre);

	TorsionalMinimisation min2( ffs, sd );
	min2.Steps = 3000;
	min2.InitialCapFactor = 0.05;
	min2.UpdateScr = 1;
	min2.UpdateTra = 1;
	min2.UpdateMon = -1;
	min2.run();

	return;
}
Пример #6
0
void Window::configure( Configuration* c ){
	WorkSpace::create();
	//ユーザー設定
	WorkSpace w;
	WorkSpace::Configuration wsCon;
	w.configure( &wsCon );
	c->setWidth( w.width() );
	c->setHeight( w.height() );
	c->setTitle( w.title() );
}
Пример #7
0
boolean UndoDecoratorMove::canUndo()
{
    VPEAnnotator* dec = this->lookupDecorator();
    if (!dec) return FALSE;
    int w,h;
    dec->getXYSize(&w,&h);
    WorkSpace* ews = dec->getWorkSpace();

    return (ews->isEmpty(this->x, this->y, w, h));
}
Пример #8
0
int main(int argc, char **argv) {
	
	Manager manager;
	PropList props;
	CACHE_CONFIG_PATH(props) = "icache.xml";
	try {
		WorkSpace *fw = manager.load(argv[1], props);
		
		// Find main CFG
		CFG *cfg = fw->getCFGInfo()->findCFG("main");
		if(cfg == 0) {
			cerr << "ERROR: cannot find main !\n";
			return 1;
		}
		
		// Removing __eabi call if available
		for(CFG::BBIterator bb(cfg); bb; bb++)
			for(Iterator<Edge *> edge(bb->outEdges()); edge; edge++)
				if(edge->kind() == Edge::CALL
				&& edge->target()
				&& edge->calledCFG()->label() == "__eabi") {
					delete(*edge);
					break;
				}
		
		// Processors configuration
		//PROC_VERBOSE(props) = true;
		//EXPLICIT(props) = true;
		
		// Get external constraints
		ipet::FlowFactLoader ffl;
		ffl.process(fw, props);
			
		// Build CAT contraint
		CATConstraintBuilder decomp;
		decomp.process(fw, props);
					
		// Resolve the system
		WCETComputation wcomp;
		wcomp.process(fw, props);
		
		// Display the result
		//ilp::System *sys = SYSTEM(fw);
		/*sys->dump();
		cout << sys->countVars() << " variables and "
			 << sys->countConstraints() << " constraints.\n";*/
		cout << "WCET = " << WCET(fw) << '\n';
	}
	catch(LoadException e) {
		cerr << "ERROR: " << e.message() << '\n';
		exit(1);
	}
	return 0;
}
Пример #9
0
boolean UndoStandInMove::canUndo()
{
    Node* n = UndoNode::LookupNode (this->editor, this->className, this->instance_number);
    if (!n) return FALSE;
    StandIn* si = n->getStandIn();
    if (!si) return FALSE;

    // determine if the destination location is empty
    int w,h;
    si->getXYSize(&w,&h);
    WorkSpace* ews = si->getWorkSpace();

    return (ews->isEmpty(this->x, this->y, w, h));
}
Пример #10
0
/**
 * Launch the work.
 */
void Command::run(void) {
	
	// Any file
//	if(!file)
//		throw OptionException("binary file path required !");
	
	// Load the file
	//GenericSimulator sim;
	PropList props;
	//SIMULATOR(props) = &sim;
	PROCESSOR_PATH(props) = proc.value();
	fw = manager.load(&file, props);
	
	// Removing __eabi call if available (should move in a file configuration)
	CFG *cfg = fw->getCFGInfo()->findCFG("main");
	if(cfg != 0)
		for(CFG::BBIterator bb(cfg); bb; bb++)
			for(BasicBlock::OutIterator edge(bb); edge; edge++)
				if(edge->kind() == Edge::CALL
				&& edge->target()
				&& edge->calledCFG()->label() == "__eabi") {
					delete(*edge);
					break;
				}
	
	// Now process the functions
	if(!funs)
		compute("main");
	else
		for(int i = 0; i < funs.length(); i++)
			compute(funs[i]);
}
Пример #11
0
int main(int argc, char **argv)
{
  WorkSpace *work    = NULL;

  get_args(argc, argv);
  
  srand (getpid());

  work = new WorkSpace();
  work->LoadMotionDB (script_file);
  work->ExecLearning ();
  
  delete work;

  return 0;
}
Пример #12
0
int main(int argc, char **argv) {

	Manager manager;
	PropList props;
//	LOADER(props) = &Loader::LOADER_Gliss_PowerPC;
	try {
		WorkSpace *fw = manager.load(argv[1], props);
		
		// Find main CFG
		cout << "Looking for the main CFG\n";
		CFG *cfg = fw->getCFGInfo()->findCFG("main");
		if(cfg == 0) {
			cerr << "ERROR: cannot find main !\n";
			return 1;
		}
		else
			cout << "main found at 0x" << cfg->address() << '\n';
		
		// Build dominance
		Dominance dom;
		dom.processCFG(fw, cfg);
		
		// Display dominance information
		for(CFG::BBIterator bb1(cfg); bb1; bb1++) {
			bool first = true;
			cout << bb1->number() << " dominates {";
			for(CFG::BBIterator bb2(cfg); bb2; bb2++)
				if(Dominance::dominates(bb1, bb2)) {
					if(first)
						first = false;
					else
						cout << ", ";
					cout << bb2->number();
				}
			cout << "}\n";
		}
		
		// Display the result
		cout << "SUCCESS\n";
	}
	catch(LoadException e) {
		cerr << "ERROR: " << e.message() << '\n';
		exit(1);
	}
	return 0;
}
Пример #13
0
/**
 * Compute the WCET for the given function.
 */
void Command::compute(String fun) {
	
	// Get the VCFG
	CFG *cfg = fw->getCFGInfo()->findCFG(fun);
	if(!cfg) {
		cerr << "ERROR: binary file does not contain the function \""
			 << fun << "\".\n";
		return;
	}
	VirtualCFG vcfg(cfg);
	//ENTRY_CFG(fw) = &vcfg;
		
	// Prepare processor configuration
	PropList props;
	ENTRY_CFG(props) = &vcfg;
	if(verbose) {
	  //	PROC_VERBOSE(props) = true;
		cerr << "verbose !\n";
	}
	if(dump_constraints)
		props.set(EXPLICIT, true);
	
	// Assign variables
	VarAssignment assign;
	assign.process(fw, props);
		
	// Compute BB time
       	LiExeGraphBBTime tbt(props);
	tbt.process(fw);
		
	// Build the system
	BasicConstraintsBuilder builder;
	builder.process(fw, props);
		
	// Load flow facts
	ipet::FlowFactLoader loader;
	loader.process(fw, props);

	// Build the object function to maximize
	BasicObjectFunctionBuilder fun_builder;
	fun_builder.process(fw, props);	
  
	// Resolve the system
	WCETComputation wcomp;
	wcomp.process(fw, props);
  
	// Get the results
	ilp::System *sys = SYSTEM(fw);
	cout << "WCET = " << WCET(fw) << "\n";
	// Dump the ILP system
	if(dump_constraints) {
	  String out_file = fun + ".lp";
		io::OutFileStream stream(&out_file);
//		if(!stream.isReady())
//			throw MessageException("cannot create file \"%s\".", &out_file);
		sys->dump(stream);
	}
}
Пример #14
0
void Window::update(){
	Window w;
	Graphics::Manager m;
	WorkSpace ws;
	bool sleep = false;
	if( w.isMinimized() ){
		sleep = true;
	}
	//終了チェック
	if( isEndRequested() ){
		ws.requestEnd();
	}
	if( !sleep ){
		ws.preUpdate();
	}
	if( sleep ){
		ws.sleep( 50 );
	} else {
		try{
			ws.update();
		}
		catch( ... ){
			WorkSpace::destroy();
			end();
			throw Mashiro::EXCEPTION_EXIT;
		}
		ws.postUpdate();
	}
	if( ws.isEndRequested() ){
		WorkSpace::destroy();
		end();
	}
}
Пример #15
0
void AutoRunThread::run()
{
	string lasFilePath, resFolder;
	WorkSpace *workSpace = NULL;

	lasFilePath = this->lasPath.toStdString();
	resFolder = this->resFolder.toStdString();
	workSpace = new WorkSpace();
	workSpace->newProj(lasFilePath.c_str(), this->cellSize, resFolder.c_str());
	resFolder = workSpace->getResFolder();

	// Seed generation
	if(this->useOBASeedGenerator && this->maxObjSize >= 20.0)
	{
		emit stepInformation(0, tr("start identifying complexity of the scene ..."));
		::calcComplexByObj(workSpace, this->maxObjSize, this->seedHeightTh, this->seedSlopeTh);
		emit stepInformation(20, tr("identifying complexity of the scene finished ..."));
	}

	// Filtering
	emit stepInformation(20, tr("start filter points ..."));
	TINFilter *filter = new TINFilter(workSpace, maxObjSize, this->seedCellSize, this->angleIteration, this->hIteration);
	filter->filterGround(this->filteringHeightTh, this->filteringSlopeTh);
	emit stepInformation(70, tr("filtering points finished ..."));
	
	// Dem interpolation
	emit stepInformation(70, tr("start dem interpolation ..."));
	las2Raster(workSpace, this->dtmFactor);
	emit stepInformation(90, tr("dem interpolation finished..."));
	
	// Object points extraction
	emit stepInformation(90, tr("start get non-groud points ..."));
	extractObjectPoints(workSpace, this->dtmFactor, this->objectHT);
	emit stepInformation(100, tr("process finished successfully!"));

	if (workSpace != NULL)
	{
		delete workSpace;
		workSpace = NULL;
	}
}
Пример #16
0
int generate_with_symbol_space(void)
{
  
	Behavior    *tmp_beh, *beh;
	WorkSpace   *work = NULL;
	work = new WorkSpace();
	tl_message ("Now loading motionDBs...");
	work->Load          ("../../script/learning_scriptfile_3");
	tl_message ("Now loading recogunits...");
	work->SetRecogUnits ("../../script/learning_scriptfile_3");
	work->SetLabelFromRecogUnit();
	work->BeforeRecognize();
	work->SetDisVector();
	work->SymmentrizeDisVector();
	work->SpaceCreate(3);

	vector<double> tmp_dis;
	vector<double> tmp_cord;
	int span = 20, step = 5;
	Pose *pose;

	cur_beh = new Behavior();
	for (int i=0; i<span; i++)
		{
			data = TOYOTA_GetMotionCaptureData();
			joint_angle = TOYOTA_TransferCaptureToJoint(data);
			pose = new Pose(dof, joint_angle);  // dof = number of DoF, joint_angle : sequence of double
			cur_beh->AddPose(pose);
		}
	for (int j=0; j<1000; j++)
		{
			cerr << "----------------  pop" << endl;
			for (int i=0; i<step; i++)
				{
					cur_beh->PopFrontPose();
					data = TOYOTA_GetMotionCaptureData();
					joint_angle = TOYOTA_TransferCaptureToJoint(data);
					pose = new Pose(dof, joint_angle);  // dof = number of DoF, joint_angle : sequence of double
					cur_beh->AddPose(pose);
				}
			cerr << "----------------  CalcDis" << endl;
			// その一部分の動作を空間に射影した場合の,各既知原始シンボルからの距離を計測
			tmp_dis = work->CalcDistanceOfInputBehavior(cur_beh);
			cerr << "----------------  GetCoordinate" << endl;
			// 求めた距離に応じて,空間に射影するべき座標を算出
			tmp_cord = work->GetPsymbolSpace()->CoordinateFromDistanceData(tmp_dis);
			cerr << "!!!!! " << j << "th Gene Start!" << endl;
			// その座標における動作を生成する.
			work->BehGeneFromTransition(tmp_cord);
			cerr << "!!!!! " << j << "th Gene Finish!" << endl;
			tmp_beh = work->GetLastBehavior ();
			for (int i=0; i<step; i++)
				{
					TOYOTA_ActuateRobot (tmp_beh->NthPose(i));
				}
		}
	return TRUE;
}
Пример #17
0
static MRESULT APIENTRY Char ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 mp2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * Get the message data.                                                   *
  ***************************************************************************/

  USHORT Flags    = (USHORT) SHORT1FROMMP ( mp1 ) ;
//UCHAR  Repeat   = (UCHAR)   CHAR3FROMMP ( mp1 ) ;
//UCHAR  ScanCode = (UCHAR)   CHAR4FROMMP ( mp1 ) ;

//USHORT Char     = (USHORT) SHORT1FROMMP ( mp2 ) ;
  USHORT VKey     = (USHORT) SHORT2FROMMP ( mp2 ) ;

 /***************************************************************************
  * Ignore keys being released, invalid characters, dead keys and           *
  *   invalid composite characters.                                         *
  ***************************************************************************/

  if ( ( Flags & KC_KEYUP )
    OR ( Flags & KC_INVALIDCHAR )
    OR ( Flags & KC_DEADKEY )
    OR ( Flags & KC_INVALIDCOMP ) )
  {
    Sys_BeepNote ( ) ;
    return ( MRFROMSHORT ( FALSE ) ) ;
  }

 /***************************************************************************
  * Intercept the ESC virtual key to abort margin set mode.                 *
  ***************************************************************************/

  if ( Flags & KC_VIRTUALKEY ) {

    switch ( VKey ) {

      case VK_ESC: {

        if ( Data->Capture ) {

          Data->Capture = FALSE ;
          Sys_ReleaseCapture ( ) ;

          HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ;
          WinSetPointer ( HWND_DESKTOP, Ptr ) ;

          Sys_SetFocus ( Data->HadFocus ) ;

          WorkSpace PS ( "HRuler::Char", 0, Window, Data->pDevice, int(Data->Metric) ) ;
          PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

          RECTL Rectangle ;
          WinQueryWindowRect ( Window, &Rectangle ) ;
          PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

          POINTL ButtonSize = { 8, 8 } ;
          PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

          PS.SetMix ( FM_INVERT ) ;
          PS.SetLineType ( LINETYPE_ALTERNATE ) ;
          POINTL Point = { Data->Tick, Rectangle.yBottom } ;
          PS.Move ( Point ) ;
          Point.y = Rectangle.yTop ;
          PS.DrawLine ( Point ) ;

          Data->Mode = NOTMOVING ;
        }

        break ;
      }
    }
  }

 /***************************************************************************
  * Return.                                                                 *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Пример #18
0
static MRESULT APIENTRY Button1Up ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * If the mouse wasn't captured, return.                                   *
  ***************************************************************************/

  if ( NOT Data->Capture )
    return ( MRFROMSHORT ( FALSE ) ) ;

 /***************************************************************************
  * Get the presentation space.                                             *
  ***************************************************************************/

  WorkSpace PS ( "HRuler::Button1Up", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::Button1Up:   Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * Erase the previous hairline.                                            *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;
  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * Release the mouse.                                                      *
  ***************************************************************************/

  Data->Capture = FALSE ;
  Sys_ReleaseCapture ( ) ;

 /***************************************************************************
  * Restore the normal mouse pointer.                                       *
  ***************************************************************************/

  HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ;
  WinSetPointer ( HWND_DESKTOP, Ptr ) ;

 /***************************************************************************
  * Restore the keyboard focus.                                             *
  ***************************************************************************/

  Sys_SetFocus ( Data->HadFocus ) ;

 /***************************************************************************
  * Process final location of mouse.                                        *
  ***************************************************************************/

  switch ( Data->Mode ) {

    case MOVELEFT:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Data->Tick < 0 ) OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }
      Sys_SendMessage ( OWNER(Window), WM_SET_LEFTMARGIN, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }

    case MOVERIGHT:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Data->Tick <= Data->LeftMargin ) OR ( Data->Tick > Data->PageWidth ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }
      Sys_SendMessage ( OWNER(Window), WM_SET_RIGHTMARGIN, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }

    case MOVETAB:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Mouse.y > Rectangle.yTop )
        OR ( Mouse.y < Rectangle.yBottom )
        OR ( Data->Tick <= Data->LeftMargin )
        OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_SendMessage ( OWNER(Window), WM_CLEAR_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), 0 ) ;
        break ;
      }

      Sys_SendMessage ( OWNER(Window), WM_MOVE_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), MPFROMLONG(Data->Tick) ) ;
      break ;
    }

    case SETTAB:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Mouse.y > Rectangle.yTop )
        OR ( Mouse.y < Rectangle.yBottom )
        OR ( Data->Tick <= Data->LeftMargin )
        OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }

      Sys_SendMessage ( OWNER(Window), WM_SET_TAB, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }
  }

 /***************************************************************************
  * Reset mode.                                                             *
  ***************************************************************************/

  Data->Mode = NOTMOVING ;

 /***************************************************************************
  * We're done.                                                             *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Пример #19
0
static MRESULT APIENTRY MouseMove ( HWND Window, MESG msg, MPARAM1 mp1, MPARAM2 mp2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * If the mouse wasn't captured, return.                                   *
  ***************************************************************************/

  if ( NOT Data->Capture )
    return ( Sys_DefWindowProc ( Window, msg, mp1, mp2 ) ) ;

 /***************************************************************************
  * Get the presentation space.                                             *
  ***************************************************************************/

  WorkSpace PS ( "HRuler::MouseMove", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::MouseMove:   Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * Erase the previous hairline.                                            *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;

  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * Save the current hairline position.                                     *
  ***************************************************************************/

  Data->Tick = TICK(Mouse.x) ;

 /***************************************************************************
  * Draw a hairline showing the current position.                           *
  ***************************************************************************/

  Point.x = Data->Tick ;
  Point.y = Rectangle.yBottom ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * We're done.                                                             *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Пример #20
0
void Pops::setTo( const WorkSpace& _WSpace, PopsMode _Mode )
{
	m_WSpace = &_WSpace;
	m_Mode = _Mode;

	m_AtomIndexes.clear();
    m_Atoms.clear();

	switch( m_Mode )
	{
	case AllAtom:
		{
			m_CurrentDat = &m_Atomic;
			if( m_Atomic.atoms.size() == 0 )
			{
				throw ProcedureException("POPS: No data has yet been loaded for AllAtom mode.");
			}
			for( size_t i = 0; i < _WSpace.nAtoms(); i++ )
			{
				if( _WSpace.atom[i].isHydrogen() )
				{
					m_AtomIndexes.push_back(SIZE_T_FAIL);
					continue;
				}
				else
				{
					m_AtomIndexes.push_back(m_Atoms.size());
				}

				bool found = false;
				for( size_t j = 0; j < m_Atomic.atoms.size(); j++ )
				{
					if( 0 == m_Atomic.atoms[j].atomName.compare( _WSpace.atom[i].pdbname ) &&
						0 == m_Atomic.atoms[j].resName.compare( _WSpace.atom[i].parentl3name ) )
					{
						m_Atoms.push_back( PopsAtom( m_Atomic.atoms[j], i, &_WSpace.atomxyz(i)) );
						found = true;
						break;
					}
				}
				if( !found )
				{
					for( size_t j = 0; j < m_Atomic.atoms.size(); j++ )
					{
						if( 0 == m_Atomic.atoms[j].resName.compare( "*" ) &&
							0 == m_Atomic.atoms[j].atomName.compare( _WSpace.atom[i].pdbname ) )
						{
							m_Atoms.push_back( PopsAtom( m_Atomic.atoms[j], i, &_WSpace.atomxyz(i)) );
							found = true;
							break;
						}
					}
				}
				if( !found )
				{
					StringBuilder sb;
					sb.setFormat("POPS: Cannot find atom type %s %s in the database.\n")
						(_WSpace.atom[i].pdbname)
						(_WSpace.atom[i].parentl3name);
					throw ProcedureException(sb.toString());
				}
			}
			break;
		}
	case Coarse:
		{
			m_CurrentDat = &m_Coarse;
			if( m_Coarse.atoms.size() == 0 )
			{
				throw ProcedureException("POPS: No data has yet been loaded for AllAtom mode.");
			}
			for( size_t i = 0; i < _WSpace.nAtoms(); i++ )
			{
				if( !_WSpace.atom[i].isCAlpha() )
				{
					m_AtomIndexes.push_back(SIZE_T_FAIL);
					continue;
				}
				else
				{
					m_AtomIndexes.push_back(m_Atoms.size());
				}

				bool found = false;
				for( size_t j = 0; j < m_Coarse.atoms.size(); j++ )
				{
					if( 0 == m_Coarse.atoms[j].atomName.compare( _WSpace.atom[i].pdbname ) &&
						0 == m_Coarse.atoms[j].resName.compare( _WSpace.atom[i].parentl3name ) )
					{
						m_Atoms.push_back( PopsAtom( m_Coarse.atoms[j], i, &_WSpace.atomxyz(i)) );
						found = true;
						break;
					}
				}
				if( !found )
				{
					for( size_t j = 0; j < m_Coarse.atoms.size(); j++ )
					{
						if( 0 == m_Coarse.atoms[j].resName.compare( "*" ) &&
							0 == m_Coarse.atoms[j].atomName.compare( _WSpace.atom[i].pdbname ) )
						{
							m_Atoms.push_back( PopsAtom( m_Coarse.atoms[j], i, &_WSpace.atomxyz(i) ) );
							found = true;
							break;
						}
					}
				}
				if( !found )
				{
					StringBuilder sb;
					sb.setFormat("POPS: Cannot find atom type %s %s in the database.\n")
						(_WSpace.atom[i].pdbname)
						(_WSpace.atom[i].parentl3name);
					throw ProcedureException(sb.toString());
				}				
			}
			break;
		}
	default:
		{
			THROW( CodeException, "Unknown PopsMode encountered!");
		}
	}
}
Пример #21
0
int main(int argc, char **argv)
{
  srand (getpid());
  Common_SetDebug (TRUE);

  get_args(argc, argv);

  JHMM		*synthesis_hmm = NULL, *hmm[10];
  Behavior	*beh = NULL;

  tl_message ("Loading hmm factor for synthesis");
  hmm[0] = new JHMM;
  hmm[1] = new JHMM;
  hmm[2] = new JHMM;
  hmm[0]->Load("./.tmp/squat/squat.hmm");
  hmm[1]->Load("./.tmp/kick/kick.hmm");
  hmm[2]->Load("./.tmp/punch/punch.hmm");


  WorkSpace *work = NULL;
  work = new WorkSpace();
  work->LoadMotionDB ("../../script/learning_scriptfile_2");
  //work->LoadHTKUnits ("../../script/htkunit_scriptfile_2");
  work->SetHTKUnitsFromMotionDB ();
  work->SetLabelFromHTKUnit();
  work->BeforeRecognize();
  //work->DisVectorLoad("../../script/symbol_data/tmp_distance_vector");
  work->SpaceLoad    ("../../script/symbol_data/tmp_dim.spc");
  cerr << "num of htk_units = " << work->NumOfHTKUnits() << endl;

#if 0
  work->CalcKLDivergenceMatrix();
  work->SpaceFileOut ("./tmp_space_output.txt");

  tl_message ("KL distance from 0 to 1 (by new algo.) = %g", work->GetNthHTKUnit(0)->CalcKLDistance ( work->GetNthHTKUnit(1) ) );
  tl_message ("KL distance from 1 to 0 (by new algo.) = %g", work->GetNthHTKUnit(1)->CalcKLDistance ( work->GetNthHTKUnit(0) ) );
  tl_message ("KL distance from 0 to 2 (by new algo.) = %g", work->GetNthHTKUnit(0)->CalcKLDistance ( work->GetNthHTKUnit(2) ) );
  tl_message ("KL distance from 2 to 0 (by new algo.) = %g", work->GetNthHTKUnit(2)->CalcKLDistance ( work->GetNthHTKUnit(0) ) );
  tl_message ("KL distance from 1 to 2 (by new algo.) = %g", work->GetNthHTKUnit(1)->CalcKLDistance ( work->GetNthHTKUnit(2) ) );
  tl_message ("KL distance from 2 to 1 (by new algo.) = %g", work->GetNthHTKUnit(2)->CalcKLDistance ( work->GetNthHTKUnit(1) ) );
#else
  work->CalcHellingerMatrix();
  work->SpaceFileOut ("./tmp_space_output.txt");

  tl_message ("Hellinger Distance from 0 to 1 = %g", work->GetNthHTKUnit(0)->CalcHellingerDistance ( *(work->GetNthHTKUnit(1)) ) );
  tl_message ("Hellinger Distance from 1 to 0 = %g", work->GetNthHTKUnit(1)->CalcHellingerDistance ( *(work->GetNthHTKUnit(0)) ) );
  tl_message ("Hellinger Distance from 0 to 2 = %g", work->GetNthHTKUnit(0)->CalcHellingerDistance ( *(work->GetNthHTKUnit(2)) ) );
  //tl_message ("Hellinger Distance from 2 to 0 = %g", work->GetNthHTKUnit(2)->CalcHellingerDistance ( work->GetNthHTKUnit(0) ) );
  tl_message ("Hellinger Distance from 1 to 2 = %g", work->GetNthHTKUnit(1)->CalcHellingerDistance ( *(work->GetNthHTKUnit(2)) ) );
  //tl_message ("Hellinger Distance from 2 to 1 = %g", work->GetNthHTKUnit(2)->CalcHellingerDistance ( work->GetNthHTKUnit(1) ) );
#endif

  vector<double>	tmp_dis, tmp_cord;
  tl_message ("Now generate a general synthesised HMM");
  ofstream fout("./result.dat");
  fout << "weight[0], weight[1], pseudo_distance to [0], pseudo_distance to [1], position_1, position_2" << endl;
  for (int i=-20; i<=20; i++)
    {
      synthesis_hmm = new JHMM;
      weight[0] = 0.1 * i;
      weight[1] = 1.0 - 0.1 * i;
      synthesis_hmm->InterpolationAny (hmm, weight, 2);
      beh = synthesis_hmm->GenerateBehavior(100, 30);
      delete synthesis_hmm;

      work->CalcDistanceOfInputBehavior(beh, tmp_dis);
      work->GetPsymbolSpace()->CoordinateFromDistanceData(tmp_dis, tmp_cord);
      fout << weight[0] << "," << weight[1] << ",";

      for (int i=0; i<(int)(tmp_dis.size()); i++)
	fout << tmp_dis[i] << ",";
      for (int i=0; i<(int)(tmp_cord.size()); i++)
	fout << tmp_cord[i] << ",";
      fout << endl;
      cerr << "size of distance vector = " << tmp_dis.size() << ", and size of coordinate = " << tmp_cord.size() << endl;
    }

  delete beh;
  for (int i=0; i<3; i++)
    delete hmm[i];
  return TRUE;
  return TRUE;
}
Пример #22
0
// Created on 2008-07-10
// Test for what's happen when the extrapolated motion patterns are recognized by mimesis
// also for RSJ conf. 2008
int test_extra_recognition(void)
{
	tl_message ("start");
	JHMM        *hmm1 = NULL, *hmm2 = NULL, *hmm3 = NULL, *synthesis_hmm = NULL;
	Behavior    *beh = NULL;
	JHMM        *hmm_vec[3];
	double      weight[3];
	int         i;

	hmm1      = new JHMM;
	hmm2      = new JHMM;
	hmm3      = new JHMM;
	hmm1->Load("./.tmp/punch/punch.hmm");
	hmm2->Load("./.tmp/squat/squat.hmm");
	hmm3->Load("./.tmp/kick/kick.hmm");
	hmm_vec[0] = hmm1;
	hmm_vec[1] = hmm2;
	hmm_vec[2] = hmm3;

	WorkSpace *work = NULL;
	work = new WorkSpace();
	if (script_file[0]==0) { print_usage(); exit(0); }
	work->LoadMotionDB (script_file);
	work->SetHTKUnitsFromMotionDB ();
	work->BeforeRecognize();
	work->DistanceLoad ("../../script/symbol_data/tmp_distance_vector");
	work->SpaceLoad    ("../../script/symbol_data/tmp_dim.spc");

	vector<double>	tmp_dis, new_dis, hellinger, tmp_cord;
	vector<double>	likelihood;

	tl_message ("# of motion db is : %d\n", work->GetNumOfMotionDB() );

	cout << "c_1, c_2, ";
	for (i=0; i<(int)(work->GetNumOfMotionDB()); i++)
		cout << "old_KLdistance[" << i << "] ,";
	for (i=0; i<(int)(work->GetNumOfMotionDB()); i++)
		cout << "new_KLdivergence[" << i << "] ,";
	for (i=0; i<(int)(work->GetNumOfMotionDB()); i++)
		cout << "Hellinger Distance[" << i << "] ,";
	for (i=0; i<(int)(work->GetPsymbolSpace()->GetDimension() ); i++)
		cout << "x[" << i << "] , ";
	cout << endl;

	for (int i=-10; i<20; i++)
		{
			synthesis_hmm = new JHMM;
			weight[0] = i * 0.1;
			weight[1] = 1 - weight[0];
			synthesis_hmm->InterpolationAny (hmm_vec, weight, 2);
			beh = synthesis_hmm->GenerateBehavior(100, 30);

			work->CalcHellingerDistanceOfOnlineBehavior(beh, hellinger);
			tl_message ("step hoge %d.0", i);
			for (int j=0; j<(int)(hellinger.size()); j++)
				cout << hellinger[j] << " , ";
			cout << endl;
			tl_message ("step hoge %d.1", i);
      
			work->CalcLikelihoodVector        (beh, likelihood);
			tl_message ("step hoge %d.2", i);
			work->CalcDistanceOfInputBehavior (beh, tmp_dis);
			tl_message ("step hoge %d.3", i);
			work->CalcDistanceOfOnlineBehavior(beh, new_dis);
			tl_message ("step hoge %d.4", i);

			work->GetPsymbolSpace()->CoordinateFromDistanceData(tmp_dis, tmp_cord);
			tl_message ("step hoge %d.5", i);
			cout << weight[0] << " , " << weight[1] << " , ";
			for (int j=0; j<(int)(tmp_dis.size()); j++)
				cout << tmp_dis[j] << " , ";
			for (int j=0; j<(int)(new_dis.size()); j++)
				cout << new_dis[j] << " , ";
			for (int j=0; j<(int)(hellinger.size()); j++)
				cout << hellinger[j] << " , ";
			for (int j=0; j<(int)(tmp_cord.size()); j++)
				cout << tmp_cord[j] << " , ";
			cout << endl;

			delete synthesis_hmm;
		}

	delete beh;
	delete hmm1;
	delete hmm2;
	delete hmm3;
	delete synthesis_hmm;
	return TRUE;
}
Пример #23
0
int main(int argc, char **argv) {

    Manager manager;
    PropList props;
    PROCESSOR_PATH(props) = "../../data/procs/op1.xml";
    CACHE_CONFIG_PATH(props) = "../../data/caches/inst-64x16x1.xml";

    try {

        // Load program
        if(argc < 2) {
            cerr << "ERROR: no argument.\n"
                 << "Syntax is : test_ipet <executable>\n";
            return 2;
        }
        WorkSpace *fw = manager.load(argv[1], props);
        assert(fw);

        // Display information
        cout << "PLATFORM INFORMATION\n";
        Platform *pf = fw->platform();
        cout << "Platform : " << pf->identification().name() << '\n';
        cout << '\n';

        // Display registers
        cout << "REGISTERS\n";
        for(int i = 0; i < pf->banks().count(); i++) {
            const hard::RegBank *bank = pf->banks()[i];
            cout << "Bank " << bank->name() << ", "
                 << bank->size() << "bits, "
                 << bank->count() << " registers, "
                 << reg_kinds[bank->kind()];
            for(int j = 0; j < bank->registers().count(); j++) {
                if(j % 8 == 0)
                    cout << "\n\t";
                else
                    cout << ", ";
                cout << bank->registers()[j]->name();
            }
            cout << '\n';
        }
        cout << '\n';

        // Display cache
        cout << "CACHE CONFIGURATION\n";
        const CacheConfiguration& cconf(pf->cache());
        display_cache_level(1, cconf.instCache(), cconf.dataCache());
        cout << '\n';

        // Display some instructions
        fw->require(DECODED_TEXT);
        cout << "READ/WRITTEN REGS TEST\n";
        String label("main");
        Inst *inst = fw->process()->findInstAt("main");
        //fw->findLabel(label));
        if(!inst)
            throw new otawa::Exception(CString("no main in this file ?"));
        for(int i = 0; i < 10; i++, inst = inst->nextInst()) {
            cout << '\n' << inst->address() << ": "
                 << inst << " (" << io::hex(inst->kind()) << ")\n";
            const elm::genstruct::Table<hard::Register *>& reads = inst->readRegs();
            cout << "\tread registers : ";
            for(int i = 0; i < reads.count(); i++)
                cout << reads[i] << ' ';
            cout << '\n';
            const elm::genstruct::Table<hard::Register *>& writes = inst->writtenRegs();
            cout << "\twritten registers : ";
            for(int i = 0; i < writes.count(); i++)
                cout << writes[i] << ' ';
            cout << '\n';
        }
        cout << io::endl;


        // Processor load test
        cout << "Processor load test\n";
        //pf->loadProcessor("proc.xml");
        const hard::Processor *proc = pf->processor();
        if(!proc)
            cout << "NO PROCESSOR !\n";
        else {
            cout << "arch = " << proc->getArch() << io::endl;
            cout << "model = " << proc->getModel() << io::endl;
            cout << "builder = " << proc->getBuilder() << io::endl;
            cout <<"stages =\n";
            const elm::genstruct::Table<hard::Stage *>& stages = proc->getStages();
            for(int i = 0; i< stages.count(); i++) {
                cout << '\t'
                     << stages[i]->getName() << " "
                     << stages[i]->getType() << " "
                     << stages[i]->getWidth() << " "
                     << stages[i]->getLatency() << " "
                     << io::pointer(stages[i]) << io::endl;
                const elm::genstruct::Table<hard::FunctionalUnit *>& fus = stages[i]->getFUs();
                if(fus) {
                    cout << "\tfus=\n";
                    for(int i = 0; i < fus.count(); i++)
                        cout << "\t\t" << fus[i]->getName() << ' '
                             << fus[i]->getWidth() << ' '
                             << fus[i]->getLatency() << ' '
                             << fus[i]->isPipelined() << io::endl;
                }
                const elm::genstruct::Table<hard::Dispatch *>& dispatch = stages[i]->getDispatch();
                if(dispatch) {
                    cout << "\tdispatch=\n";
                    for(int i = 0; i < dispatch.count(); i++)
                        cout << "\t\t" << dispatch[i]->getType() << ' '
                             << dispatch[i]->getFU()->getName() << io::endl;
                }
            }
            cout << "queues =\n";
            const elm::genstruct::Table<hard::Queue *>& queues = proc->getQueues();
            for(int i = 0; i< queues.count(); i++) {
                cout << '\t'
                     << queues[i]->getName() << " "
                     << queues[i]->getSize() << " "
                     << queues[i]->getInput()->getName() << " ("
                     << io::pointer(queues[i]->getInput()) << ") "
                     << queues[i]->getOutput()->getName() << " ("
                     << io::pointer(queues[i]->getOutput()) << ")" << io::endl;
                const elm::genstruct::Table<hard::Stage *>& intern = queues[i]->getIntern();
                if(intern) {
                    cout << "\tintern=\n";
                    for(int i = 0; i < intern.count(); i++)
                        cout << "\t\t" << intern[i]->getName()
                             << " (" << io::pointer(intern[i]) << ')' << io::endl;
                }
            }
        }
    }
    catch(elm::Exception& e) {
        cerr << "ERROR: " << e.message() << '\n';
        return 1;
    }
    return 0;
}
Пример #24
0
static MRESULT APIENTRY Button1Down ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  WorkSpace PS ( "HRuler::Button1Down", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::Button1Down: Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * If the mouse isn't touching in the button area, return.                 *
  ***************************************************************************/

  if ( Mouse.y < Rectangle.yTop - ButtonSize.y ) {
     Sys_BeepNote ( ) ;
     return ( MRFROMSHORT ( FALSE ) ) ;
  } /* endif */

 /***************************************************************************
  * If the mouse is beyond the margins, return.                             *
  ***************************************************************************/

  if ( ( Mouse.x < Data->LeftMargin ) OR ( Mouse.x > Data->RightMargin+ButtonSize.x ) ) {
     Sys_BeepNote ( ) ;
     return ( MRFROMSHORT ( FALSE ) ) ;
  } /* endif */

 /***************************************************************************
  * If mouse is touching the left margin button, set mode to MOVELEFT.      *
  ***************************************************************************/

  if ( ( Mouse.x >= Data->LeftMargin ) AND ( Mouse.x <= Data->LeftMargin+ButtonSize.x ) ) {
     Data->Mode = MOVELEFT ;
     Data->Ptr = Data->MarginPtr ;
  } /* endif */

 /***************************************************************************
  * If mouse is touching the right margin button, set mode to MOVERIGHT.    *
  ***************************************************************************/

  else if ( ( Mouse.x >= Data->RightMargin-ButtonSize.x ) AND ( Mouse.x <= Data->RightMargin ) ) {
     Data->Mode = MOVERIGHT ;
     Data->Ptr = Data->MarginPtr ;
  } /* endif */

 /***************************************************************************
  * Else, find which tab-stop, if any, we're touching.                      *
  ***************************************************************************/

  else {
     for ( int i=0; i<Data->TabCount; i++ ) {
        if ( ( Mouse.x >= Data->Tabs[i] ) AND ( Mouse.x <= Data->Tabs[i]+ButtonSize.x ) ) {
           Data->Mode = MOVETAB ;
           Data->TabIndex = USHORT ( i ) ;
           break ;
        } /* endif */
     } /* endfor */

     if ( i >= Data->TabCount ) {
        Data->Mode = SETTAB ;
     } /* endif */

     Data->Ptr = Data->TabstopPtr ;
  } /* endif */

 /***************************************************************************
  * Capture the mouse.                                                      *
  ***************************************************************************/

  Data->Capture = TRUE ;
  Sys_SetCapture ( Window ) ;

 /***************************************************************************
  * Set the new mouse pointer.                                              *
  ***************************************************************************/

  WinSetPointer ( HWND_DESKTOP, Data->Ptr ) ;

 /***************************************************************************
  * Get the keyboard focus.                                                 *
  ***************************************************************************/

  Data->HadFocus = WinQueryFocus ( HWND_DESKTOP ) ;
  Sys_SetFocus ( Window ) ;

 /***************************************************************************
  * Save the current hairline position.                                     *
  ***************************************************************************/

  Data->Tick = TICK(Mouse.x) ;

 /***************************************************************************
  * Draw a hairline showing the current position.                           *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;
  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * We're done.                                                             *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Пример #25
0
static MRESULT APIENTRY SetTick ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

  /**************************************************************************
   * Find the instance data.                                                *
   **************************************************************************/

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * Get the new tick-mark position from the message.                       *
   **************************************************************************/

   LONG Tick = LONGFROMMP ( mp1 ) ;

  /**************************************************************************
   * If only the tick-mark has changed, move it.                            *
   **************************************************************************/

   if ( Data->Tick != Tick ) {

     /***********************************************************************
      * Get the presentation space.                                         *
      ***********************************************************************/

      WorkSpace PS ( "HRuler::SetTick", 0, Window, Data->pDevice, int(Data->Metric) ) ;
      PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

     /***********************************************************************
      * Find out some background information.                               *
      ***********************************************************************/

      RECTL Rectangle ;
      WinQueryWindowRect ( Window, &Rectangle ) ;
      PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

     /***********************************************************************
      * Erase the previous hairline.                                        *
      ***********************************************************************/

      if ( Data->Tick ) {
         PS.SetMix ( FM_INVERT ) ;
         PS.SetLineType ( LINETYPE_ALTERNATE ) ;
         POINTL Point = { Data->Tick, Rectangle.yBottom } ;
         PS.Move ( Point ) ;
         Point.y = Rectangle.yTop ;
         PS.DrawLine ( Point ) ;
      } /* endif */

     /***********************************************************************
      * Save the current hairline position.                                 *
      ***********************************************************************/

      Data->Tick = Tick ;

     /***********************************************************************
      * Draw a hairline showing the current position.                       *
      ***********************************************************************/

      if ( Data->Tick ) {
         PS.SetMix ( FM_INVERT ) ;
         PS.SetLineType ( LINETYPE_ALTERNATE ) ;
         POINTL Point = { Data->Tick, Rectangle.yBottom } ;
         PS.Move ( Point ) ;
         Point.y = Rectangle.yTop ;
         PS.DrawLine ( Point ) ;
      } /* endif */

   } /* endif */
 
  /**************************************************************************
   * We're done.                                                            *
   **************************************************************************/

   return ( MRFROMSHORT ( 0 ) ) ;
}
Пример #26
0
static MRESULT APIENTRY Paint ( HWND Window, MESG, MPARAM1, MPARAM2 ) {

  /**************************************************************************
   * Find the instance data.                                                *
   **************************************************************************/

   PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

  /**************************************************************************
   * Compute the current zoom factor.                                       *
   **************************************************************************/

   double Zoom = (double) FIXEDINT ( Data->fxZoom ) ;
   Zoom += (double) FIXEDFRAC ( Data->fxZoom ) / 0x10000L ;

  /**************************************************************************
   * Get presentation space and prepare it for use.                         *
   **************************************************************************/

   RECTL ClippingRectangle ;
   WorkSpace PS ( "HRuler::Paint", 0, Window, Data->pDevice, int(Data->Metric), ClippingRectangle ) ;
   PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;
   PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, ClippingRectangle ) ;

  /**************************************************************************
   * Clear the window and draw a border.                                    *
   **************************************************************************/

   RECTL WindowRectangle ;
   WinQueryWindowRect ( Window, &WindowRectangle ) ;

   WindowRectangle.xRight -- ;
   WindowRectangle.yTop -- ;

   PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, WindowRectangle ) ;

   PS.SetColor ( Data->IniData->fRulerColors[0] ? Data->IniData->RulerColors[0] : RGB_WHITE ) ;
   PS.FillBox ( WindowRectangle ) ;

   PS.SetColor ( RGB_BLACK ) ;
   PS.DrawBox ( WindowRectangle ) ;

  /**************************************************************************
   * Draw the left margin.                                                  *
   **************************************************************************/

   if ( ClippingRectangle.xLeft <= Data->LeftMargin ) {

      PS.SetColor ( Data->IniData->fRulerColors[1] ? Data->IniData->RulerColors[1] : RGB_BLUE ) ;
      PS.SetFillType ( PATSYM_HALFTONE ) ;
      RECTL Box = { ClippingRectangle.xLeft, ClippingRectangle.yBottom,
         Data->LeftMargin, ClippingRectangle.yTop } ;
      PS.FillBox ( Box ) ;
      PS.SetFillType ( PATSYM_DEFAULT ) ;

      PS.SetColor ( RGB_BLACK ) ;
      PS.SetLineType ( LINETYPE_ALTERNATE ) ;
      POINTL Point = { Data->LeftMargin, ClippingRectangle.yTop } ;
      PS.Move ( Point ) ;
      Point.y = ClippingRectangle.yTop ;
      PS.DrawLine ( Point ) ;
      PS.SetLineType ( LINETYPE_SOLID ) ;

   } /* endif */

   POINTL Point = { Data->LeftMargin, WindowRectangle.yTop } ;
   PS.Transform ( CVTC_DEFAULTPAGE, CVTC_DEVICE, 1, &Point ) ;
   Point.y -= 8 ;
   PS.DrawPointer ( Data->MarginPtr, Point, DP_NORMAL ) ;

  /**************************************************************************
   * Draw the right margin.                                                 *
   **************************************************************************/

   if ( ClippingRectangle.xRight >= Data->RightMargin ) {

      PS.SetColor ( Data->IniData->fRulerColors[1] ? Data->IniData->RulerColors[1] : RGB_BLUE ) ;
      PS.SetFillType ( PATSYM_HALFTONE ) ;
      RECTL Box = { Data->RightMargin, ClippingRectangle.yBottom,
         ClippingRectangle.xRight, ClippingRectangle.yTop } ;
      PS.FillBox ( Box ) ;
      PS.SetFillType ( PATSYM_DEFAULT ) ;

      PS.SetColor ( RGB_BLACK ) ;
      PS.SetLineType ( LINETYPE_ALTERNATE ) ;
      Point.x = Data->RightMargin ;
      Point.y = ClippingRectangle.yBottom ;
      PS.Move ( Point ) ;
      Point.y = ClippingRectangle.yTop ;
      PS.DrawLine ( Point ) ;
      PS.SetLineType ( LINETYPE_SOLID ) ;

   } /* endif */

   Point.x = Data->RightMargin ;
   Point.y = WindowRectangle.yTop ;
   PS.Transform ( CVTC_DEFAULTPAGE, CVTC_DEVICE, 1, &Point ) ;
   Point.x -= 8 ;
   Point.y -= 8 ;
   PS.DrawPointer ( Data->MarginPtr, Point, DP_NORMAL ) ;

  /**************************************************************************
   * Draw the tab-stops.                                                    *
   **************************************************************************/

   for ( int i=0; i<Data->TabCount; i++ ) {
      Point.x = Data->Tabs[i] ;
      Point.y = WindowRectangle.yTop ;
      PS.Transform ( CVTC_DEFAULTPAGE, CVTC_DEVICE, 1, &Point ) ;
      Point.y -= 8 ;
      PS.DrawPointer ( Data->TabstopPtr, Point, DP_NORMAL ) ;
   } /* endfor */

  /**************************************************************************
   * Draw the ruler.                                                        *
   **************************************************************************/

   for ( long x=WindowRectangle.xLeft; x<WindowRectangle.xRight; x++ ) {
      if ( x % ( Data->Metric ? 200 : 250 ) == 0 ) {
         PS.SetColor ( RGB_BLACK ) ;
         Point.x = x ;
         Point.y = 0 ;
         PS.Move ( Point ) ;
         if ( x % 1000 == 0 ) {
            Point.y = LONG ( 200.0 / Zoom ) ;
            PS.DrawLine ( Point ) ;
            Point.x += LONG ( 50.0 / Zoom ) ;
            Point.y = LONG ( 50.0 / Zoom ) ;
            char Text [10] ;
            sprintf ( Text, "%i", int(x/1000) ) ;
            PS.SetColor ( Data->IniData->fRulerColors[1] ? Data->IniData->RulerColors[1] : RGB_BLUE ) ;
            PS.Move ( Point ) ;
            PS.DrawText ( Text ) ;
         } else if ( x % 500 == 0 ) {
            Point.y = LONG ( 150.0 / Zoom ) ;
            PS.DrawLine ( Point ) ;
         } else {
            Point.y = LONG ( 100.0 / Zoom ) ;
            PS.DrawLine ( Point ) ;
         } /* endif */
      } /* endif */
   } /* endfor */

  /**************************************************************************
   * We're done.                                                            *
   **************************************************************************/

   return ( MRFROMSHORT ( 0 ) ) ;
}
Пример #27
0
void PD_API MCPackSideChains( WorkSpace& wspace, Physics::Forcefield& ffs, Physics::Forcefield& ff, const std::string& rotLibPath )
{
	Library::RotamerLibrary rotLib(wspace.ffps());
	rotLib.readLib( rotLibPath );
	MCPackSideChains( wspace, ffs, ff, rotLib );
}
Пример #28
0
	virtual void work(PropList &props) throw (elm::Exception) {
		WorkSpace *ws = workspace();
		cerr << "DEBUG: verbose = " << isVerbose() << "\n";

		// put the symbols
		for(Process::FileIter file(workspace()->process()); file; file++)
			for(File::SymIter sym(file); sym; sym++) {
				if(sym->kind() == Symbol::FUNCTION || sym->kind() == Symbol::LABEL) {
					cerr << "DEBUG: code symbol: " << sym->name() << " (" << sym->address() << ")\n";
					Inst *inst = workspace()->findInstAt(sym->address());
					if(inst) {
						Symbol::ID(inst).add(*sym);
						switch(sym->kind()) {
						case Symbol::FUNCTION:
							FUNCTION_LABEL(inst).add(sym->name());
							break;
						case Symbol::LABEL:
							LABEL(inst).add(sym->name());
							break;
						default:
							break;
						}
					}
				}
			}
		cerr << "DEBUG: here\n";

		// Look the _start
		Inst *start = ws->start();
		if(start) {
			if(isVerbose())
				cerr << "ENTRY: processing entry at " << start->address() << io::endl;
			processEntry(ws, start->address());
		}
		else if(isVerbose())
			cerr << "no entry to process\n";

		// Look the function symbols
		for(Process::FileIter file(ws->process()); file; file++)
			for(File::SymIter sym(file); sym; sym++)
				if(sym->kind() == Symbol::FUNCTION) {
					if(IGNORE_ENTRY(sym))
						cerr << "\n\nINFO: ignoring function symbol \"" << sym->name() << "\"\n";
					else {
						cerr << "\n\nENTRY: processing function \"" << sym->name() << " at " << sym->address() << io::endl;
						Inst *inst = ws->findInstAt(sym->address());
						if(inst)
							processEntry(ws, sym->address());
						else
							cerr << "bad function symbol \"" << sym->name()
								   << "\" no code segment at " << sym->address() << io::endl;
					}
				}

		// dump the instructions
		for(Process::FileIter file(workspace()->process()); file; file++) {
			cout << "FILE: " << file->name() << io::endl;
			for(File::SegIter seg(file); seg; seg++) {
				cout << "SEGMENT: " << seg->name() << io::endl;
				for(Segment::ItemIter item(seg); item; item++) {
					Inst *inst = item->toInst();
					if(inst) {
						if(MARKER(inst))
							cout << io::endl;
						for(Identifier<Symbol *>::Getter sym(inst, Symbol::ID); sym; sym++)
							cout << "\t" << sym->name() << ":\n";
						cout << "\t\t" << inst->address() << "  ";
						if(inst->isUnknown()) {
							cout << "<unknown>:";
							writeBytes(cout, inst->address(), inst->size());
						}
						else
							cout << inst;
						if(MARKER(inst)) {
							bool fst = true;
							for(Identifier<Inst *>::Getter from(inst, FROM); from; from++) {
								cout << (fst ? "\tfrom " : ", ");
								fst = false;
								cout << from->address();
							}
						}
						cout << io::endl;
					}
				}
			}
			cout << "\n";
		}
	}