Commit 9864c9e6 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit Committed by Kitware Robot
Browse files

Merge topic 'command-button-property-widget'

367eed82 Add command button property widget
parents 5a4c712c 367eed82
......@@ -65,6 +65,8 @@ set (Module_SRCS
pqColorEditorPropertyWidget.h
pqColorToolbar.cxx
pqColorToolbar.h
pqCommandButtonPropertyWidget.cxx
pqCommandButtonPropertyWidget.h
pqCommandLineOptionsBehavior.cxx
pqCommandLineOptionsBehavior.h
pqCopyReaction.cxx
......@@ -230,6 +232,7 @@ set (Module_MOC_HDRS
pqColorSelectorPropertyWidget.h
pqColorEditorPropertyWidget.h
pqColorToolbar.h
pqCommandButtonPropertyWidget.h
pqCommandLineOptionsBehavior.h
pqCopyReaction.h
pqCrashRecoveryBehavior.h
......
/*=========================================================================
Program: ParaView
Module: pqCommandButtonPropertyWidget.cxx
Copyright (c) 2005-2012 Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
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 AUTHORS 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 "pqCommandButtonPropertyWidget.h"
#include "vtkSMProxy.h"
#include "vtkSMProperty.h"
#include <QVBoxLayout>
#include <QPushButton>
pqCommandButtonPropertyWidget::pqCommandButtonPropertyWidget(vtkSMProxy *proxy,
vtkSMProperty *property,
QWidget *parent)
: pqPropertyWidget(proxy, parent),
Property(property)
{
QVBoxLayout *l = new QVBoxLayout;
l->setSpacing(0);
l->setMargin(0);
QPushButton *button = new QPushButton(property->GetXMLLabel());
connect(button, SIGNAL(clicked()), this, SLOT(buttonClicked()));
l->addWidget(button);
this->setShowLabel(false);
this->setLayout(l);
this->setReason() << "pqCommandButtonPropertyWidget for a property with "
<< "the panel_widget=\"command_button\" attribute";
}
pqCommandButtonPropertyWidget::~pqCommandButtonPropertyWidget()
{
}
void pqCommandButtonPropertyWidget::buttonClicked()
{
this->Property->Modified();
this->proxy()->UpdateProperty(this->proxy()->GetPropertyName(this->Property));
}
/*=========================================================================
Program: ParaView
Module: pqCommandButtonPropertyWidget.h
Copyright (c) 2005-2012 Kitware Inc.
All rights reserved.
ParaView is a free software; you can redistribute it and/or modify it
under the terms of the ParaView license version 1.2.
See License_v1.2.txt for the full ParaView license.
A copy of this license can be obtained by contacting
Kitware Inc.
28 Corporate Drive
Clifton Park, NY 12065
USA
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 AUTHORS 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.
=========================================================================*/
#ifndef _pqCommandButtonPropertyWidget_h
#define _pqCommandButtonPropertyWidget_h
#include "pqApplicationComponentsModule.h"
#include "pqPropertyWidget.h"
/// A property widget with a push button for invoking a command on a proxy.
///
/// To use this widget for a property add the 'panel_widget="command_button"'
/// to the property's XML.
class PQAPPLICATIONCOMPONENTS_EXPORT pqCommandButtonPropertyWidget : public pqPropertyWidget
{
Q_OBJECT
public:
explicit pqCommandButtonPropertyWidget(vtkSMProxy *proxy,
vtkSMProperty *property,
QWidget *parent = 0);
~pqCommandButtonPropertyWidget();
private slots:
void buttonClicked();
private:
vtkSMProperty* Property;
};
#endif // _pqCommandButtonPropertyWidget_h
......@@ -37,6 +37,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "pqCalculatorWidget.h"
#include "pqColorEditorPropertyWidget.h"
#include "pqColorSelectorPropertyWidget.h"
#include "pqCommandButtonPropertyWidget.h"
#include "pqCubeAxesPropertyWidget.h"
#include "pqDisplayRepresentationWidget.h"
#include "pqPipelineRepresentation.h"
......@@ -84,6 +85,10 @@ pqStandardPropertyWidgetInterface::createWidgetForProperty(vtkSMProxy *smProxy,
{
return new pqCalculatorWidget(smProxy, smProperty);
}
else if(name == "command_button")
{
return new pqCommandButtonPropertyWidget(smProxy, smProperty);
}
else
{
qDebug() << "Unknown \"panel_widget\" '" << name.c_str() << "' specified.";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment