Example #1
0
void MainFrm::callAssistant()
{
    if (process!=0){
        process->close();
        delete process; process=0;
    }
     process = new QProcess(this);

    //Builds filename from search path; app *SHOULD BE* on the path!
    QFile helpFile("help:mycollection.qhc");
    QString strHelpFilePath(QFileInfo(helpFile).absoluteFilePath());
    qDebug() << "help is located here: " << strHelpFilePath << endl;

    QStringList args;
    args << QLatin1String("-collectionFile")
         << strHelpFilePath
    << QLatin1String("-enableRemoteControl");

     process->start(QLatin1String("assistant"), args);
     if (!process->waitForStarted()) {
         QMessageBox::critical(this, tr("Remote Control"),
                               tr("Could not start Qt Assistant from %1.").arg("assistant"));
         return;
     }

    QByteArray ba;
    //ba.append("setSource qthelp://medfisis.app.1_1/doc/index.html");
    if (!curHelpId.isEmpty() && !curHelpId.isNull()){
        ba.append("ActivateIdentifier " + curHelpId);
        curHelpId="";
    }else
        ba.append("setSource qthelp://medfisis.app.1_1/doc/index.htm\n;");
    process->write(ba);

}
Example #2
0
void HelpTreeWidget::openJsonDocument(const QString &filepath)
{
    QJsonDocument doc;
    QFile helpFile(filepath);
    if (!helpFile.open(QIODevice::ReadOnly)) {
        qWarning("Could not open pro file");
        return;
    }
    QByteArray jData = helpFile.readAll();
    helpFile.close();

    doc = QJsonDocument::fromJson(jData);
    QJsonObject obj = doc.object();
    QJsonArray jarray = obj["help"].toArray();

    for (int i = 0; i < jarray.size(); i++)
    {
        QString itemName = jarray.at(i).toObject()["name"].toString();
        QString itemDdsc = jarray.at(i).toObject()["dsc"].toString();

        QTreeWidgetItem *name = new QTreeWidgetItem();
        QTreeWidgetItem *dsc = new QTreeWidgetItem();
        name->setData(0, Qt::DisplayRole, itemName);
        dsc->setData(0, Qt::DisplayRole, itemDdsc);
        name->addChild(dsc);
        m_tree->addTopLevelItem(name);
    }
}
Example #3
0
void VDShowHelp(HWND hwnd, const wchar_t *filename) {
	try {
		VDStringW helpFile(VDGetHelpPath());

		if (!VDDoesPathExist(helpFile.c_str()))
			throw MyError("Cannot find help file: %ls", helpFile.c_str());

		// If we're on Windows NT, check for the ADS and/or network drive.
		if (VDIsWindowsNT()) {
			VDStringW helpFileADS(helpFile);
			helpFileADS += L":Zone.Identifier";
			if (VDDoesPathExist(helpFileADS.c_str())) {
				int rv = MessageBox(hwnd, "VirtualDub has detected that its help file, VirtualDub.chm, has an Internet Explorer download location marker on it. This may prevent the help file from being displayed properly, resulting in \"Action canceled\" errors being displayed. Would you like to remove it?", "VirtualDub warning", MB_YESNO|MB_ICONEXCLAMATION);

				if (rv == IDYES)
					DeleteFileW(helpFileADS.c_str());
			}
		}

		if (filename) {
			helpFile.append(L"::/");
			helpFile.append(filename);
		}

		VDStringW helpCommand(VDStringW(L"\"hh.exe\" \"") + helpFile + L'"');

		PROCESS_INFORMATION pi;
		BOOL retval;

		// CreateProcess will actually modify the string that it gets, soo....
		if (VDIsWindowsNT()) {
			STARTUPINFOW si = {sizeof(STARTUPINFOW)};
			std::vector<wchar_t> tempbufW(helpCommand.size() + 1, 0);
			helpCommand.copy(&tempbufW[0], tempbufW.size());
			retval = CreateProcessW(NULL, &tempbufW[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		} else {
			STARTUPINFOA si = {sizeof(STARTUPINFOA)};
			VDStringA strA(VDTextWToA(helpCommand));
			std::vector<char> tempbufA(strA.size() + 1, 0);
			strA.copy(&tempbufA[0], tempbufA.size());
			retval = CreateProcessA(NULL, &tempbufA[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		}

		if (retval) {
			CloseHandle(pi.hThread);
			CloseHandle(pi.hProcess);
		} else
			throw MyWin32Error("Cannot launch HTML Help: %%s", GetLastError());
	} catch(const MyError& e) {
		e.post(hwnd, g_szError);
	}
}
Example #4
0
static void
throwDispatchException (EXCEPINFO &excepInfo)
{
    // Clean up exception information strings.
    _bstr_t source(excepInfo.bstrSource, false);
    _bstr_t description(excepInfo.bstrDescription, false);
    _bstr_t helpFile(excepInfo.bstrHelpFile, false);

    HRESULT hr = excepInfo.scode;
    if (hr == 0) {
        hr = _com_error::WCodeToHRESULT(excepInfo.wCode);
    }
    throw DispatchException(hr, description);
}
BOOL OptionsDialog::OnHelpInfo(HELPINFO* pHelpInfo)
{
  static DWORD helpIds[] =
  {
    IDC_PROP_FONT,1,
    IDC_FIXED_FONT,2,
    IDC_FONT_SIZE,3,
    IDC_TEXT_COLOUR,5,
    IDC_BACK_COLOUR,6,
    IDC_TERP_NUMBER,7,
    IDC_ERRORS,8,
    IDC_IGNORE_RUNTIME,9,
    IDC_EXPAND,10,
    IDC_TANDY,11,
    IDC_FAST_SCROLL,12,
    IDC_LEFT_MARGIN,13,
    IDC_RIGHT_MARGIN,14,
    IDC_MORE_PROMPT,15,
    IDC_REGISTER_FILETYPES,16,
    IDC_WRAP_SCRIPT,17,
    IDC_SHOW_IFICTION,18,
    IDC_USERNAME,19,
    IDC_SPEAK,20,
    IDC_VOICE,21,
    IDC_SPEECH_RATE,22,
    0,0
  };

  if (pHelpInfo->iContextType == HELPINFO_WINDOW)
  {
    // Is there a help topic for this control?
    DWORD* id = helpIds;
    while (*id != 0)
    {
      if (pHelpInfo->iCtrlId == *id)
      {
        CString helpFile(AfxGetApp()->m_pszHelpFilePath);
        helpFile.Append("::/options.txt");

        // Show the help popup
        AfxHtmlHelp((HWND)pHelpInfo->hItemHandle,helpFile,
          HH_TP_HELP_WM_HELP,(DWORD_PTR)helpIds);
        return TRUE;
      }
      id += 2;
    }
  }
  return TRUE;
}
Example #6
0
bool
PathGroups::keyPressEvent(QKeyEvent *event)
{
  for(int i=0; i<m_paths.count(); i++)
    {
      if (m_paths[i]->grabsMouse())
	{
	  if (event->key() == Qt::Key_G)
	    {
	      m_paths[i]->removeFromMouseGrabberPool();
	      return true;
	    }
	  if (event->key() == Qt::Key_C)
	    {
	      bool b = m_paths[i]->closed();
	      m_paths[i]->setClosed(!b);
	      return true;
	    }
	  else if (event->key() == Qt::Key_P)
	    {
	      bool b = m_paths[i]->showPoints();
	      m_paths[i]->setShowPoints(!b);    
	      return true;
	    }
	  else if (event->key() == Qt::Key_L)
	    {
	      bool b = m_paths[i]->showLength();
	      m_paths[i]->setShowLength(!b);    
	      return true;
	    }
	  else if (event->key() == Qt::Key_X)
	    {
	      m_paths[i]->setMoveAxis(PathGroupGrabber::MoveX);
	      return true;
	    }
	  else if (event->key() == Qt::Key_Y)
	    {
	      if (event->modifiers() & Qt::ControlModifier ||
		  event->modifiers() & Qt::MetaModifier)
		m_paths[i]->redo();
	      else
		m_paths[i]->setMoveAxis(PathGroupGrabber::MoveY);
	      return true;
	    }
	  else if (event->key() == Qt::Key_Z)
	    {
	      if (event->modifiers() & Qt::ControlModifier ||
		  event->modifiers() & Qt::MetaModifier)
		m_paths[i]->undo();
	      else
		m_paths[i]->setMoveAxis(PathGroupGrabber::MoveZ);
	      return true;
	    }
	  else if (event->key() == Qt::Key_W)
	    {
	      m_paths[i]->setMoveAxis(PathGroupGrabber::MoveAll);
	      return true;
	    }
	  else if (event->key() == Qt::Key_S)
	    {
	      int idx = m_paths[i]->pointPressed();
	      if (idx > -1)
		{
		  float radx = m_paths[i]->getRadX(idx);
		  if (event->modifiers() & Qt::ShiftModifier)
		    radx--;
		  else
		    radx++;
		  radx = qMax(1.0f, radx);
		  m_paths[i]->setRadX(idx, radx, m_sameForAll);
		  return true;
		}
	    }
	  else if (event->key() == Qt::Key_T)
	    {
	      int idx = m_paths[i]->pointPressed();
	      if (idx > -1)
		{
		  float rady = m_paths[i]->getRadY(idx);
		  if (event->modifiers() & Qt::ShiftModifier)
		    rady--;
		  else
		    rady++;
		  rady = qMax(1.0f, rady);
		  m_paths[i]->setRadY(idx, rady, m_sameForAll);
		}
	      else // switch to tube mode
		{
		  if (event->modifiers() & Qt::ShiftModifier)
		    {
		      m_paths[i]->loadCaption();
		    }
		  else
		    {
		      bool b = m_paths[i]->tube();
		      m_paths[i]->setTube(!b);
		    }
		}

	      return true;
	    }
	  else if (event->key() == Qt::Key_A)
	    {
	      int idx = m_paths[i]->pointPressed();
	      if (idx > -1)
		{
		  float a = m_paths[i]->getAngle(idx);
		  if (event->modifiers() & Qt::ShiftModifier)
		    a--;
		  else
		    a++;
		  m_paths[i]->setAngle(idx, a, m_sameForAll);
		  return true;
		}
	    }
	  else if (event->key() == Qt::Key_Delete ||
		   event->key() == Qt::Key_Backspace ||
		   event->key() == Qt::Key_Backtab)
	    {
	      m_paths[i]->removeFromMouseGrabberPool();
	      m_paths.removeAt(i);
	      return true;
	    }

	  if (event->key() == Qt::Key_Space)
	    {
	      PropertyEditor propertyEditor;
	      QMap<QString, QVariantList> plist;

	      QVariantList vlist;

	      vlist.clear();
	      vlist << QVariant("double");
	      vlist << QVariant(m_paths[i]->opacity());
	      vlist << QVariant(0.0);
	      vlist << QVariant(1.0);
	      vlist << QVariant(0.1); // singlestep
	      vlist << QVariant(1); // decimals
	      plist["opacity"] = vlist;

	      vlist.clear();
	      vlist << QVariant("colorgradient");
	      QGradientStops stops = m_paths[i]->stops();
	      for(int s=0; s<stops.size(); s++)
		{
		  float pos = stops[s].first;
		  QColor color = stops[s].second;
		  int r = color.red();
		  int g = color.green();
		  int b = color.blue();
		  int a = color.alpha();
		  vlist << QVariant(pos);
		  vlist << QVariant(r);
		  vlist << QVariant(g);
		  vlist << QVariant(b);
		  vlist << QVariant(a);
		}
	      plist["color"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->filterPathLen());
	      plist["filter on length"] = vlist;

	      float vmin, vmax;
	      m_paths[i]->userPathlenMinmax(vmin, vmax);
	      vlist.clear();
	      vlist << QVariant("string");
	      vlist << QVariant(QString("%1 %2").arg(vmin).arg(vmax));
	      plist["length bounds"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->scaleType());
	      plist["scale type"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->depthcue());
	      plist["depthcue"] = vlist;

	      vlist.clear();
	      vlist << QVariant("int");
	      vlist << QVariant(m_paths[i]->segments());
	      vlist << QVariant(1);
	      vlist << QVariant(100);
	      plist["smoothness"] = vlist;

	      vlist.clear();
	      vlist << QVariant("int");
	      vlist << QVariant(m_paths[i]->sections());
	      vlist << QVariant(1);
	      vlist << QVariant(100);
	      plist["sections"] = vlist;

	      vlist.clear();
	      vlist << QVariant("int");
	      vlist << QVariant(m_paths[i]->sparseness());
	      vlist << QVariant(1);
	      vlist << QVariant(100);
	      plist["sparseness"] = vlist;

	      vlist.clear();
	      vlist << QVariant("int");
	      vlist << QVariant(m_paths[i]->separation());
	      vlist << QVariant(0);
	      vlist << QVariant(10);
	      plist["screen separation"] = vlist;

	      vlist.clear();
	      vlist << QVariant("combobox");
	      vlist << QVariant(m_paths[i]->capType());
	      vlist << QVariant("flat");
	      vlist << QVariant("round");
	      vlist << QVariant("arrow");
	      plist["cap style"] = vlist;

	      vlist.clear();
	      vlist << QVariant("combobox");
	      vlist << QVariant(m_paths[i]->arrowDirection());
	      vlist << QVariant("forward");
	      vlist << QVariant("backward");
	      plist["arrow direction"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->animate());
	      plist["animate"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->allowInterpolate());
	      plist["interpolate"] = vlist;

	      vlist.clear();
	      vlist << QVariant("int");
	      vlist << QVariant(m_paths[i]->animateSpeed());
	      vlist << QVariant(10);
	      vlist << QVariant(100);
	      plist["animation speed"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->arrowForAll());
	      plist["arrows for all"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_sameForAll);
	      plist["same for all"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->clip());
	      plist["clip"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->allowEditing());
	      plist["allow editing"] = vlist;

	      vlist.clear();
	      vlist << QVariant("checkbox");
	      vlist << QVariant(m_paths[i]->blendMode());
	      plist["blend with volume"] = vlist;

	      vlist.clear();
	      plist["command"] = vlist;

	      vlist.clear();
	      QFile helpFile(":/pathgroups.help");
	      if (helpFile.open(QFile::ReadOnly))
		{
		  QTextStream in(&helpFile);
		  QString line = in.readLine();
		  while (!line.isNull())
		    {
		      if (line == "#begin")
			{
			  QString keyword = in.readLine();
			  QString helptext;
			  line = in.readLine();
			  while (!line.isNull())
			    {
			      helptext += line;
			      helptext += "\n";
			      line = in.readLine();
			      if (line == "#end") break;
			    }
			  vlist << keyword << helptext;
			}
		      line = in.readLine();
		    }
		}	      
	      plist["commandhelp"] = vlist;


	      vlist.clear();
	      QString mesg;
	      float pmin, pmax;
	      m_paths[i]->pathlenMinmax(pmin, pmax);
	      mesg = QString("min/max path lengths : %1 %2\n").arg(pmin).arg(pmax);
	      float mins,maxs;
	      mins = m_paths[i]->minScale();
	      maxs = m_paths[i]->maxScale();
	      mesg += QString("min/max scale : %1 %2\n").arg(mins).arg(maxs);
	      vlist << mesg;
	      plist["message"] = vlist;


	      QStringList keys;
	      keys << "color";
	      keys << "opacity";
	      keys << "depthcue";
	      keys << "gap";
	      keys << "filter on length";
	      keys << "length bounds";
	      keys << "scale type";
	      keys << "gap";
	      keys << "smoothness";
	      keys << "sections";
	      keys << "sparseness";
	      keys << "screen separation";
	      keys << "gap";
	      keys << "cap style";
	      keys << "arrow direction";
	      keys << "arrows for all";
	      keys << "gap";
	      keys << "animate";
	      keys << "interpolate";
	      keys << "animation speed";
	      keys << "gap";
	      keys << "same for all";
	      keys << "clip";
	      keys << "blend with volume";
	      keys << "allow editing";
	      keys << "command";
	      keys << "commandhelp";
	      keys << "message";
	      

	      propertyEditor.set("Path Group Parameters", plist, keys);

	      
	      QMap<QString, QPair<QVariant, bool> > vmap;

	      if (propertyEditor.exec() == QDialog::Accepted)
		vmap = propertyEditor.get();
	      else
		return true;

	      keys = vmap.keys();

	      for(int ik=0; ik<keys.count(); ik++)
		{
		  QPair<QVariant, bool> pair = vmap.value(keys[ik]);


		  if (pair.second)
		    {
		      if (keys[ik] == "color")
			{
			  QGradientStops stops = propertyEditor.getGradientStops(keys[ik]);
			  m_paths[i]->setStops(stops);
			}
		      else if (keys[ik] == "opacity")
			m_paths[i]->setOpacity(pair.first.toDouble());
		      else if (keys[ik] == "scale type")
			m_paths[i]->setScaleType(pair.first.toBool());
		      else if (keys[ik] == "sections")
			m_paths[i]->setSections(pair.first.toInt());
		      else if (keys[ik] == "smoothness")
			m_paths[i]->setSegments(pair.first.toInt());
		      else if (keys[ik] == "sparseness")
			m_paths[i]->setSparseness(pair.first.toInt());
		      else if (keys[ik] == "screen separation")
			m_paths[i]->setSeparation(pair.first.toInt());
		      else if (keys[ik] == "depthcue")
			m_paths[i]->setDepthcue(pair.first.toBool());
		      else if (keys[ik] == "animate")
			m_paths[i]->setAnimate(pair.first.toBool());
		      else if (keys[ik] == "interpolate")
			m_paths[i]->setAllowInterpolate(pair.first.toBool());
		      else if (keys[ik] == "animation speed")
			m_paths[i]->setAnimateSpeed(pair.first.toInt());
		      else if (keys[ik] == "cap style")
			m_paths[i]->setCapType(pair.first.toInt());
		      else if (keys[ik] == "arrow direction")
			m_paths[i]->setArrowDirection(pair.first.toInt());
		      else if (keys[ik] == "arrows for all")
			m_paths[i]->setArrowForAll(pair.first.toBool());
		      else if (keys[ik] == "same for all")
			{
			  m_sameForAll = pair.first.toBool();
			  m_paths[i]->setSameForAll(m_sameForAll);
			}
		      else if (keys[ik] == "clip")
			m_paths[i]->setClip(pair.first.toBool());
		      else if (keys[ik] == "allow editing")
			m_paths[i]->setAllowEditing(pair.first.toBool());
		      else if (keys[ik] == "blend with volume")
			m_paths[i]->setBlendMode(pair.first.toBool());
		      else if (keys[ik] == "filter on length")
			m_paths[i]->setFilterPathLen(pair.first.toBool());
		      else if (keys[ik] == "length bounds")
			{
			  QString vstr = pair.first.toString();
			  QStringList vl = vstr.split(" ", QString::SkipEmptyParts);
			  if (vl.count() == 2)
			    m_paths[i]->setUserPathlenMinmax(vl[0].toDouble(),
							     vl[1].toDouble());
			}
		    }
		}

	      QString cmd = propertyEditor.getCommandString();
	      if (!cmd.isEmpty())
		processCommand(i, cmd);	
	      	      
	      updateGL();
	    }
	}
    }
  
  return true;
}
Example #7
0
bool
ClipObject::commandEditor()
{
  PropertyEditor propertyEditor;
  QMap<QString, QVariantList> plist;
  QVariantList vlist;
  vlist.clear();
  plist["command"] = vlist;


  vlist.clear();
  vlist << QVariant("double");
  vlist << QVariant(m_opacity);
  vlist << QVariant(0.0);
  vlist << QVariant(1.0);
  vlist << QVariant(0.1); // singlestep
  vlist << QVariant(1); // decimals
  plist["opacity"] = vlist;
  
  vlist.clear();
  vlist << QVariant("color");
  Vec pcolor = m_color;
  QColor dcolor = QColor::fromRgbF(pcolor.x,
				   pcolor.y,
				   pcolor.z);
  vlist << dcolor;
  plist["color"] = vlist;
  
  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(m_apply);
  plist["apply clipping"] = vlist;

  vlist.clear();
  vlist << QVariant("int");
  vlist << QVariant(m_tfset);
  vlist << QVariant(-1);
  vlist << QVariant(15);
  plist["tfset"] = vlist;

  vlist.clear();
  vlist << QVariant("int");
  vlist << QVariant(m_thickness);
  vlist << QVariant(0);
  vlist << QVariant(200);
  plist["thickness"] = vlist;

  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(m_solidColor);
  plist["solid color"] = vlist;

  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(m_showSlice);
  plist["show slice"] = vlist;

  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(m_showThickness);
  plist["show thickness"] = vlist;

  vlist.clear();
  vlist << QVariant("combobox");
  if (m_viewportType)
    vlist << QVariant(1);
  else
    vlist << QVariant(0);
  vlist << QVariant("orthographic");
  vlist << QVariant("perspective");
  plist["camera type"] = vlist;

  vlist.clear();
  vlist << QVariant("double");
  vlist << QVariant(m_stereo);
  vlist << QVariant(0.0);
  vlist << QVariant(1.0);
  vlist << QVariant(0.1); // singlestep
  vlist << QVariant(1); // decimals
  plist["stereo"] = vlist;
  
  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(m_showOtherSlice);
  plist["show other slice"] = vlist;


  QString vpstr = QString("%1 %2 %3 %4").\
                  arg(m_viewport.x()).\
                  arg(m_viewport.y()).\
                  arg(m_viewport.z()).\
                  arg(m_viewport.w());
  vlist.clear();
  vlist << QVariant("string");
  vlist << QVariant(vpstr);
  plist["viewport"] = vlist;

  vlist.clear();
  vlist << QVariant("double");
  vlist << QVariant(m_viewportScale);
  vlist << QVariant(0.5);
  vlist << QVariant(30.0);
  vlist << QVariant(0.1); // singlestep
  vlist << QVariant(1); // decimals
  plist["viewport scale"] = vlist;  


  vlist.clear();
  QFile helpFile(":/clipobject.help");
  if (helpFile.open(QFile::ReadOnly))
    {
      QTextStream in(&helpFile);
      QString line = in.readLine();
      while (!line.isNull())
	{
	  if (line == "#begin")
	    {
	      QString keyword = in.readLine();
	      QString helptext;
	      line = in.readLine();
	      while (!line.isNull())
		{
		  helptext += line;
		  helptext += "\n";
		  line = in.readLine();
		  if (line == "#end") break;
		}
	      vlist << keyword << helptext;
	    }
	  line = in.readLine();
	}
    }
  
  plist["commandhelp"] = vlist;
  
  //---------------------
  vlist.clear();
  QString mesg;
  if (m_scale1 < 0 || m_scale2 < 0)
    mesg += QString("scales : %1 %2\n").arg(-m_scale1).arg(-m_scale2);
  else
    mesg += QString("vscales : %1 %2\n").arg(m_scale1).arg(m_scale2);

  mesg += QString("opacity : %1\n").arg(m_opacity);
  mesg += QString("position : %1 %2 %3\n").			\
    arg(m_position.x).arg(m_position.y).arg(m_position.z);

  Quaternion q = orientation();
  Vec axis;
  qreal angle;
  q.getAxisAngle(axis, angle);
  mesg += QString("rotation : %1 %2 %3 : %4\n").			\
    arg(axis.x).arg(axis.y).arg(axis.z).arg(RAD2DEG(angle));
  
  
  mesg += QString("Red axis : %1 %2 %3\n").		\
    arg(m_xaxis.x).arg(m_xaxis.y).arg(m_xaxis.z);
  mesg += QString("Green axis : %1 %2 %3\n").		\
    arg(m_yaxis.x).arg(m_yaxis.y).arg(m_yaxis.z);
  mesg += QString("Blue axis : %1 %2 %3\n").		\
    arg(m_tang.x).arg(m_tang.y).arg(m_tang.z);
  
  vlist << mesg;
  
  plist["message"] = vlist;
  //---------------------



  QStringList keys;
  keys << "apply clipping";
  keys << "solid color";
  keys << "show slice";
  keys << "show thickness";
  keys << "show other slice";
  keys << "gap";
  keys << "color";
  keys << "opacity";
  keys << "gap";
  keys << "viewport";
  keys << "tfset";
  keys << "thickness";
  keys << "viewport scale";
  keys << "camera type";
  keys << "stereo";
  keys << "gap";
  keys << "command";
  keys << "commandhelp";
  keys << "message";
  
  propertyEditor.set("Clip Plane Dialog", plist, keys);
  
  QMap<QString, QPair<QVariant, bool> > vmap;

  if (propertyEditor.exec() == QDialog::Accepted)
    vmap = propertyEditor.get();
  else
    return true;
	      
  keys = vmap.keys();

  for(int ik=0; ik<keys.count(); ik++)
    {
      QPair<QVariant, bool> pair = vmap.value(keys[ik]);
      
      
      if (pair.second)
	{
	  if (keys[ik] == "color")
	    {
	      QColor color = pair.first.value<QColor>();
	      float r = color.redF();
	      float g = color.greenF();
	      float b = color.blueF();
	      m_color = Vec(r,g,b);
	    }
	  else if (keys[ik] == "opacity")
	    m_opacity = pair.first.toDouble();
	  else if (keys[ik] == "solid color")
	    m_solidColor = pair.first.toBool();
	  else if (keys[ik] == "apply clipping")
	    m_apply = pair.first.toBool();
	  else if (keys[ik] == "show slice")
	    m_showSlice = pair.first.toBool();
	  else if (keys[ik] == "show thickness")
	    m_showThickness = pair.first.toBool();
	  else if (keys[ik] == "show other slice")
	    m_showOtherSlice = pair.first.toBool();
	  else if (keys[ik] == "tfset")
	    m_tfset = pair.first.toInt();
	  else if (keys[ik] == "thickness")
	    m_thickness = pair.first.toInt();
	  else if (keys[ik] == "viewport scale")
	    m_viewportScale = pair.first.toDouble();
	  else if (keys[ik] == "camera type")
	    m_viewportType = (pair.first.toInt() == 1);
	  else if (keys[ik] == "stereo")
	    m_stereo = pair.first.toDouble();
	  else if (keys[ik] == "viewport")
	    {
	      vpstr = pair.first.toString();
	      QStringList list = vpstr.split(" ", QString::SkipEmptyParts);
	      if (list.count() == 4)
		{
		  float x = list[0].toFloat();
		  float y = list[1].toFloat();
		  float z = list[2].toFloat();
		  float w = list[3].toFloat();
		  if (x < 0.0f || x > 1.0f ||
		      y < 0.0f || y > 1.0f ||
		      z < 0.0f || z > 1.0f ||
		      w < 0.0f || w > 1.0f)
		    QMessageBox::information(0, "",
		      QString("Values for viewport must be between 0.0 and 1.0 : %1 %2 %3 %4").\
					     arg(x).arg(y).arg(z).arg(w));
		  else
		    m_viewport = QVector4D(x,y,z,w);
		}
	      else if (list.count() == 3)
		{
		  float x = list[0].toFloat();
		  float y = list[1].toFloat();
		  float z = list[2].toFloat();
		  if (x < 0.0f || x > 1.0f ||
		      y < 0.0f || y > 1.0f ||
		      z < 0.0f || z > 1.0f)
		    QMessageBox::information(0, "",
		      QString("Values for viewport must be between 0.0 and 1.0 : %1 %2 %3").\
					     arg(x).arg(y).arg(z));
		  else
		    m_viewport = QVector4D(x,y,z,z);
		}
	      else if (list.count() == 2)
		{
		  float x = list[0].toFloat();
		  float y = list[1].toFloat();
		  if (x < 0.0f || x > 1.0f ||
		      y < 0.0f || y > 1.0f)
		    QMessageBox::information(0, "",
		      QString("Values for viewport must be between 0.0 and 1.0 : %1 %2").\
					     arg(x).arg(y));
		  else
		    m_viewport = QVector4D(x,y,0.5,0.5);
		}
	      else
		{
		  QMessageBox::information(0, "", "Switching off the viewport");
		  m_viewport = QVector4D(-1,-1,-1,-1);
		}
	    }
	}
    }

  QString cmd = propertyEditor.getCommandString();
  if (!cmd.isEmpty())
    return processCommand(cmd);
  else
    return true;

//  if (propertyEditor.exec() == QDialog::Accepted)
//    {
//      QString cmd = propertyEditor.getCommandString();
//      if (!cmd.isEmpty())
//	return processCommand(cmd);
//    }
//  else
//    return true;
}
Example #8
0
int main(int argc, char ** argv)
{
    int start_time = time(0);

    int cpus;

#ifdef _OPENMP
    omp_set_num_threads(cpus);
#else
    cpus=1;
#endif
    
    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////
    ProgramVersion();

    
    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////
    // parameters
    Parameters par;
    std::vector<std::string> vec_arg(argc+2); // we add 2 nothing
    for(int i=0; i<argc; i++) vec_arg[i]=(std::string) argv[i];
    vec_arg[argc]="nothing"; // for checking
    vec_arg[argc+1]="nothing";

    if (!par.read(vec_arg))
    {
        std::cout << std::endl;
        std::cout << " For more information type [GeneEvolve --help]." << std::endl;
        std::cout << std::endl;
        return -1;
    }

    if (par._help)
    {
        helpFile();
        return -1;
    }
    
    if (!par.check())
    {
        std::cout << std::endl;
        std::cout << " For more information type [GeneEvolve --help]." << std::endl;
        std::cout << std::endl;
        return -1;
    }
    
    
    par.print();
    
    
    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////
    // main simulation
    Simulation simulation;
    simulation.par=par;

    if(!simulation.run())
    {
        std::cout << "Program exits with an error." << std::endl;
        return -1;
    }
    
    //if(log)
    //    fclose(LogFile);

    
    /////////////////////////////////////////////////////////////////////////////////
    /////////////////////////////////////////////////////////////////////////////////
    int time_tot = time(0) - start_time;
    std::cout << "\n Program Successfully finished.\n ";
    printf("\n Total Run completed in %d hours, %d mins, %d seconds.\n",
           time_tot / 3600, (time_tot % 3600) / 60, time_tot % 60);
    std::cout << "\n Thank You for using GeneEvolve !!! " << std::endl << std::endl;

	return 0;
}
Example #9
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QApplication::setOrganizationName(_S("Majister"));
    QApplication::setApplicationName(_S("jPos"));

    qRegisterMetaType<SyncState>("SyncState");

    // Имя файла логов
    logFileName.clear();

    // Настройки базы - SQLite
    QString mainBase = _S("db.sqlite3");
    QString dbDriver = _S("QSQLITE");
    QString dbUser;
    QString dbPass;
    QString dbOptions;
    QString executeModule;
    QString executeParams;


    QString styleFileName;
    bool stylefree = false;

    //  Уровни лога, 1- только ошибки, 2 - основные действия, 3 - отладка каждого чиха
    int  loglevel = 1;
    //  Обнулить файл логов
    bool newlog        = false;
    bool resetSettings = false;
    bool showHelp      = false;
    bool saveSources   = false;


    QStringList args = QCoreApplication::arguments();
    for (int i = 1; i < args.count(); ++i)
    {
        QString value = args.at(i);

        if (value == _S("--logfile") && i < args.count())
        {
            logFileName = args.at(++i);
            continue;
        }

        if (value == _S("--loglevel") && i < args.count())
        {
            loglevel = args.at(++i).toInt();
            continue;
        }

        if (value == _S("--newlog"))
        {
            newlog = true;
            continue;
        }

        if (value == _S("--driver") && i < args.count())
        {
            dbDriver = args.at(++i);
            continue;
        }
        if (value == _S("--user") && i < args.count())
        {
            dbUser = args.at(++i);
            continue;
        }
        if (value == _S("--password") && i < args.count())
        {
            dbPass = args.at(++i);
            continue;
        }
        if (value == _S("--resetsettings"))
        {
            resetSettings = true;
            continue;
        }
        if (value == _S("--stylefree"))
        {
            stylefree = true;
            continue;
        }
        if (value == _S("--istyle") && i < args.count())
        {
            styleFileName = args.at(++i);
            continue;
        }
        if (value == _S("--version"))
        {
            qDebug() << _T("jPOS версия от %1 %2").arg(BUILDDATE).arg(BUILDTIME);
            return 0;
        }
        if (value == _S("--help"))
        {
            showHelp = true;
            break; // all other params not matter
        }
        if (value == _S("--sources"))
        {
            saveSources = true;
            break; // all other params not matter
        }
        if (value == _S("--execute") && i+1 < args.count())
        {
            executeModule = args.at(++i);
            executeParams = args.at(++i);
            continue;
        }
        // если не параметров - значит название базы
        mainBase = value;
    }


    if (saveSources)
    {
        QFile   sourcesFile(_S(":/sources/sources/sources.7z"));
        if(!sourcesFile.open(QFile::ReadOnly))
        {
            qDebug() << _T("%1 Ошибка доступа к исходникам: %2")
                        .arg(posForLog)
                        .arg(sourcesFile.errorString());
            return 1;
        }

        QFile   resultFile(_S("sources.7z"));
        if(!resultFile.open(QFile::WriteOnly))
        {
            qDebug() << _T("%1 Ошибка создания файла для сохранения: %2")
                        .arg(posForLog)
                        .arg(resultFile.errorString());
            return 1;
        }

        resultFile.write(sourcesFile.readAll());
        resultFile.close();
        sourcesFile.close();

        qDebug()<<"Исходники сохранены в файле sources.7z";
        return 0;
    }

    if (showHelp)
    {
        QFile   helpFile(_S(":/texts/texts/help.txt"));
        helpFile.open(QFile::ReadOnly);
        QString helpText = helpFile.readAll();
        qDebug() << _T("jPOS версия от %1 %2").arg(BUILDDATE).arg(BUILDTIME)<<endl;
        qDebug() << helpText;
        return 0;
    }

    if (newlog)
    {
        QFile::remove(logFileName);
    }


    if (!logFileName.isEmpty())
        qInstallMessageHandler(fileMessageHandler);
    //else
    //    qInstallMessageHandler(outputMessageHandler);


    if(!stylefree)
    {
        QFile styleFile;
        if(!styleFileName.isEmpty())
            styleFile.setFileName(styleFileName);
        else
            styleFile.setFileName(":/qss/qss/black-n-orange.qss");

        styleFile.open(QFile::ReadOnly);
        QString styleSheet = QString::fromLatin1(styleFile.readAll());
        qApp->setStyleSheet(styleSheet);
    }

    Datapipe               * data = new Datapipe();
    QMap<QString, QVariant>* vars = data->getVariables();

    if (loglevel > 0)
        qDebug() << _T("%1 Уровень лога: %2").arg(posForLog).arg(loglevel);

    vars->insert(_S("loglevel"), loglevel);


    QSettings *settings = data->getSettings();
    if (resetSettings)
        settings->clear();

    QStringList settingsKeys = settings->allKeys();

    QSettings *defaults = new QSettings(_S(":/defaults/defaults/globalsettings.ini"), QSettings::IniFormat);
    defaults->setIniCodec(QTextCodec::codecForName("UTF-8"));

    QStringList defaultKeys = defaults->allKeys();

    for (int i = 0; i < defaultKeys.count(); i++)
    {
        QString  key   = defaultKeys.at(i);
        QVariant value = defaults->value(key);

        if (!settingsKeys.contains(key))
            settings->setValue(key, value);
    }
    delete defaults;

    QFont font;
    font.setFamily(settings->value("global/default_font","DejaVu Sans").toString());
    font.setPixelSize(settings->value("global/default_font_size",14).toInt());
    font.setBold(settings->value("global/defalut_font_bold",true).toBool());

    qApp->setFont(font);


    // Финт - зададим дефолты для некоторых баз
    if((dbDriver=="QIBASE" || dbDriver=="QFIREBIRD") && dbUser.isEmpty())
        dbUser="******";
    if((dbDriver=="QIBASE" || dbDriver=="QFIREBIRD") && dbPass.isEmpty())
        dbPass="******";


    QSqlDatabase db = QSqlDatabase::addDatabase(dbDriver);

    db.setDatabaseName(mainBase);
    db.setUserName(dbUser);
    db.setPassword(dbPass);
    db.setConnectOptions(dbOptions);

    if (!db.open())
    {
        qCritical()<<_T("%1 Ошибка подключения: %2").arg(posForLog).arg(db.lastError().text());
        return 2;
    }

    if (loglevel > 0)
    {
        qDebug() << _T("%1 База данных: %2").arg(posForLog).arg(mainBase);
        qDebug() << _T("%1 Драйвер: %2").arg(posForLog).arg(dbDriver);
        qDebug() << _T("%1 Пользователь: %2").arg(posForLog).arg(dbUser);
        qDebug() << _T("%1 Пароль: %2").arg(posForLog).arg(dbPass);
        qDebug() << _T("%1 Настройки: %2").arg(posForLog).arg(dbOptions);
    }
    vars->insert(_S("database"), mainBase);
    vars->insert(_S("database_driver"), dbDriver);
    vars->insert(_S("database_user"), dbUser);
    vars->insert(_S("database_password"), dbPass);
    vars->insert(_S("database_settings"), dbOptions);

    QSqlQuery query;


    query.prepare(settings->value(_S("global/queries/settings")).toString());
    if (query.exec())
    {
        while (query.next())
        {
            vars->insert(query.value(0).toString(), query.value(1));
            if(loglevel > 0)
                qDebug() << _T("%1 Переменные: %2 = %3").arg(posForLog).arg(query.value(0).toString()).arg(query.value(1).toString());
        }
    }
    else
    {
        bool solved = false;
        if(dbDriver=="QSQLITE")
        {
            QMessageBox::StandardButton reply;
            reply = QMessageBox::question(0,
                                          _T("Не обнаружена база данных"),
                                          _T("Не обнаружена база данных\nСоздать новую?"),
                                          QMessageBox::Yes|QMessageBox::No);

            if (reply == QMessageBox::Yes)
            {
                QFile file(":/defaults/defaults/database_sqlite.sql");
                if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
                {
                    qCritical() << _T("%1 Ошибка создания новой базы данных\n%2").arg(posForLog).arg(file.errorString());
                    return  0;
                }


                QStringList queryPartsList = QString::fromUtf8(file.readAll()).split(QRegExp("\\s"), QString::SkipEmptyParts);

                int triggerDepth=0;
                int stringDepth=0;
                bool skipOneBegin=false;
                QString queryFromParts;

                for(int i=0; i<queryPartsList.count();++i)
                {
                    QString part = queryPartsList.at(i).trimmed();

                    if(part.isEmpty())
                        continue;

                    if(part.toUpper() == "CREATE" && i+1 < queryPartsList.count())
                        if(queryPartsList.at(i+1)=="TRIGGER")
                        {
                            triggerDepth++;
                            skipOneBegin=true;
                        }


                    if(triggerDepth > 0 && part.toUpper()=="BEGIN")
                    {
                        if(skipOneBegin)
                            skipOneBegin=false;
                        else
                            triggerDepth++;
                    }
                    if(triggerDepth > 0 && part.toUpper()=="CASE")
                            triggerDepth++;

                    if(triggerDepth > 0 && part.toUpper().startsWith("END"))
                            triggerDepth--;

                    queryFromParts += _S(" %1").arg(part);

                    //qDebug()<<part<<triggerDepth<<stringDepth;

                    if(part.contains(";") && triggerDepth==0 && stringDepth==0)
                    {
                        bool skipQuery = false;
                        if(queryFromParts.contains("CREATE TABLE sqlite_sequence"))
                            skipQuery=true;

                        if(queryFromParts.trimmed().isEmpty())
                            skipQuery=true;

                        if(queryFromParts.trimmed()==";")
                            skipQuery=true;

                        if(!skipQuery)
                        {
                            if (!query.exec(queryFromParts))
                            {
                                qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery());
                                return 1;
                            }
                           // qDebug()<<queryFromParts;
                        }
                        queryFromParts.clear();
                    }

                }

                QDialog dlg;
                QFormLayout layout;
                dlg.setLayout(&layout);

                QLineEdit posID;
                layout.addRow(_T("Код ПОС-а"), &posID);

                QLineEdit generatorMin;
                layout.addRow(_T("Генератор мин"), &generatorMin);

                QLineEdit generatorMax;
                layout.addRow(_T("Генератор макс"), &generatorMax);

                QPushButton bt;
                bt.setText("OK");
                layout.addRow(0, &bt);
                dlg.connect(&bt, SIGNAL(clicked()), &dlg, SLOT(accept()));

                if(dlg.exec()==QDialog::Accepted)
                {
                    query.prepare(settings->value(_S("global/queries/set_pos_id")).toString());
                    query.bindValue(":val", posID.text().toInt());
                    if(!query.exec())
                    {
                        qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery());
                        return 1;
                    }
                    query.prepare(settings->value(_S("global/queries/set_generator_min")).toString());
                    query.bindValue(":val", generatorMin.text().toInt());
                    if(!query.exec())
                    {
                        qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery());
                        return 1;
                    }

                    query.prepare(settings->value(_S("global/queries/set_generator_min1_sqlite")).toString());
                    query.bindValue(":val", generatorMin.text().toInt());
                    if(!query.exec())
                    {
                        qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery());
                        return 1;
                    }

                    query.prepare(settings->value(_S("global/queries/set_generator_min2_sqlite")).toString());
                    query.bindValue(":val", generatorMin.text().toInt());
                    if(!query.exec())
                    {
                        qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery());
                        return 1;
                    }

                    query.prepare(settings->value(_S("global/queries/set_generator_max")).toString());
                    query.bindValue(":val", generatorMax.text().toInt());
                    if(!query.exec())
                    {
                        qCritical() << _T("%1 Ошибка создания новой базы данных\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery());
                        return 1;
                    }

                }
                else
                {
                    QMessageBox message;
                    message.setText(_T("Создание новой базы данных отменено"));
                    message.exec();
                    return 1;
                }

               solved = true;
            }
        }

        if(!solved){
            qCritical() << _T("%1 Ошибка чтения настроек\n%2\n%3").arg(posForLog, query.lastError().text(), query.lastQuery());
            return 1;
        }
    }


    int width  = 0;
    int height = 0;

    if (QApplication::desktop()->screenGeometry().width() > QApplication::desktop()->screenGeometry().height())
    {
        width  = QApplication::desktop()->screenGeometry().width();
        height = QApplication::desktop()->screenGeometry().height();
    }
    else
    {
        width  = QApplication::desktop()->screenGeometry().height();
        height = QApplication::desktop()->screenGeometry().width();
    }


    double scale = settings->value("global/button_scale", 1).toDouble();



    vars->insert(_S("standart_button_width"), (int) width / 12 * scale);
    vars->insert(_S("standart_button_height"), (int) height / 12 * scale);
    vars->insert(_S("standart_text_height"), (int) height / 18 * scale);
    vars->insert(_S("standart_margins"), (int) vars->value(_S("standart_button_width")).toInt() * 0.1 * scale);

    // заполняем тут, чтобы не тянуть в плагины все файлы
    data->setPrinter(new ChequePrinter(data->getSettings(), data->getVariables()));


    if (loglevel > 0)
    {
        QStringList keys = settings->allKeys();
        for (int i = 0; i < keys.count(); i++)
            qDebug() << _T("%1 Настройки: %2 %3").arg(posForLog).arg(keys.at(i)).arg(settings->value(keys.at(i)).toString());
    }


    if (loglevel > 0)
        qDebug() << _T("%1 Запуск ").arg(posForLog);


    MainWindow window(data);
    window.showFullScreen();

    // проверка 3
    return a.exec();
}
Example #10
0
bool
MeshGenerator::getValues(int &depth,
			 int &fillValue,
			 bool &checkForMore,
			 bool &lookInside,
			 QGradientStops &stops,
			 bool doBorder,
			 int &chan,
			 bool &avgColor)
{
  chan = 0;
  depth = 1;
  fillValue = -1;
  checkForMore = true;
  lookInside = false;
  avgColor = false;
  m_useTagColors = false;
  m_scaleModel = 1.0;
  QGradientStops vstops;
  vstops << QGradientStop(0.0, QColor(50 ,50 ,50 ,255))
	 << QGradientStop(0.5, QColor(200,150,100,255))
	 << QGradientStop(1.0, QColor(255,255,255,255));

  if (doBorder) fillValue = 0;
  
  PropertyEditor propertyEditor;
  QMap<QString, QVariantList> plist;
  
  QVariantList vlist;

  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(avgColor);
  plist["average color"] = vlist;

  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(m_useTagColors);
  plist["apply tag colors"] = vlist;

  vlist.clear();
  vlist << QVariant("int");
  vlist << QVariant(chan);
  vlist << QVariant(0);
  vlist << QVariant(2);
  plist["mop channel"] = vlist;

  vlist.clear();
  vlist << QVariant("int");
  vlist << QVariant(depth);
  vlist << QVariant(0);
  vlist << QVariant(200);
  plist["depth"] = vlist;

  vlist.clear();
  vlist << QVariant("int");
  vlist << QVariant(fillValue);
  vlist << QVariant(-1);
  vlist << QVariant(255);
  plist["fillvalue"] = vlist;

  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(checkForMore);
  plist["greater"] = vlist;

  vlist.clear();
  vlist << QVariant("checkbox");
  vlist << QVariant(lookInside);
  plist["look inside"] = vlist;

  vlist.clear();
  vlist << QVariant("float");
  vlist << QVariant(m_scaleModel);
  vlist << QVariant(0.001);
  vlist << QVariant(1.0);
  vlist << QVariant(0.005); // singlestep
  vlist << QVariant(3); // decimals
  plist["scale"] = vlist;

  vlist.clear();
  vlist << QVariant("colorgradient");
  for(int s=0; s<vstops.size(); s++)
    {
      float pos = vstops[s].first;
      QColor color = vstops[s].second;
      int r = color.red();
      int g = color.green();
      int b = color.blue();
      int a = color.alpha();
      vlist << QVariant(pos);
      vlist << QVariant(r);
      vlist << QVariant(g);
      vlist << QVariant(b);
      vlist << QVariant(a);
    }
  plist["color gradient"] = vlist;


  vlist.clear();
  QFile helpFile(":/mesh.help");
  if (helpFile.open(QFile::ReadOnly))
    {
      QTextStream in(&helpFile);
      QString line = in.readLine();
      while (!line.isNull())
	{
	  if (line == "#begin")
	    {
	      QString keyword = in.readLine();
	      QString helptext;
	      line = in.readLine();
	      while (!line.isNull())
		{
		  helptext += line;
		  helptext += "\n";
		  line = in.readLine();
		  if (line == "#end") break;
		}
	      vlist << keyword << helptext;
	    }
	  line = in.readLine();
	}
    }	      
  plist["commandhelp"] = vlist;

  vlist.clear();
  QString mesg;
  mesg += "File : "+m_vfm->fileName()+"\n";
  int d = m_vfm->depth();
  int w = m_vfm->width();
  int h = m_vfm->height();
  mesg += QString("Volume Size : %1 %2 %3\n").arg(h).arg(w).arg(d);
  mesg += QString("Data Min : %1 %2 %3\n").arg(m_dataMin.x).arg(m_dataMin.y).arg(m_dataMin.z);
  mesg += QString("Data Max : %1 %2 %3\n").arg(m_dataMax.x).arg(m_dataMax.y).arg(m_dataMax.z);

  if (m_voxelType > 0)
    mesg += "\n ** Only opacity based surface generation available for unsigned short data **\n";

  mesg += "\n* You can keep on working while this process is running.\n";
  vlist << mesg;
  plist["message"] = vlist;


  QStringList keys;
  keys << "average color";
  keys << "apply tag colors";
  keys << "mop channel";
  keys << "isosurface value";
  keys << "depth";
  keys << "fillvalue";
  keys << "scale";
  keys << "greater";
  keys << "look inside";
  keys << "color gradient";
  keys << "commandhelp";
  keys << "message";

  propertyEditor.set("Mesh Repainting Parameters", plist, keys);
  QMap<QString, QPair<QVariant, bool> > vmap;
  
  if (propertyEditor.exec() == QDialog::Accepted)
    vmap = propertyEditor.get();
  else
    return false;
  
  for(int ik=0; ik<keys.count(); ik++)
    {
      QPair<QVariant, bool> pair = vmap.value(keys[ik]);

      if (pair.second)
	{
	  if (keys[ik] == "average color")
	    avgColor = pair.first.toBool();
	  else if (keys[ik] == "apply tag colors")
	    m_useTagColors = pair.first.toBool();
	  else if (keys[ik] == "mop channel")
	    chan = pair.first.toInt();
	  else if (keys[ik] == "color gradient")
	    vstops = propertyEditor.getGradientStops(keys[ik]);
	  else if (keys[ik] == "scale")
	    m_scaleModel = pair.first.toFloat();
	  else if (keys[ik] == "depth")
	    depth = pair.first.toInt();
	  else if (keys[ik] == "fillvalue")
	    fillValue = pair.first.toInt();
	  else if (keys[ik] == "greater")
	    checkForMore = pair.first.toBool();
	  else if (keys[ik] == "look inside")
	    lookInside = pair.first.toBool();
	}
    }

  stops = resampleGradientStops(vstops);

  return true;
}
//Begin excution of function main
int main()
{
	Menu *menuPtr[5];   //declare an array of pointer of class type Menu
   Menu menu;          //declare an object of the class type Menu

   Insurpolicy *Bpolicy;  //declare a pointer to the base class

   Homeinsurpolicy HCpolicy;         //declare an object of the class type Homeinsurpolicy
   Homeinsurpolicy blankHCpolicy;    //declare an object of the class type Homeinsurpolicy for initializing objects of its type to blank
   fstream HomeFile ("HomeFile.txt", ios::in | ios::out | ios::binary);   //create a file for storing home insurance

   Lifeinsurpolicy LCpolicy;        //declare an object of the class type Lifeinsurpolicy
   Lifeinsurpolicy blankLCpolicy;   //declare an object of the class type Lifeinsurpolicy for initializing objects of its type to blank
   fstream LifeFile("LifeFile.txt", ios::in | ios::out | ios::binary);    //create a file for storing life insurance

   MVinsurpolicy   MVCpolicy;       //declare an object of the class type MVinsurpolicy
   MVinsurpolicy   blankMVCpolicy;  //declare an object of the class type MVinsurpolicy for initializing objects of its type to blank
   fstream MVFile ("MVFile.txt", ios::in | ios::out | ios::binary);  //create a file for storing motor vehicle insurance

   int Option;  //Menu selection/option
   int Polopt;  //policy selection/option

   Startup( );  //call a function to display boot up screen

   //exit program if fstream cannot open file
   if (!HomeFile)
   {
   	cerr << "HomeFile File could not be opened."<<endl;  //display error
      exit (1);
   }// end if

   //exit program if fstream cannot open file
   if (!LifeFile)
   {
   	cerr << "LifeFile File could not be opened."<<endl;  //display error
      exit (1);
   }// end if

   //exit program if fstream cannot open file
   if (!MVFile)
   {
   	cerr << "MVFile File could not be opened."<<endl;  //display error
      exit (1);
   }//end if

   system("title True Value Insurance Company Ltd.");  //programme title

   Option = menu.Popumenu(menuPtr);   //call function to get user option

   //while the option is not 5, do the following
   while (Option != 5) {

      //do a case on the option
   	switch (Option) {

      	case 1:           //Add policy

               // call a function to get the policy option that the user wants and set it to Polopt
               Polopt = Poloption();
               //do a case on the Polopt
               switch(Polopt) {
						case 1:                               //if 1 add home policy
                     HCpolicy.AddHomeDisplayScreen( );  //Create display screen
                     HCpolicy.addPolicy(HomeFile);      //call object method to add policy and send the home file to it
                     HCpolicy = blankHCpolicy;          //then initialize the object to be blank
                  	break;

						case 2:                              //if 2 add life policy
                     LCpolicy.AddLifeDisplayScreen( ); //Create display screen
                     LCpolicy.addPolicy(LifeFile);     //call object method to add policy and send the life file to it
                     LCpolicy = blankLCpolicy;         //then initialize the object to be blank
                  	break;

						case 3:                             //if 3 add motor vehicle policy
                     MVCpolicy.AddMotovDisplayScreen( ); //Create display screen
                     MVCpolicy.addPolicy(MVFile);        //call object method to add policy and send the motor vehicle file to it
                     MVCpolicy = blankMVCpolicy;         //then initialize the object to be blank
                  	break;

               }// end switch

         	break;

      	case 2: 				//Delete policy

         		// call a function to get the policy option that the user wants and set it to Polopt
               Polopt = Poloption();
               //do a case on the Polopt
               switch(Polopt) {
						case 1:                            //if 1 delete home policy
                  	HCpolicy.DeleteHome(HomeFile);  //call object method to delete policy and send the home file to it
                     HCpolicy = blankHCpolicy;       //then initialize the object to be blank
                  	break;

						case 2:                           //if 2 delete life policy
                     LCpolicy.DeleteLife(LifeFile); //call object method to delete policy and send the life file to it
                     LCpolicy = blankLCpolicy;      //then initialize the object to be blank
                  	break;

						case 3:                           //if 3 delete a motor vehicle policy
                     MVCpolicy.DeleteMotov(MVFile); //call object method to delete policy and send the motor vehicle file to it
                     MVCpolicy = blankMVCpolicy;    //then initialize the object to be blank
                  	break;

               }// end switch

         	break;

      	case 3: 				//Edit policy

         		// call a function to get the policy option that the user wants and set it to Polopt
               Polopt = Poloption();
               //do a case on the Polopt
               switch(Polopt) {
						case 1:                             //if 1 edit home policy
                     HCpolicy.EditPolicy( HomeFile ); //call object method to edit policy and send the home file to it
                  	break;

						case 2:                             //if 2 edit life policy
                     LCpolicy.EditPolicy( LifeFile ); //call object method to edit policy and send the life file to it
                  	break;

						case 3:                            //if 3 edit motor vehicle policy
                  	MVCpolicy.EditPolicy( MVFile ); //call object method to edit policy and send the motor vehicle file to it
                  	break;

               }// end switch

         	break;

      	case 4:           //View policy

         		// call a function to get the policy option that the user wants and set it to Polopt
               Polopt = Poloption();
               //do a case on the Polopt
               switch(Polopt) {

						case 1:                         //if 1 view home policy

                  	Bpolicy = &HCpolicy;         //point the base class to the child class home

                     /*call the view method inside the child object to get policy to view
                       if it return a zero then dont enter the if statment
                     */
                     if ( HCpolicy.ViewHome(HomeFile) != 0 ){
                                                        //if not equal to 0
                        ThemeStyle1( );     //create screen theme
                  		Bpolicy->Insurpolicy::Display( ); //display the base class data
                  		Bpolicy->Display( );              //display the child class data
                     }//end if
                     gotoxy( 25, 22); system("PAUSE");
                  	break;

						case 2:                        //if 2 view life policy
                  	Bpolicy = &LCpolicy;        //point the base class to the child class life

                     /*call the view method inside the child object to get policy to view
                       if it return a zero then dont enter the if statment
                     */
                     if ( LCpolicy.ViewLife(LifeFile) != 0 ){
                                                     //if not equal to 0
                        ThemeStyle1( );             //create screen theme
                  		Bpolicy->Insurpolicy::Display( );  //display the base class data
                  		Bpolicy->Display( );               //display the child class data
                     }//end if
                     gotoxy( 25, 22); system("PAUSE");
                  	break;

						case 3:                     //if 3 view motor vehicle policy

                  	Bpolicy = &MVCpolicy;    //point the base class to the child class motor vehicle

                     /*call the view method inside the child object to get policy to view
                       if it return a zero then dont enter the if statment
                     */
                     if ( MVCpolicy.ViewMotov(MVFile) != 0 ){
                                                //if not equal to 0
                        ThemeStyle1( );        //create screen theme
                  		Bpolicy->Insurpolicy::Display( );   //display the base class data
                  		Bpolicy->Display( );                //display the child class data
                     } //end if
                     gotoxy( 25, 24); system("PAUSE");
                  	break;

               }// end switch

         	break;

         case 6:
         	helpFile();  //function calls the help
         	break;

         case 7:
            AboutUs();  //function tell about the program
         	break;

         case 8:
            Credit();  //function gives credit to the programmers
         	break;

         default :
         	cout<<"\a\a\a";  //sound the system alarm to notify wrong input

      }//end switch

      Option = menu.Popumenu(menuPtr);  //call function to get user option

   }//end while

   Shutdown( );  //display a shutdown screen
   
   return 0;  //the function has run successfully

}//end function main
Example #12
0
bool
Grids::keyPressEvent(QKeyEvent *event)
{
  for(int i=0; i<m_grids.count(); i++)
    {
      if (m_grids[i]->grabsMouse())
	{
	  if (event->key() == Qt::Key_P)
	    {
	      bool b = m_grids[i]->showPoints();
	      m_grids[i]->setShowPoints(!b);    
	      return true;
	    }
	  else if (event->key() == Qt::Key_N)
	    {
	      bool b = m_grids[i]->showPointNumbers();
	      m_grids[i]->setShowPointNumbers(!b);    
	      return true;
	    }
	  else if (event->key() == Qt::Key_X)
	    {
	      m_grids[i]->setMoveAxis(GridGrabber::MoveX);
	      return true;
	    }
	  else if (event->key() == Qt::Key_Y)
	    {
	      if (event->modifiers() & Qt::ControlModifier ||
		  event->modifiers() & Qt::MetaModifier)
		m_grids[i]->redo();
	      else
		m_grids[i]->setMoveAxis(GridGrabber::MoveY);
	      return true;
	    }
	  else if (event->key() == Qt::Key_Z)
	    {
	      if (event->modifiers() & Qt::ControlModifier ||
		  event->modifiers() & Qt::MetaModifier)
		m_grids[i]->undo();
	      else
		m_grids[i]->setMoveAxis(GridGrabber::MoveZ);
	      return true;
	    }
	  else if (event->key() == Qt::Key_W)
	    {
	      m_grids[i]->setMoveAxis(GridGrabber::MoveAll);
	      return true;
	    }
	  else if (event->key() == Qt::Key_Delete ||
		   event->key() == Qt::Key_Backspace ||
		   event->key() == Qt::Key_Backtab)
	    {
	      m_grids[i]->removeFromMouseGrabberPool();
	      m_grids.removeAt(i);
	      return true;
	    }
	  
	  if (event->key() == Qt::Key_Space)
	    {
	      PropertyEditor propertyEditor;
	      QMap<QString, QVariantList> plist;

	      QVariantList vlist;

	      vlist.clear();
	      vlist << QVariant("double");
	      vlist << QVariant(m_grids[i]->opacity());
	      vlist << QVariant(0.0);
	      vlist << QVariant(1.0);
	      vlist << QVariant(0.1); // singlestep
	      vlist << QVariant(1); // decimals
	      plist["opacity"] = vlist;

	      vlist.clear();
	      vlist << QVariant("color");
	      Vec pcolor = m_grids[i]->color();
	      QColor dcolor = QColor::fromRgbF(pcolor.x,
					       pcolor.y,
					       pcolor.z);
	      vlist << dcolor;
	      plist["color"] = vlist;

	      vlist.clear();
	      plist["command"] = vlist;


	      vlist.clear();
	      QFile helpFile(":/grids.help");
	      if (helpFile.open(QFile::ReadOnly))
		{
		  QTextStream in(&helpFile);
		  QString line = in.readLine();
		  while (!line.isNull())
		    {
		      if (line == "#begin")
			{
			  QString keyword = in.readLine();
			  QString helptext;
			  line = in.readLine();
			  while (!line.isNull())
			    {
			      helptext += line;
			      helptext += "\n";
			      line = in.readLine();
			      if (line == "#end") break;
			    }
			  vlist << keyword << helptext;
			}
		      line = in.readLine();
		    }
		}	      
	      plist["commandhelp"] = vlist;

	      QStringList keys;
	      keys << "color";
	      keys << "opacity";
	      keys << "gap";
	      keys << "command";
	      keys << "commandhelp";
	      

	      propertyEditor.set("Grid Parameters", plist, keys);

	      
	      QMap<QString, QPair<QVariant, bool> > vmap;

	      if (propertyEditor.exec() == QDialog::Accepted)
		vmap = propertyEditor.get();
	      else
		return true;
	      
	      keys = vmap.keys();

	      for(int ik=0; ik<keys.count(); ik++)
		{
		  QPair<QVariant, bool> pair = vmap.value(keys[ik]);


		  if (pair.second)
		    {
		      if (keys[ik] == "color")
			{
			  QColor color = pair.first.value<QColor>();
			  float r = color.redF();
			  float g = color.greenF();
			  float b = color.blueF();
			  pcolor = Vec(r,g,b);
			  m_grids[i]->setColor(pcolor);
			}
		      else if (keys[ik] == "opacity")
			m_grids[i]->setOpacity(pair.first.toDouble());
		    }
		}

	      QString cmd = propertyEditor.getCommandString();
	      if (!cmd.isEmpty())
		processCommand(i, cmd);	
	      
 	      emit updateGL();
	    }
	}
    }
  
  return true;
}
Example #13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow),
    m_contactsModel(new CContactsModel(this)),
    m_messagingModel(new CMessagingModel(this)),
    m_chatContactsModel(new CContactsModel(this)),
    m_chatMessagingModel(new CMessagingModel(this)),
    m_chatInfoModel(new CChatInfoModel(this)),
    m_activeChatId(0),
    m_chatCreationMode(false),
    m_core(new CTelegramCore(this)),
    m_registered(false),
    m_appState(AppStateNone)
{
    ui->setupUi(this);
    ui->contactListTable->setModel(m_contactsModel);
    ui->messagingView->setModel(m_messagingModel);
    ui->groupChatContacts->setModel(m_chatContactsModel);
    ui->groupChatChatsList->setModel(m_chatInfoModel);
    ui->groupChatMessagingView->setModel(m_chatMessagingModel);

    QCompleter *comp = new QCompleter(m_contactsModel, this);
    ui->messagingContactPhone->setCompleter(comp);
    ui->groupChatContactPhone->setCompleter(comp);

    connect(ui->secretOpenFile, SIGNAL(clicked()), SLOT(loadSecretFromBrowsedFile()));

    // Telepathy Morse app info
    CAppInformation appInfo;
    appInfo.setAppId(14617);
    appInfo.setAppHash(QLatin1String("e17ac360fd072f83d5d08db45ce9a121"));
    appInfo.setAppVersion(QLatin1String("0.1"));
    appInfo.setDeviceInfo(QLatin1String("pc"));
    appInfo.setOsInfo(QLatin1String("GNU/Linux"));
    appInfo.setLanguageCode(QLatin1String("en"));

    m_core->setAppInformation(&appInfo);
    m_core->setAutoReconnection(true);

    connect(m_core, SIGNAL(connectionStateChanged(TelegramNamespace::ConnectionState)),
            SLOT(whenConnectionStateChanged(TelegramNamespace::ConnectionState)));
    connect(m_core, SIGNAL(phoneStatusReceived(QString,bool,bool)),
            SLOT(whenPhoneStatusReceived(QString,bool,bool)));
    connect(m_core, SIGNAL(phoneCodeRequired()),
            SLOT(whenPhoneCodeRequested()));
    connect(m_core, SIGNAL(authSignErrorReceived(TelegramNamespace::AuthSignError,QString)),
            SLOT(whenAuthSignErrorReceived(TelegramNamespace::AuthSignError,QString)));
    connect(m_core, SIGNAL(contactListChanged()),
            SLOT(whenContactListChanged()));
    connect(m_core, SIGNAL(contactProfileChanged(QString)),
            SLOT(whenContactProfileChanged(QString)));
    connect(m_core, SIGNAL(avatarReceived(QString,QByteArray,QString,QString)),
            SLOT(whenAvatarReceived(QString,QByteArray,QString)));
    connect(m_core, SIGNAL(messageMediaDataReceived(QString,quint32,QByteArray,QString,TelegramNamespace::MessageType,quint32,quint32)),
            SLOT(whenMessageMediaDataReceived(QString,quint32,QByteArray,QString,TelegramNamespace::MessageType,quint32,quint32)));
    connect(m_core, SIGNAL(messageReceived(TelegramNamespace::Message)),
            SLOT(whenMessageReceived(TelegramNamespace::Message)));
    connect(m_core, SIGNAL(contactChatTypingStatusChanged(quint32,QString,bool)),
            SLOT(whenContactChatTypingStatusChanged(quint32,QString,bool)));
    connect(m_core, SIGNAL(contactTypingStatusChanged(QString,bool)),
            SLOT(whenContactTypingStatusChanged(QString,bool)));
    connect(m_core, SIGNAL(contactStatusChanged(QString,TelegramNamespace::ContactStatus)),
            SLOT(whenContactStatusChanged(QString)));
    connect(m_core, SIGNAL(sentMessageStatusChanged(QString,quint64,TelegramNamespace::MessageDeliveryStatus)),
            m_messagingModel, SLOT(setMessageDeliveryStatus(QString,quint64,TelegramNamespace::MessageDeliveryStatus)));
    connect(m_core, SIGNAL(uploadingStatusUpdated(quint32,quint32,quint32)),
            SLOT(whenUploadingStatusUpdated(quint32,quint32,quint32)));

    connect(m_core, SIGNAL(chatAdded(quint32)), SLOT(whenChatAdded(quint32)));
    connect(m_core, SIGNAL(chatChanged(quint32)), SLOT(whenChatChanged(quint32)));

    ui->groupChatContacts->hideColumn(CContactsModel::Blocked);

    ui->mainSplitter->setSizes(QList<int>() << 0 << 100);
    ui->groupChatSplitter->setSizes(QList<int>() << 550 << 450 << 300);

    ui->groupChatChatsList->setColumnWidth(CChatInfoModel::Id, 30);

    ui->blockContact->hide();
    ui->unblockContact->hide();

    ui->groupChatLeaveChat->hide();

    QFile helpFile(QLatin1String(":/USAGE"));
    helpFile.open(QIODevice::ReadOnly);
    ui->helpView->setPlainText(helpFile.readAll());

    setAppState(AppStateNone);
    updateGroupChatAddContactButtonText();

    connect(ui->groupChatContactPhone, SIGNAL(textChanged(QString)), SLOT(updateGroupChatAddContactButtonText()));

#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
    connect(ui->messagingView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(whenCustomMenuRequested(QPoint)));
#endif

    ui->groupChatAddContactForwardMessages->hide();

    ui->messagingAttachButton->hide();
}