void JointManager::findAndPutView(std::vector<std::string>  &jointList, std::string jointName, std::string label
									, int row, PosVelEffView::Alignment alignment, int id, bool shiftMirrored)
{
	for (unsigned i = 0; i < jointList.size(); i++)
	{
		if(jointList.at(i) == jointName)
		{
			PosVelEffView *view = new PosVelEffView(alignment, jointList.at(i), id, this);
			view->setOnShiftMirrored(shiftMirrored);
				
			connect(view, SIGNAL(positionChanged()), this, SLOT(handlePositionChanged()));
			connect(view, SIGNAL(velocityChanged()), this, SLOT(handleVelocityChanged()));
			connect(view, SIGNAL(effortChanged()), this, SLOT(handleEffortChanged()));
			
			connect(view, SIGNAL(changeForID(int,PosVelEffView::Field,float))
					, this, SLOT(handleChangeForID(int,PosVelEffView::Field,float)));
			
			if(alignment == PosVelEffView::LEFT || alignment == PosVelEffView::NO_PAIR)
				jointsLayout->addWidget(view, row, 0);
			else
				jointsLayout->addWidget(view, row, 2);
			
			QLabel *nameLabel = new QLabel();
			nameLabel->setAlignment(Qt::AlignCenter);
			nameLabel->setText(QString::fromStdString(label));

			jointsLayout->addWidget(nameLabel, row, 1);	
			jointViews.push_back(view);
			return;
		}
	}
Example #2
0
/****************************************************************************
**
** Copyright (C) 2015
**
** This file is generated by the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

// Include
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QMessageBox>
#include <QDir>
#include <QLabel>
#include <QImageReader>
#include <QListWidgetItem>
#include <QMouseEvent>
#include <QProcess>
#include "tool_audiowidget.h"

namespace Magus
{
    //****************************************************************************/
    QtAudioAndText::QtAudioAndText(const QString& iconDir,
                                   Source source,
                                   const QString& name,
                                   const QString& baseName,
                                   const QSize& size,
                                   QWidget* parent) : QWidget(parent)
    {
        setContentsMargins(-8, -8, -8, -8);
        setMinimumSize(size);
        setMaximumSize(size);
        QHBoxLayout* mainLayout = new QHBoxLayout;
        QVBoxLayout* audioAndNameLayout = new QVBoxLayout;
        mPixmapAudioPlay = QPixmap(iconDir + TOOL_AUDIOWIDGET_ICON_PLAY);
        mPixmapAudioPause = QPixmap(iconDir + TOOL_AUDIOWIDGET_ICON_PAUSE);
        mPixmapAudioStop = QPixmap(iconDir + TOOL_AUDIOWIDGET_ICON_STOP);

        mName = name;
        mBaseName = baseName;
        mSource = source;
        mBaseNameEdit = new QLineEdit;
        mBaseNameEdit->setText(mBaseName);
        mBaseNameEdit->setEnabled(false);

        mTextureLabel = new QLabel();
        mTextureLabel->setPixmap(mPixmapAudioStop);
        mTextureLabel->setScaledContents(true);
        setMouseTracking(true);

        // Layout
        audioAndNameLayout->addWidget(mTextureLabel, 1000);
        audioAndNameLayout->addWidget(mBaseNameEdit, 1);
        mainLayout->addLayout(audioAndNameLayout);
        setLayout(mainLayout);
    }

    //****************************************************************************/
    QtAudioAndText::~QtAudioAndText(void)
    {
    }

    //****************************************************************************/
    void QtAudioAndText::setPlay(void)
    {
        mTextureLabel->setPixmap(mPixmapAudioPlay);
    }

    //****************************************************************************/
    void QtAudioAndText::setPause(void)
    {
        mTextureLabel->setPixmap(mPixmapAudioPause);
    }

    //****************************************************************************/
    void QtAudioAndText::setStop(void)
    {
        mTextureLabel->setPixmap(mPixmapAudioStop);
    }

    //****************************************************************************/
    //****************************************************************************/
    //****************************************************************************/
    QtAudioListWidget::QtAudioListWidget(QWidget* parent) : QListWidget(parent)
    {
        setMouseTracking(true);
        setAcceptDrops(true);
        setDropIndicatorShown(true);
    }

    //****************************************************************************/
    QtAudioListWidget::~QtAudioListWidget(void)
    {
    }

    //****************************************************************************/
    void QtAudioListWidget::keyPressEvent(QKeyEvent* event)
    {
        switch (event->key())
        {
            case Qt::Key_Delete:
            {
                if (count() > 0)
                {
                    QListWidgetItem* item = currentItem();
                    if (item)
                    {
                        QWidget* widget = itemWidget(item);
                        if (widget)
                        {
                            int r = row(item);
                            QtAudioAndText* audioAndText = static_cast<QtAudioAndText*>(widget);
                            QString name = audioAndText->mName;
                            QString baseName = audioAndText->mBaseName;
                            removeItemWidget(item);
                            takeItem(r);
                            emit assetDeleted(name, baseName);
                        }
                    }
                }
            }
            break;
        }

        event->accept();
    }

    //****************************************************************************/
    void QtAudioListWidget::dropEvent(QDropEvent* event)
    {
        const QMimeData *mimeData = event->mimeData();
        if (mimeData->hasUrls())
        {
            QList<QUrl> urlList = mimeData->urls();
            for (int i = 0; i < urlList.size(); ++i)
            {
                QString baseName = urlList.at(i).fileName();
                if (isTypeBasedOnExtension(baseName, MAGUS_SUPPORTED_AUDIO_FORMATS, MAGUS_SUPPORTED_AUDIO_FORMATS_LENGTH))
                {
                    QString name = urlList.at(i).path();
                    stripLeadingSlashes(name);
                    //QMessageBox::information(0, QString("drop"), name); // test
                    emit audioFileDropped(name, baseName);
                }
            }
        }
        event->acceptProposedAction();
    }

    //****************************************************************************/
    void QtAudioListWidget::dragEnterEvent(QDragEnterEvent *event)
    {
        event->acceptProposedAction();
    }

    //****************************************************************************/
    void QtAudioListWidget::dragMoveEvent(QDragMoveEvent *event)
    {
        event->acceptProposedAction();
    }

    //****************************************************************************/
    //****************************************************************************/
    //****************************************************************************/
    QtAudioWidget::QtAudioWidget(const QString& iconDir, QWidget* parent) : QWidget(parent)
    {
        mNameAudio = QString("");
        mBaseNameAudio = QString("");
        mSystemCommandEditAsset = QString("");
        mCurrentAudioPlaying = QString("");
        mLastSelectedAudioAndText = 0;
        mAudioPlayer = new QMediaPlayer();
        connect(mAudioPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(handlePositionChanged(qint64)));
        mContextMenu = 0;
        mIconDir = iconDir;
        setWindowTitle(QString("Texture selection"));
        mTextureSize = QSize(128, 128);
        QHBoxLayout* mainLayout = new QHBoxLayout;
        QVBoxLayout* textureSelectionLayout = new QVBoxLayout;

        // Define selection widget (QtAudioListWidget)
        mSelectionList = new QtAudioListWidget();
        mSelectionList->setViewMode(QListView::ListMode);
        mSelectionList->setWrapping(true);
        mSelectionList->setWordWrap(true);
        mSelectionList->setSpacing(0);
        mSelectionList->setUniformItemSizes(true);
        mSelectionList->setMovement(QListView::Snap);
        mSelectionList->setFlow(QListView::LeftToRight);
        connect(mSelectionList, SIGNAL(audioFileDropped(QString,QString)), this, SLOT(handleAudioFileDropped(QString,QString)));
        connect(mSelectionList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(handleSelected(QListWidgetItem*)));
        connect(mSelectionList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(handleDoubleClicked(QListWidgetItem*)));
        connect(mSelectionList, SIGNAL(itemEntered(QListWidgetItem*)), this, SLOT(handleMouseOver(QListWidgetItem*)));
        connect(mSelectionList, SIGNAL(assetDeleted(QString,QString)), this, SLOT(handleAssetDeleted(QString,QString)));

        // Layout
        textureSelectionLayout->addWidget(mSelectionList);
        mainLayout->addLayout(textureSelectionLayout);
        setLayout(mainLayout);
    }
Example #3
0
void Widget::setPosition(const glm::vec2 &newPosition)
{
    PositionChangedEvent event(position, newPosition);
	position = newPosition;
    handlePositionChanged(event);
}