bool SensorManager::GetKinectSensor( KCBHANDLE kcbHandle, std::shared_ptr<KinectSensor>& pSensor  )
{
    assert( nullptr == pSensor );

    if( KCB_INVALID_HANDLE == kcbHandle )
    {
        return false;
    }

    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    // find the port id for the handle
    auto iter = m_handleMap.find( kcbHandle );
    if( iter == m_handleMap.end() )
    {
        return nullptr;
    }

    // from the Port ID, gets the instance of the sensor object
    auto sensorIter = m_kinectSensors.find( iter->second );

    assert( nullptr != sensorIter->second );

    pSensor = sensorIter->second;

    return true;
}
void SensorManager::CloseSensorHandle( KCBHANDLE& kcbHandle )
{
    assert( KCB_INVALID_HANDLE != kcbHandle );

    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    auto iter = m_handleMap.find( kcbHandle );
    if( iter == m_handleMap.end() )
    {
        return;
    }

    // found the handle, find the sensor for this handle
    KinectSensor* pSensor = nullptr;
    auto sensorIter = m_kinectSensors.find( iter->second );
    if( sensorIter != m_kinectSensors.end() )
    {
        sensorIter->second->Close();
    }

    // remove the handle from the list
    m_handleMap.erase(iter);

    kcbHandle = KCB_INVALID_HANDLE;
}
// gets the current amount of senosrs on the list
UINT SensorManager::GetSensorCount() 
{ 
    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    UINT count = (UINT)m_kinectSensors.size(); 

    return count;
}
void SensorManager::UpdateSensorOnList( _In_z_ const WCHAR* wcPortID, _In_ HRESULT hrStatus )
{
    // set the lock on the list
    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    // find the sensor id on the list
    auto iter = m_kinectSensors.find( wcPortID );
    if( iter == m_kinectSensors.end() )
    {
        // we didn't find this port id of a sensor
        // look for a temporary sensor that we can assign this to

        // select the first one on the list 
        iter = m_kinectSensors.begin();
        if( m_kinectSensors.size() == 1 && !iter->first.compare( this->m_wcTempPortID ) )
        {
            // hold on to the instance of the sensor
            // have to re-add it to the list with the correct PortID
            auto pSensor = iter->second;
            assert( nullptr != pSensor );

            // has a handle been issued for the temporary sensor
            std::wstring wsPortID( pSensor->GetPortID() );
            for( auto handleIter = m_handleMap.begin(); handleIter != m_handleMap.end(); ++handleIter )
            {
                if( 0 == wsPortID.compare( handleIter->second ) )
                {
                    // update the portID for the handle
                    handleIter->second = wcPortID;
                    break;
                }
            }

            // now remove it from the sensor map
            // set the lock/wait to modify the map of sensors
            m_kinectSensors.erase( iter );

            // add it with the correct id
            m_kinectSensors.insert( std::make_pair(wcPortID, pSensor) );
        }
        else
        {
            // wasn't a sensor available based on the wcPortID
            // so we can create one since the id seems valid
            AddSensorToList( wcPortID );
        }

        // should be there now since we can account to all id's
        // on the system
        iter = m_kinectSensors.find( wcPortID );
    }

    // notify the wrapper of the change
    iter->second->NuiStatusNotification( iter->first.c_str(), hrStatus );
}
// when the instance is first created, it will create an initial
// set of sensor objects
void SensorManager::Initialize()
{
    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    CreateListOfAvailableSensors();

    // Set the sensor status callback
    NuiSetDeviceStatusCallback( NuiStatusCallback, this );
}
// Dtor
SensorManager::~SensorManager()
{
    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    // explicit clean up of all the sensor objects
    for (auto iter = m_kinectSensors.begin(); iter != m_kinectSensors.end(); ++iter)
    {
        // release the created pointer
        iter->second.reset();
    }

    m_handleMap.clear();
    m_kinectSensors.clear();
}
// provides the wrapper a handle to the C api
KCBHANDLE SensorManager::OpenDefaultSensor()
{
    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    auto pSensor = GetDefaultSensor();

    assert( nullptr != pSensor );

    // get a handle for this port id
    KCBHANDLE kcbHandle = GetHandle( pSensor->GetPortID() );

    // set the select flag on the sensor
    pSensor->Open();

    return kcbHandle;
}
// create the handle with a known PortID
KCBHANDLE SensorManager::OpenSensorByPortID( _In_z_ const WCHAR* wcPortID )
{
    AutoLock sensorLock( m_csSensorLock );
    AutoLock handleLock( m_csHandleLock );

    auto pSensor = GetSensor( wcPortID );
    if( nullptr == pSensor )
    {
        return KCB_INVALID_HANDLE;
    }
    
    // get a handle for this port id
    KCBHANDLE kcbHandle = GetHandle( pSensor->GetPortID() );

    // open the default streams
    pSensor->Open();

    return kcbHandle;
}
예제 #9
0
PropertiesPalette_XYZ::PropertiesPalette_XYZ( QWidget* parent) : QWidget(parent)
{
	m_ScMW=0;
	m_doc=0;
	m_haveDoc  = false;
	m_haveItem = false;
	m_lineMode = false;
	m_oldRotation = 0;
	m_unitRatio = 1.0;

	setupUi(this);
	setSizePolicy( QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));

	_userActionOn = false;
	userActionSniffer = new UserActionSniffer(this);
	connect(userActionSniffer, SIGNAL(actionStart()), this, SLOT(spinboxStartUserAction()));
	connect(userActionSniffer, SIGNAL(actionEnd()), this, SLOT(spinboxFinishUserAction()));

	nameEdit->setFocusPolicy(Qt::ClickFocus);

	installSniffer(xposSpin);
	installSniffer(yposSpin);
	installSniffer(widthSpin);
	installSniffer(heightSpin);

	xposLabel->setBuddy(xposSpin);
	yposLabel->setBuddy(yposSpin);
	widthLabel->setBuddy(widthSpin);
	heightLabel->setBuddy(heightSpin);

	keepFrameWHRatioButton->setCheckable( true );
	keepFrameWHRatioButton->setAutoRaise( true );
	keepFrameWHRatioButton->setMaximumSize( QSize( 15, 32767 ) );
	keepFrameWHRatioButton->setChecked(false);
	rotationSpin->setWrapping( true );
	installSniffer(rotationSpin);

	rotationSpin->setNewUnit(6);
	rotationLabel->setBuddy(rotationSpin);

	levelUp->setIcon(QIcon(loadIcon("16/go-up.png")));
	levelDown->setIcon(QIcon(loadIcon("16/go-down.png")));
	levelTop->setIcon(QIcon(loadIcon("16/go-top.png")));
	levelBottom->setIcon(QIcon(loadIcon("16/go-bottom.png")));
	levelLabel->setAlignment( Qt::AlignCenter );

	doGroup->setIcon(QIcon(loadIcon("group.png")));
	doUnGroup->setIcon(QIcon(loadIcon("ungroup.png")));

	flipH->setIcon(QIcon(loadIcon("16/flip-object-horizontal.png")));
	flipH->setCheckable( true );
	flipV->setIcon(QIcon(loadIcon("16/flip-object-vertical.png")));
	flipV->setCheckable( true );
	
	doLock->setCheckable( true );
	QIcon a = QIcon();
	a.addPixmap(loadIcon("16/lock.png"), QIcon::Normal, QIcon::On);
	a.addPixmap(loadIcon("16/lock-unlocked.png"), QIcon::Normal, QIcon::Off);
	doLock->setIcon(a);

	noPrint->setCheckable( true );
	QIcon a2 = QIcon();
	a2.addPixmap(loadIcon("NoPrint.png"), QIcon::Normal, QIcon::On);
	a2.addPixmap(loadIcon("16/document-print.png"), QIcon::Normal, QIcon::Off);
	noPrint->setIcon(a2);

	noResize->setCheckable( true );
	QIcon a3 = QIcon();
	a3.addPixmap(loadIcon("framenoresize.png"), QIcon::Normal, QIcon::On);
	a3.addPixmap(loadIcon("frameresize.png"), QIcon::Normal, QIcon::Off);
	noResize->setIcon(a3);

	m_lineMode = false;

	languageChange();

	connect(xposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewX()));
	connect(yposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewY()));
	connect(widthSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewW()));
	connect(heightSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewH()));
	connect(rotationSpin, SIGNAL(valueChanged(double)), this, SLOT(handleRotation()));
	connect(flipH, SIGNAL(clicked()), this, SLOT(handleFlipH()));
	connect(flipV, SIGNAL(clicked()), this, SLOT(handleFlipV()));
	connect(levelUp, SIGNAL(clicked()), this, SLOT(handleRaise()));
	connect(levelDown, SIGNAL(clicked()), this, SLOT(handleLower()));
	connect(levelTop, SIGNAL(clicked()), this, SLOT(handleFront()));
	connect(levelBottom, SIGNAL(clicked()), this, SLOT(handleBack()));
	connect(basePointWidget, SIGNAL(buttonClicked(int)), this, SLOT(handleBasePoint(int)));

	connect(nameEdit , SIGNAL(Leaved()) , this, SLOT(handleNewName()));
	connect(doLock   , SIGNAL(clicked()), this, SLOT(handleLock()));
	connect(noPrint  , SIGNAL(clicked()), this, SLOT(handlePrint()));
	connect(noResize , SIGNAL(clicked()), this, SLOT(handleLockSize()));
	connect(doGroup  , SIGNAL(clicked()), this, SLOT(handleGrouping()) );
	connect(doUnGroup, SIGNAL(clicked()), this, SLOT(handleUngrouping()) );

	m_haveItem = false;
	xposSpin->showValue(0);
	yposSpin->showValue(0);
	widthSpin->showValue(0);
	heightSpin->showValue(0);
	rotationSpin->showValue(0);
}
예제 #10
0
void PropertiesPalette_XYZ::setCurrentItem(PageItem *i)
{
	if (!m_ScMW || m_ScMW->scriptIsRunning())
		return;
	//CB We shouldnt really need to process this if our item is the same one
	//maybe we do if the item has been changed by scripter.. but that should probably
	//set some status if so.
	//FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
	//if (m_item == i)
	//	return;

	if (!m_doc)
		setDoc(i->doc());

	disconnect(nameEdit, SIGNAL(Leaved()), this, SLOT(handleNewName()));

	m_haveItem = false;
	m_item = i;

	nameEdit->setText(m_item->itemName());
	QString tm;
	levelLabel->setText(tm.setNum(m_item->ItemNr + 1));

	connect(nameEdit, SIGNAL(Leaved()), this, SLOT(handleNewName()));

//CB replaces old emits from PageItem::emitAllToGUI()
	disconnect(xposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewX()));
	disconnect(yposSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewY()));
	disconnect(widthSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewW()));
	disconnect(heightSpin, SIGNAL(valueChanged(double)), this, SLOT(handleNewH()));
	disconnect(doLock, SIGNAL(clicked()), this, SLOT(handleLock()));
	disconnect(noPrint, SIGNAL(clicked()), this, SLOT(handlePrint()));
	disconnect(noResize, SIGNAL(clicked()), this, SLOT(handleLockSize()));
	disconnect(flipH, SIGNAL(clicked()), this, SLOT(handleFlipH()));
	disconnect(flipV, SIGNAL(clicked()), this, SLOT(handleFlipV()));
	disconnect(rotationSpin, SIGNAL(valueChanged(double)), this, SLOT(handleRotation()));

	double selX = m_item->xPos();
	double selY = m_item->yPos();
	double selW = m_item->width();
	double selH = m_item->height();
	if (m_doc->m_Selection->count() > 1)
		m_doc->m_Selection->getGroupRect(&selX, &selY, &selW, &selH);
	displayXY(selX, selY);
	displayWH(selW, selH);
	
	bool checkableFlip = (i->isImageFrame() || i->isTextFrame() || i->isLatexFrame() || i->isOSGFrame() || i->isSymbol() || i->isGroup() || i->isSpiral());
	flipH->setCheckable(checkableFlip);
	flipV->setCheckable(checkableFlip);

	noPrint->setChecked(!i->printEnabled());
	displayFlippedH(i->imageFlippedH());
	displayFlippedV(i->imageFlippedV());
	m_oldRotation = i->rotation();
	double rr = i->rotation();
	if (i->rotation() > 0)
		rr = 360 - rr;
	rotationSpin->setValue(fabs(rr));

//CB TODO reconnect PP signals from here
	connect(xposSpin    , SIGNAL(valueChanged(double)), this, SLOT(handleNewX()));
	connect(yposSpin    , SIGNAL(valueChanged(double)), this, SLOT(handleNewY()));
	connect(widthSpin   , SIGNAL(valueChanged(double)), this, SLOT(handleNewW()));
	connect(heightSpin  , SIGNAL(valueChanged(double)), this, SLOT(handleNewH()));
	connect(doLock  , SIGNAL(clicked()), this, SLOT(handleLock()));
	connect(noPrint , SIGNAL(clicked()), this, SLOT(handlePrint()));
	connect(noResize, SIGNAL(clicked()), this, SLOT(handleLockSize()));
	connect(flipH   , SIGNAL(clicked()), this, SLOT(handleFlipH()));
	connect(flipV   , SIGNAL(clicked()), this, SLOT(handleFlipV()));
	connect(rotationSpin, SIGNAL(valueChanged(double)), this, SLOT(handleRotation()));

	bool setter = false;
	if ((m_item->isTableItem) && (m_item->isSingleSel))
	{
		setter = true;
		rotationSpin->setEnabled(false);
	}
	xposSpin->setEnabled(!setter);
	yposSpin->setEnabled(!setter);
	levelGroup->setEnabled(!setter);
	if ((m_item->isGroup()) && (!m_item->isSingleSel))
	{
		setEnabled(true);
	}
	if ((m_item->itemType() == PageItem::Line) && m_lineMode)
	{
		xposLabel->setText( tr( "&X1:" ) );
		widthLabel->setText( tr( "X&2:" ) );
		yposLabel->setText( tr( "Y&1:" ) );
		heightLabel->setText( tr( "&Y2:" ) );
		rotationSpin->setEnabled(false);
	}
	else
	{
		xposLabel->setText( tr( "&X-Pos:" ) );
		widthLabel->setText( tr( "&Width" ) );
		yposLabel->setText( tr( "&Y-Pos:" ) );
		heightLabel->setText( tr( "&Height:" ) );
		rotationSpin->setEnabled(!((m_item->isTableItem) && (m_item->isSingleSel)));
	}
	m_haveItem = true;
	if (m_item->asLine())
	{
		keepFrameWHRatioButton->setEnabled(false);
		heightSpin->setEnabled(m_lineMode && !m_item->locked());
	}
	else
	{
		heightSpin->setEnabled(true);
		keepFrameWHRatioButton->setEnabled(true);
	}
	displayXY(selX, selY);
	displayWH(selW, selH);
	displayLocked(i->locked());
	displaySizeLocked(i->sizeLocked());
	double rrR = i->imageRotation();
	if (i->imageRotation() > 0)
		rrR = 360 - rrR;
	noResize->setEnabled(!m_item->isArc());
	
	doGroup->setEnabled(false);
	doUnGroup->setEnabled(false);
	if (m_doc->m_Selection->count() > 1)
		doGroup->setEnabled(true);
	if (m_doc->m_Selection->count() == 1)
		doUnGroup->setEnabled(m_item->isGroup());
	if (m_item->asOSGFrame())
	{
		setEnabled(true);
		rotationSpin->setEnabled(false);
	}
	if (m_item->asSymbolFrame())
	{
		setEnabled(true);
	}
	updateSpinBoxConstants();
}