CHANGES
- export MousePositionWidget.h so pharos can use it (displays the (x,y) mouse position in status bar) ADDS - add a getOnPhysicalGrid() in DbU - add getPhysical and getOnPhysicalGrid functions in PyDbU and also defines useful CONSTANTS
This commit is contained in:
parent
fee6e4c593
commit
297e58d535
|
@ -98,6 +98,7 @@ namespace Hurricane {
|
||||||
static DbU::Unit getOnSymbolicSnapGrid ( DbU::Unit u, SnapMode mode=Nearest );
|
static DbU::Unit getOnSymbolicSnapGrid ( DbU::Unit u, SnapMode mode=Nearest );
|
||||||
static inline void setSymbolicSnapGridStep ( DbU::Unit step );
|
static inline void setSymbolicSnapGridStep ( DbU::Unit step );
|
||||||
static DbU::Unit getOnCustomGrid ( DbU::Unit u, DbU::Unit step, SnapMode mode=Nearest );
|
static DbU::Unit getOnCustomGrid ( DbU::Unit u, DbU::Unit step, SnapMode mode=Nearest );
|
||||||
|
static inline DbU::Unit getOnPhysicalGrid ( DbU::Unit u, SnapMode mode=Superior );
|
||||||
// Conversions.
|
// Conversions.
|
||||||
static inline long getDb ( Unit u );
|
static inline long getDb ( Unit u );
|
||||||
static inline double getGrid ( Unit u );
|
static inline double getGrid ( Unit u );
|
||||||
|
@ -136,6 +137,7 @@ namespace Hurricane {
|
||||||
inline void DbU::setStringMode ( unsigned int mode ) { _stringMode = mode; }
|
inline void DbU::setStringMode ( unsigned int mode ) { _stringMode = mode; }
|
||||||
inline void DbU::setRealSnapGridStep ( DbU::Unit step ) { _realSnapGridStep = step; }
|
inline void DbU::setRealSnapGridStep ( DbU::Unit step ) { _realSnapGridStep = step; }
|
||||||
inline void DbU::setSymbolicSnapGridStep ( DbU::Unit step ) { _symbolicSnapGridStep = step; }
|
inline void DbU::setSymbolicSnapGridStep ( DbU::Unit step ) { _symbolicSnapGridStep = step; }
|
||||||
|
inline DbU::Unit DbU::getOnPhysicalGrid ( DbU::Unit u, SnapMode mode ) { return getOnCustomGrid(u, grid(1), mode); }
|
||||||
|
|
||||||
|
|
||||||
} // End of Hurricane namespace.
|
} // End of Hurricane namespace.
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
hurricane/viewer/GraphicsWidget.h
|
hurricane/viewer/GraphicsWidget.h
|
||||||
hurricane/viewer/ExceptionWidget.h
|
hurricane/viewer/ExceptionWidget.h
|
||||||
hurricane/viewer/BreakpointWidget.h
|
hurricane/viewer/BreakpointWidget.h
|
||||||
|
hurricane/viewer/MousePositionWidget.h
|
||||||
hurricane/viewer/Selector.h
|
hurricane/viewer/Selector.h
|
||||||
hurricane/viewer/Command.h
|
hurricane/viewer/Command.h
|
||||||
hurricane/viewer/AreaCommand.h
|
hurricane/viewer/AreaCommand.h
|
||||||
|
|
|
@ -61,6 +61,10 @@ using namespace Hurricane;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
#define LOAD_CONSTANT(CONSTANT_VALUE,CONSTANT_NAME) \
|
||||||
|
constant = PyInt_FromLong ( (long)CONSTANT_VALUE ); \
|
||||||
|
PyDict_SetItemString ( dictionnary, CONSTANT_NAME, constant ); \
|
||||||
|
Py_DECREF ( constant );
|
||||||
|
|
||||||
// x=================================================================x
|
// x=================================================================x
|
||||||
// | "PyDbU" Python Module Code Part |
|
// | "PyDbU" Python Module Code Part |
|
||||||
|
@ -68,6 +72,50 @@ extern "C" {
|
||||||
|
|
||||||
#if defined(__PYTHON_MODULE__)
|
#if defined(__PYTHON_MODULE__)
|
||||||
|
|
||||||
|
// x-------------------------------------------------------------x
|
||||||
|
// | "PyDbU" Local Functions |
|
||||||
|
// x-------------------------------------------------------------x
|
||||||
|
|
||||||
|
static DbU::SnapMode PyInt_AsSnapMode ( PyObject* object ) {
|
||||||
|
switch ( PyInt_AsLong(object) ) {
|
||||||
|
case DbU::Inferior : return ( DbU::Inferior );
|
||||||
|
case DbU::Superior : return ( DbU::Superior );
|
||||||
|
case DbU::Nearest : return ( DbU::Nearest );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( DbU::Superior );
|
||||||
|
}
|
||||||
|
|
||||||
|
static DbU::UnitPower PyInt_AsUnitPower ( PyObject* object ) {
|
||||||
|
switch ( PyInt_AsLong(object) ) {
|
||||||
|
case DbU::Pico : return ( DbU::Pico );
|
||||||
|
case DbU::Nano : return ( DbU::Nano );
|
||||||
|
case DbU::Micro : return ( DbU::Micro );
|
||||||
|
case DbU::Milli : return ( DbU::Milli );
|
||||||
|
case DbU::Unity : return ( DbU::Unity );
|
||||||
|
case DbU::Kilo : return ( DbU::Kilo );
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( DbU::Micro );
|
||||||
|
}
|
||||||
|
|
||||||
|
// x-------------------------------------------------------------x
|
||||||
|
// | Global Constants Loading |
|
||||||
|
// x-------------------------------------------------------------x
|
||||||
|
|
||||||
|
extern void DbULoadConstants ( PyObject* dictionnary ) {
|
||||||
|
PyObject* constant;
|
||||||
|
|
||||||
|
LOAD_CONSTANT ( DbU::Inferior, "SnapModeInferior" )
|
||||||
|
LOAD_CONSTANT ( DbU::Superior, "SnapModeSuperior" )
|
||||||
|
LOAD_CONSTANT ( DbU::Nearest , "SnapModeNearest" )
|
||||||
|
LOAD_CONSTANT ( DbU::Pico , "UnitPowerPico" )
|
||||||
|
LOAD_CONSTANT ( DbU::Nano , "UnitPowerNano" )
|
||||||
|
LOAD_CONSTANT ( DbU::Micro , "UnitPowerMicro" )
|
||||||
|
LOAD_CONSTANT ( DbU::Milli , "UnitPowerMilli" )
|
||||||
|
LOAD_CONSTANT ( DbU::Unity , "UnitPowerUnity" )
|
||||||
|
LOAD_CONSTANT ( DbU::Kilo , "UnitPowerKilo" )
|
||||||
|
}
|
||||||
|
|
||||||
// x-------------------------------------------------------------x
|
// x-------------------------------------------------------------x
|
||||||
// | "PyDbU" General Methods |
|
// | "PyDbU" General Methods |
|
||||||
|
@ -200,6 +248,20 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
// Module Method : "PyDbU_getPhysical ()"
|
||||||
|
|
||||||
|
extern PyObject* PyDbU_getPhysical ( PyObject* module, PyObject* args )
|
||||||
|
{
|
||||||
|
trace << "PyDbU_getPhysical ()" << endl;
|
||||||
|
|
||||||
|
PyObject* arg0;
|
||||||
|
PyObject* arg1;
|
||||||
|
if ( ! ParseTwoArg ( "Dbu.getPhysical", args,INTS2_ARG, &arg0, &arg1 ) ) return ( NULL );
|
||||||
|
|
||||||
|
return ( Py_BuildValue("d",DbU::getPhysical(PyInt_AsLong(arg0), PyInt_AsUnitPower(arg1))) );
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------
|
// ---------------------------------------------------------------
|
||||||
// Module Method : "PyDbU_getResolution ()"
|
// Module Method : "PyDbU_getResolution ()"
|
||||||
|
|
||||||
|
@ -211,6 +273,36 @@ extern "C" {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------
|
||||||
|
// Module Method : "PyDbu_getOnPhysicalGrid ()"
|
||||||
|
|
||||||
|
extern PyObject* PyDbU_getOnPhysicalGrid ( PyObject* module, PyObject* args )
|
||||||
|
{
|
||||||
|
trace << "PyDbU_getOnPhysicalGrid ()" << endl;
|
||||||
|
|
||||||
|
PyObject* arg0;
|
||||||
|
PyObject* arg1;
|
||||||
|
DbU::Unit result;
|
||||||
|
|
||||||
|
HTRY
|
||||||
|
__cs.init ( "DbU.getOnPhysicalGrid" );
|
||||||
|
if (!PyArg_ParseTuple(args, "O&|O&O&:DbU.getOnPhysicalGrid", Converter, &arg0, Converter, &arg1)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( __cs.getObjectIds() == INTS2_ARG ) {
|
||||||
|
result = DbU::getOnPhysicalGrid ( PyInt_AsLong(arg0), PyInt_AsSnapMode(arg1) );
|
||||||
|
} else if ( __cs.getObjectIds() == INT_ARG ) {
|
||||||
|
result = DbU::getOnPhysicalGrid ( PyInt_AsLong(arg0) );
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
HCATCH
|
||||||
|
|
||||||
|
return ( Py_BuildValue ( "i", result ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // End of Python Module Code Part.
|
#endif // End of Python Module Code Part.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -506,6 +506,8 @@ extern "C" {
|
||||||
, { "DbU_getDb" , PyDbU_getDb , METH_VARARGS, "Converts a DbU::Unit to an integer value (no scale factor)." }
|
, { "DbU_getDb" , PyDbU_getDb , METH_VARARGS, "Converts a DbU::Unit to an integer value (no scale factor)." }
|
||||||
, { "DbU_getGrid" , PyDbU_getGrid , METH_VARARGS, "Converts a DbU::Unit to a to grid founder." }
|
, { "DbU_getGrid" , PyDbU_getGrid , METH_VARARGS, "Converts a DbU::Unit to a to grid founder." }
|
||||||
, { "DbU_getLambda" , PyDbU_getLambda , METH_VARARGS, "Converts a DbU::Unit to a symbolic value (to lambda)." }
|
, { "DbU_getLambda" , PyDbU_getLambda , METH_VARARGS, "Converts a DbU::Unit to a symbolic value (to lambda)." }
|
||||||
|
, { "DbU_getPhysical" , PyDbU_getPhysical , METH_VARARGS, "Converts a DbU::Unit to a physical value." }
|
||||||
|
, { "DbU_getOnPhysicalGrid" , PyDbU_getOnPhysicalGrid , METH_VARARGS, "Adjusts a DbU::Unit to physical grid." }
|
||||||
, { "Point" , PyPoint_create , METH_VARARGS, "Creates a new Point." }
|
, { "Point" , PyPoint_create , METH_VARARGS, "Creates a new Point." }
|
||||||
, { "Box" , PyBox_create , METH_VARARGS, "Creates a new Box." }
|
, { "Box" , PyBox_create , METH_VARARGS, "Creates a new Box." }
|
||||||
, { "Transformation" , PyTransformation_create , METH_VARARGS, "Creates a new Transformation." }
|
, { "Transformation" , PyTransformation_create , METH_VARARGS, "Creates a new Transformation." }
|
||||||
|
@ -679,6 +681,7 @@ extern "C" {
|
||||||
PyDict_SetItemString ( dictionnary, "ProxyError" , ProxyError );
|
PyDict_SetItemString ( dictionnary, "ProxyError" , ProxyError );
|
||||||
PyDict_SetItemString ( dictionnary, "HurricaneError" , HurricaneError );
|
PyDict_SetItemString ( dictionnary, "HurricaneError" , HurricaneError );
|
||||||
|
|
||||||
|
DbULoadConstants ( dictionnary );
|
||||||
TransformationLoadConstants ( dictionnary );
|
TransformationLoadConstants ( dictionnary );
|
||||||
NetLoadConstants ( dictionnary );
|
NetLoadConstants ( dictionnary );
|
||||||
InstanceLoadConstants ( dictionnary );
|
InstanceLoadConstants ( dictionnary );
|
||||||
|
|
|
@ -83,7 +83,11 @@ extern "C" {
|
||||||
extern PyObject* PyDbU_getDb ( PyObject* module, PyObject* args );
|
extern PyObject* PyDbU_getDb ( PyObject* module, PyObject* args );
|
||||||
extern PyObject* PyDbU_getGrid ( PyObject* module, PyObject* args );
|
extern PyObject* PyDbU_getGrid ( PyObject* module, PyObject* args );
|
||||||
extern PyObject* PyDbU_getLambda ( PyObject* module, PyObject* args );
|
extern PyObject* PyDbU_getLambda ( PyObject* module, PyObject* args );
|
||||||
|
extern PyObject* PyDbU_getPhysical ( PyObject* module, PyObject* args );
|
||||||
extern PyObject* PyDbU_getResolution ( PyObject* module );
|
extern PyObject* PyDbU_getResolution ( PyObject* module );
|
||||||
|
extern PyObject* PyDbU_getOnPhysicalGrid ( PyObject* module, PyObject* args );
|
||||||
|
|
||||||
|
extern void DbULoadConstants ( PyObject* dictionnary );
|
||||||
|
|
||||||
|
|
||||||
} // End of extern "C".
|
} // End of extern "C".
|
||||||
|
|
Loading…
Reference in New Issue