X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetCreatorFactory.cpp;h=b3122659346d5d5ca98be1d0400a1d07b67d51d9;hb=11e506a02bbd919d5977b3a25cd4cd84ba54fda4;hp=1427e22a709ef242ac8043081cee93f30217d193;hpb=868158fe6d39b25e60ac528295b1c908821e4af5;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp b/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp old mode 100755 new mode 100644 index 1427e22a7..b31226593 --- a/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetCreatorFactory.cpp @@ -1,13 +1,28 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetCreatorFactory.cpp -// Created: 03 Dec 2015 -// Author: Natalia ERMOLAEVA +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// #include #include -#include +#include + +#include #include @@ -17,7 +32,8 @@ std::shared_ptr MY_WIDGET_CREATOR_FACTORY; std::shared_ptr ModuleBase_WidgetCreatorFactory::get() { if (!MY_WIDGET_CREATOR_FACTORY) { - MY_WIDGET_CREATOR_FACTORY = std::shared_ptr(new ModuleBase_WidgetCreatorFactory()); + MY_WIDGET_CREATOR_FACTORY = + std::shared_ptr(new ModuleBase_WidgetCreatorFactory()); } return MY_WIDGET_CREATOR_FACTORY; } @@ -32,43 +48,82 @@ ModuleBase_WidgetCreatorFactory::~ModuleBase_WidgetCreatorFactory() void ModuleBase_WidgetCreatorFactory::registerCreator(const WidgetCreatorPtr& theCreator) { - const std::set& aTypes = theCreator->widgetTypes(); - std::set::const_iterator anIt = aTypes.begin(), aLast = aTypes.end(); - for (; anIt != aLast; anIt++) { + std::set::const_iterator anIt, aLast; + /// fill map of panels + std::set aPanelTypes; + theCreator->panelTypes(aPanelTypes); + for (anIt = aPanelTypes.begin(), aLast = aPanelTypes.end(); anIt != aLast; anIt++) { + std::string aKey = *anIt; + if (!myPanelToCreator.contains(aKey)) + myPanelToCreator[aKey] = theCreator; + else { + Events_InfoMessage("ModuleBase_WidgetCreatorFactory", + "The %1 panel XML definition has been already used by another widget creator") + .arg(aKey).send(); + } + } + + /// fill map of widgets + std::set aTypes; + theCreator->widgetTypes(aTypes); + for (anIt = aTypes.begin(), aLast = aTypes.end(); anIt != aLast; anIt++) { std::string aKey = *anIt; if (!myCreators.contains(aKey)) myCreators[aKey] = theCreator; else { - Events_Error::send("The" + aKey + " widget XML definition has been already \ -used by another widget creator"); + Events_InfoMessage("ModuleBase_WidgetCreatorFactory", + "The %1 widget XML definition has been already used by another widget creator") + .arg(aKey).send(); } } - const std::set& aPTypes = theCreator->pageTypes(); + /// fill map of pages + std::set aPTypes; + theCreator->pageTypes(aPTypes); for (anIt = aPTypes.begin(), aLast = aPTypes.end(); anIt != aLast; anIt++) { std::string aKey = *anIt; if (!myPageToCreator.contains(aKey)) myPageToCreator[aKey] = theCreator; else { - Events_Error::send("The" + aKey + " page XML definition has been already \ -used by another widget creator"); + Events_InfoMessage("ModuleBase_WidgetCreatorFactory", + "The %1 page XML definition has been already used by another widget creator") + .arg(aKey).send(); } } } +bool ModuleBase_WidgetCreatorFactory::hasPanelWidget(const std::string& theType) +{ + return myPanelToCreator.contains(theType); +} + +QWidget* ModuleBase_WidgetCreatorFactory::createPanelByType(const std::string& theType, + QWidget* theParent, + const FeaturePtr& theFeature, + Config_WidgetAPI* myWidgetApi) +{ + QWidget* aPanel = 0; + if (myPanelToCreator.contains(theType)) { + WidgetCreatorPtr aCreator = myPanelToCreator[theType]; + aPanel = aCreator->createPanelByType(theType, theParent, theFeature, myWidgetApi); + } + return aPanel; +} + bool ModuleBase_WidgetCreatorFactory::hasPageWidget(const std::string& theType) { return myPageToCreator.contains(theType); } ModuleBase_PageBase* ModuleBase_WidgetCreatorFactory::createPageByType( - const std::string& theType, QWidget* theParent) + const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi) { ModuleBase_PageBase* aPage = 0; if (myPageToCreator.contains(theType)) { WidgetCreatorPtr aCreator = myPageToCreator[theType]; - aPage = aCreator->createPageByType(theType, theParent); + aPage = aCreator->createPageByType(theType, theParent, theWidgetApi); } return aPage; @@ -76,13 +131,15 @@ ModuleBase_PageBase* ModuleBase_WidgetCreatorFactory::createPageByType( ModuleBase_ModelWidget* ModuleBase_WidgetCreatorFactory::createWidgetByType( - const std::string& theType, QWidget* theParent) + const std::string& theType, QWidget* theParent, + Config_WidgetAPI* theWidgetApi, + ModuleBase_IWorkshop* theWorkshop) { ModuleBase_ModelWidget* aWidget = 0; if (myCreators.contains(theType)) { WidgetCreatorPtr aCreator = myCreators[theType]; - aWidget = aCreator->createWidgetByType(theType, theParent); + aWidget = aCreator->createWidgetByType(theType, theParent, theWidgetApi, theWorkshop); } return aWidget;