Beispiel #1
0
// This version sends VArrays using MPI
static void computeAndSendVertexArrays()
{
  // compute...
  for(unsigned int i = 0; i < PView::list.size(); i++)
    PView::list[i]->fillVertexArrays();

  // ...and send
  int nbArrays = PView::list.size()* 4;
  MPI_Send(&nbArrays, 1, MPI_INT, 0, MPI_GMSH_DATA_READY, MPI_COMM_WORLD);

  for(unsigned int i = 0; i < PView::list.size(); i++){
    PView *p = PView::list[i];
    PViewData *data = p->getData();
    PViewOptions *opt = p->getOptions();
    double min = data->getMin(), max = data->getMax();
    if(opt->rangeType == PViewOptions::PerTimeStep){
      min = data->getMin(opt->timeStep);
      max = data->getMax(opt->timeStep);
    }
    VertexArray *va[4] =
      {p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
    for(int type = 0; type < 4; type++){
      if(va[type]){
        int len;
        char *str = va[type]->toChar
          (p->getTag(), data->getName(), type + 1, min, max,
           data->getNumTimeSteps(), data->getTime(opt->timeStep),
           data->getBoundingBox(), len);
        MPI_Send(&len, 1, MPI_INT, 0, MPI_GMSH_VARRAY_LEN, MPI_COMM_WORLD);
        MPI_Send(str, len, MPI_CHAR, 0, MPI_GMSH_VARRAY, MPI_COMM_WORLD);
        delete [] str;
      }
    }
  }
}
Beispiel #2
0
static void computeAndSendVertexArrays(GmshClient *client, bool compute=true)
{
  for(unsigned int i = 0; i < PView::list.size(); i++){
    PView *p = PView::list[i];
    if(compute) p->fillVertexArrays();
    PViewData *data = p->getData();
    PViewOptions *opt = p->getOptions();
    double min = data->getMin(), max = data->getMax();
    if(opt->rangeType == PViewOptions::PerTimeStep){
      min = data->getMin(opt->timeStep);
      max = data->getMax(opt->timeStep);
    }
    VertexArray *va[4] =
      {p->va_points, p->va_lines, p->va_triangles, p->va_vectors};
    for(int type = 0; type < 4; type++){
      if(va[type]){
        int len;
        char *str = va[type]->toChar
          (p->getTag(), data->getName(), type + 1, min, max,
           data->getNumTimeSteps(), data->getTime(opt->timeStep),
           data->getBoundingBox(), len);
        client->SendMessage(GmshSocket::GMSH_VERTEX_ARRAY, len, str);
        delete [] str;
      }
    }
  }
}
Beispiel #3
0
int32_t
PTextViewHighlight(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	int32 start;
	if (inArgs->FindInt32("start", &start) != B_OK)
		return B_ERROR;

	int32 end;
	if (inArgs->FindInt32("end", &end) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->Highlight(start, end);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #4
0
int32_t
PListViewScrollTo(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	float x;
	if (inArgs->FindFloat("x", &x) != B_OK)
		return B_ERROR;

	float y;
	if (inArgs->FindFloat("y", &y) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->ScrollTo(x, y);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #5
0
int32_t
PTextViewLineAtOffset(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 offset;
	if (inArgs->FindInt32("offset", &offset) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();

	int32 outValue1;

	outValue1 = backend->LineAt(offset);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();

	return B_OK;
}
Beispiel #6
0
int32_t
PTextViewInsert(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	BString text;
	if (inArgs->FindString("text", &text) != B_OK)
		return B_ERROR;

	int32 length;
	if (inArgs->FindInt32("length", &length) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->Insert(text.String(), length);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #7
0
int32_t
PListViewItemFrame(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 index;
	if (inArgs->FindInt32("index", &index) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();

	BRect outValue1;

	outValue1 = backend->ItemFrame(index);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();

	return B_OK;
}
Beispiel #8
0
int32_t
PListViewDeselectExcept(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	int32 from;
	if (inArgs->FindInt32("from", &from) != B_OK)
		return B_ERROR;

	int32 to;
	if (inArgs->FindInt32("to", &to) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->DeselectExcept(from, to);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #9
0
int32_t
PTextViewCut(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in);
	
	uint64 id = 0;
	if (inArgs->FindInt64("clipid", (int64*)&id) != B_OK)
		return B_ERROR;
	
	PObject *obj = BROKER->FindObject(id);
	if (!obj || obj->GetType().ICompare("PClipboard") != 0)
		return B_BAD_DATA;
	
	PClipboard *clip = dynamic_cast<PClipboard*>(obj);
	
	if (backend->Window())
		backend->Window()->Lock();
	
	backend->Cut(clip->GetBackend());
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
Beispiel #10
0
int32_t
PListViewRemoveItem(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	int32 index;
	if (args->FindInt32("index", &index) != B_OK)
		return B_ERROR;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	bool outValue = backend->RemoveItems(index, 1);
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	outArgs->MakeEmpty();
	outArgs->AddBool("value", outValue);
	
	return B_OK;
}
Beispiel #11
0
int32_t
PListViewSelect(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	int32 index;
	if (inArgs->FindInt32("index", &index) != B_OK)
		return B_ERROR;

	bool extend;
	if (inArgs->FindBool("extend", &extend) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->Select(index, extend);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #12
0
bool PView::readMED(const std::string &fileName, int fileIndex)
{
  std::vector<std::string> fieldNames = medGetFieldNames(fileName);

  for(unsigned int index = 0; index < fieldNames.size(); index++){
    if(fileIndex < 0 || (int)index == fileIndex){
      PViewDataGModel *d = 0;
      // we use the filename as a kind of "partition" indicator, allowing to
      // complete datasets provided in separate files (e.g. coming from DDM)
      PView *p = getViewByName(fieldNames[index], -1, -1, fileName);
      if(p) d = dynamic_cast<PViewDataGModel*>(p->getData());
      bool create = d ? false : true;
      if(create) d = new PViewDataGModel();
      if(!d->readMED(fileName, index)){
        Msg::Error("Could not read data in MED file");
        if(create) delete d;
        return false;
      }
      else{
        if(create) new PView(d);
      }
    }
  }

  return true;
}
Beispiel #13
0
int32_t
PListViewScrollToPoint(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	BPoint pt;
	if (inArgs->FindPoint("pt", &pt) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->ScrollTo(pt);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #14
0
int32_t
PTextViewGetSelection(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();


	PArgs *outArgs = static_cast<PArgs*>(out);

	if (backend->Window())
		backend->Window()->Lock();

	int32 outValue1;
	int32 outValue2;

	backend->GetSelection(&outValue1, &outValue2);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();
	outArgs->AddInt32("start", outValue1);
	outArgs->AddInt32("end", outValue2);

	return B_OK;
}
Beispiel #15
0
int32_t
PMenuItemSubmenu(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BMenuItem *backend = (BMenuItem*)parent->GetView();
	
	PArgs *outArgs = static_cast<PArgs*>(out);
	outArgs->MakeEmpty();
	
	BMenu *menu = backend->Menu();
	
	PMenuBackend *menuBackend = static_cast<PMenuBackend*>(menu);
	if (menuBackend)
	{
		PMenu *pmenu = static_cast<PMenu*>(menuBackend->GetOwner());
		outArgs->AddInt64("id", pmenu->GetID());
	}
	else
		outArgs->AddInt64("id", 0);
	
	return B_OK;
}
Beispiel #16
0
int32_t
PTextViewDisallowChars(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in);
	BString string;
	if (inArgs->FindString("chars", &string) != B_OK)
		return B_ERROR;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	for (int32 i = 0; i < string.CountChars(); i++)
	{
		char c = string.ByteAt(i);
		if (c)
			backend->DisallowChar(c);
	}
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
Beispiel #17
0
int32_t
PListViewInvoke(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in);
	int32 what;
	if (args->FindInt32("message", &what) != B_OK)
		what = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	if (what >= 0)
	{
		BMessage invMsg(what);
		backend->Invoke(&invMsg);
	}
	else	
		backend->Invoke();
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
Beispiel #18
0
// Merge the vertex arrays
static void addToVertexArrays(int length, const char* bytes, int swap)
{
  std::string name;
  int num, type, numSteps;
  double min, max, time, xmin, ymin, zmin, xmax, ymax, zmax;
  VertexArray::decodeHeader(length, bytes, swap, name, num, type, min, max,
                            numSteps, time, xmin, ymin, zmin, xmax, ymax, zmax);

  PView *p = PView::list[num - 1];
  PViewData *data = p->getData();

  VertexArray *varrays[4] =
    {p->va_points, p->va_lines, p->va_triangles, p->va_vectors};

  VertexArray *va = varrays[type - 1];

  if (data->getMin() > min) data->setMin(min);
  if (data->getMax() < max) data->setMax(max);

  SBoundingBox3d bbox(xmin, ymin, zmin, xmax, ymax, zmax);
  SBoundingBox3d bb = data->getBoundingBox();
  bb += bbox;

  data->setBoundingBox(bb);

  if (type == 4) type = 2;
  VertexArray* toAdd = new VertexArray(type, 100);
  toAdd->fromChar(length, bytes, swap);
  va->merge(toAdd);
  delete toAdd;
}
Beispiel #19
0
void set_animation(int step)
{
  for(unsigned int i = 0; i < PView::list.size(); i++){
    PView * p = PView::list[i];
    if(p->getOptions()->visible){
      p->getOptions()->timeStep = step;
      p->setChanged(true);
    }
  }
}
Beispiel #20
0
int number_of_animation()
{
  int ret = 0;
  for(unsigned int i = 0; i < PView::list.size(); i++){
    PView * p = PView::list[i];
    if(p->getOptions()->visible){
      int numSteps = (int)p->getData()->getNumTimeSteps();
      if(numSteps > ret) ret = numSteps;
    }
  }
  return ret;
}
Beispiel #21
0
int32_t
PListViewAddItems(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	
	int32 index;
	if (args->FindInt32("index", &index) != B_OK)
		index = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	BList list;
	BString itemName;
	int32 nameIndex = 0;
	while (args->FindString("items", &itemName, nameIndex) == B_OK)
	{
		list.AddItem(new BString(itemName));
		nameIndex++;
	}
	
	bool outValue = true;
	if (list.CountItems() > 0)
	{
		if (index >= 0)
			outValue = backend->AddList(&list, index);
		else
			outValue = backend->AddList(&list);
	}
		
	if (backend->Window())
		backend->Window()->Unlock();
	
	for (int32 i = 0; i < list.CountItems(); i++)
		delete ((BString*)list.ItemAt(i));
	list.MakeEmpty();
	
	outArgs->MakeEmpty();
	outArgs->AddBool("value", outValue);
	
	return B_OK;
}
Beispiel #22
0
int32_t
PTextViewSetInsets(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	float left;
	if (inArgs->FindFloat("left", &left) != B_OK)
		return B_ERROR;

	float top;
	if (inArgs->FindFloat("top", &top) != B_OK)
		return B_ERROR;

	float right;
	if (inArgs->FindFloat("right", &right) != B_OK)
		return B_ERROR;

	float bottom;
	if (inArgs->FindFloat("bottom", &bottom) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();


	backend->SetInsets(left, top, right, bottom);

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #23
0
int32_t
PListViewAddItem(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	BString label;
	if (args->FindString("label", &label) != B_OK)
		label = "";
	
	int32 index;
	if (args->FindInt32("index", &index) != B_OK)
		index = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	bool outValue;
	BStringItem *item = new BStringItem(label.String());
	if (index >= 0)
		outValue = backend->AddItem(item);
	else
		outValue = backend->AddItem(item, index);
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	outArgs->MakeEmpty();
	outArgs->AddBool("value", outValue);
	
	return B_OK;
}
Beispiel #24
0
int32_t
PListViewMoveItem(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 from;
	if (inArgs->FindInt32("from", &from) != B_OK)
		return B_ERROR;

	int32 to;
	if (inArgs->FindInt32("to", &to) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();

	bool outValue1;

	outValue1 = backend->MoveItem(from, to);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();

	return B_OK;
}
Beispiel #25
0
int32_t
PListViewScrollToSelection(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	if (backend->Window())
		backend->Window()->Lock();


	backend->ScrollToSelection();

	if (backend->Window())
		backend->Window()->Unlock();

	return B_OK;
}
Beispiel #26
0
int32_t
PListViewSwapItems(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();


	PArgs *inArgs = static_cast<PArgs*>(in);

	PArgs *outArgs = static_cast<PArgs*>(out);

	int32 first;
	if (inArgs->FindInt32("first", &first) != B_OK)
		return B_ERROR;

	int32 second;
	if (inArgs->FindInt32("second", &second) != B_OK)
		return B_ERROR;

	if (backend->Window())
		backend->Window()->Lock();

	bool outValue1;

	outValue1 = backend->SwapItems(first, second);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();

	return B_OK;
}
Beispiel #27
0
void frameSolver2d::exportFrameData(const char *DISPL, const char *M)
{
#if defined(HAVE_POST)
  {
    std::map<int, std::vector<double> > data;
    for(std::size_t i = 0; i < _beams.size(); i++) {
      std::vector<double> tmp;
      // tmp.push_back(_beams[i]._e);
      // tmp.push_back(_beams[i]._i);
      // tmp.push_back(_beams[i]._a);
      tmp.reserve(6);
      for(int j = 0; j < 6; j++) {
        tmp.push_back(_beams[i]._displacement[j]);
      }
      data[_beams[i]._element->getNum()] = tmp;
    }
    PView *pv = new PView("displacements", "Beam", _myModel, data, 0.0, 6);
    pv->getData()->writeMSH(DISPL);
    delete pv;
  }
  {
    std::map<int, std::vector<double> > data;
    for(std::size_t i = 0; i < _beams.size(); i++) {
      std::vector<double> tmp;
      fullVector<double> d(_beams[i]._displacement, 6), F(6);
      _beams[i]._stiffness.mult(d, F);
      tmp.push_back(-F(2));
      tmp.push_back(F(5));
      data[_beams[i]._element->getNum()] = tmp;
    }
    PView *pv =
      new PView("Momentum", "ElementNodeData", _myModel, data, 0.0, 1);
    pv->getData()->writeMSH(M);
    delete pv;
  }
#endif
}
Beispiel #28
0
int32_t
PTextViewGetInsets(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();


	PArgs *outArgs = static_cast<PArgs*>(out);

	if (backend->Window())
		backend->Window()->Lock();

	float outValue1;
	float outValue2;
	float outValue3;
	float outValue4;

	backend->GetInsets(&outValue1, &outValue2, &outValue3, &outValue4);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();
	outArgs->AddFloat("left", outValue1);
	outArgs->AddFloat("top", outValue2);
	outArgs->AddFloat("right", outValue3);
	outArgs->AddFloat("bottom", outValue4);

	return B_OK;
}
Beispiel #29
0
PView::PView(PView *ref, bool copyOptions)
{
  _init();

  if(ref->getAliasOf() >= 0){ // alias of an alias
    PView *orig = getViewByTag(ref->getAliasOf());
    if(orig) _aliasOf = orig->getTag();
    else{
      Msg::Warning("Original view for alias does not exist anymore");
      _aliasOf = ref->getTag();
    }
  }
  else
    _aliasOf = ref->getTag();

  _data = ref->getData();
  if(copyOptions)
    _options = new PViewOptions(*ref->getOptions());
  else
    _options = new PViewOptions(*PViewOptions::reference());
  if(_options->adaptVisualizationGrid)
    _data->initAdaptiveData(_options->timeStep, _options->maxRecursionLevel,
                            _options->targetError);
}
Beispiel #30
0
int32_t
PTextViewGetText(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();
	
	PArgs *inArgs = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	outArgs->MakeEmpty();
	
	if (backend->Window())
		backend->Window()->Lock();
	
	int32 start, length;
	if (inArgs->FindInt32("start", &start) != B_OK ||
		inArgs->FindInt32("length", &length) != B_OK)
		return B_ERROR;
	
	char *buffer = new char[length + 1];
	
	backend->GetText(start, length, buffer);
	
	outArgs->AddString("text", buffer);
	
	delete [] buffer;
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}